├── .github ├── CODEOWNERS ├── logo.svg └── workflows │ ├── builds.yml │ ├── dco.yml │ └── tests.yml ├── .gitignore ├── .golangci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile.dirty ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── cmd └── frostfs-rest-gw │ ├── config.go │ ├── integration_test.go │ └── main.go ├── config ├── config.env └── config.yaml ├── docs └── gate-configuration.md ├── gen ├── models │ ├── action.go │ ├── address.go │ ├── attribute.go │ ├── balance.go │ ├── bearer.go │ ├── binary_bearer.go │ ├── container_info.go │ ├── container_list.go │ ├── container_put_info.go │ ├── eacl.go │ ├── error_response.go │ ├── error_type.go │ ├── filter.go │ ├── header_type.go │ ├── match_type.go │ ├── object_base_info.go │ ├── object_info.go │ ├── object_list.go │ ├── object_upload.go │ ├── operation.go │ ├── principal.go │ ├── record.go │ ├── role.go │ ├── rule.go │ ├── search_filter.go │ ├── search_filters.go │ ├── search_match.go │ ├── success_response.go │ ├── target.go │ ├── token_response.go │ ├── token_type.go │ └── verb.go └── restapi │ ├── doc.go │ ├── embedded_spec.go │ ├── operations │ ├── auth.go │ ├── auth_parameters.go │ ├── auth_responses.go │ ├── delete_container.go │ ├── delete_container_parameters.go │ ├── delete_container_responses.go │ ├── delete_object.go │ ├── delete_object_parameters.go │ ├── delete_object_responses.go │ ├── form_binary_bearer.go │ ├── form_binary_bearer_parameters.go │ ├── form_binary_bearer_responses.go │ ├── frostfs_rest_gw_api.go │ ├── get_balance.go │ ├── get_balance_parameters.go │ ├── get_balance_responses.go │ ├── get_container.go │ ├── get_container_e_acl.go │ ├── get_container_e_acl_parameters.go │ ├── get_container_e_acl_responses.go │ ├── get_container_parameters.go │ ├── get_container_responses.go │ ├── get_object_info.go │ ├── get_object_info_parameters.go │ ├── get_object_info_responses.go │ ├── list_containers.go │ ├── list_containers_parameters.go │ ├── list_containers_responses.go │ ├── options_auth.go │ ├── options_auth_bearer.go │ ├── options_auth_bearer_parameters.go │ ├── options_auth_bearer_responses.go │ ├── options_auth_parameters.go │ ├── options_auth_responses.go │ ├── options_containers_e_acl.go │ ├── options_containers_e_acl_parameters.go │ ├── options_containers_e_acl_responses.go │ ├── options_containers_get_delete.go │ ├── options_containers_get_delete_parameters.go │ ├── options_containers_get_delete_responses.go │ ├── options_containers_put_list.go │ ├── options_containers_put_list_parameters.go │ ├── options_containers_put_list_responses.go │ ├── options_objects_get_delete.go │ ├── options_objects_get_delete_parameters.go │ ├── options_objects_get_delete_responses.go │ ├── options_objects_put.go │ ├── options_objects_put_parameters.go │ ├── options_objects_put_responses.go │ ├── options_objects_search.go │ ├── options_objects_search_parameters.go │ ├── options_objects_search_responses.go │ ├── put_container.go │ ├── put_container_e_acl.go │ ├── put_container_e_acl_parameters.go │ ├── put_container_e_acl_responses.go │ ├── put_container_parameters.go │ ├── put_container_responses.go │ ├── put_object.go │ ├── put_object_parameters.go │ ├── put_object_responses.go │ ├── search_objects.go │ ├── search_objects_parameters.go │ └── search_objects_responses.go │ ├── server.go │ └── server_config.go ├── go.mod ├── go.sum ├── handlers ├── api.go ├── auth.go ├── auth_test.go ├── balance.go ├── container_test.go ├── containers.go ├── objects.go ├── objects_test.go ├── preflight.go ├── util.go └── util_test.go ├── internal └── util │ ├── transformers.go │ └── transformers_test.go ├── metrics ├── metrics.go ├── pprof.go └── service.go ├── spec └── rest.yaml ├── static └── docs │ ├── acl-basic.svg │ ├── docs.md │ └── index.html └── templates ├── server-config.yaml └── server ├── config.gotmpl └── server.gotmpl /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @alexvanin @KirillovDenis 2 | -------------------------------------------------------------------------------- /.github/workflows/builds.yml: -------------------------------------------------------------------------------- 1 | name: Builds 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | types: [opened, synchronize] 8 | paths-ignore: 9 | - '**/*.md' 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build_cli: 14 | name: Build CLI 15 | runs-on: ubuntu-20.04 16 | strategy: 17 | matrix: 18 | go_os: [ linux, darwin ] 19 | go_arch: [ amd64, arm64 ] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | with: 24 | fetch-depth: 0 25 | 26 | - name: Setup Go 27 | uses: actions/setup-go@v2 28 | with: 29 | go-version: 1.19 30 | 31 | - name: Restore Go modules from cache 32 | uses: actions/cache@v2 33 | with: 34 | path: /home/runner/go/pkg/mod 35 | key: deps-${{ hashFiles('go.sum') }} 36 | 37 | - name: Update Go modules 38 | run: make dep 39 | 40 | - name: Build CLI 41 | run: BUILD_OS=${{ matrix.go_os }} BUILD_ARCH=${{ matrix.go_arch }} make 42 | 43 | - name: Check version 44 | run: if [[ $(make version) == *"dirty"* ]]; then exit 1; fi 45 | 46 | build_image: 47 | needs: build_cli 48 | name: Build Docker image 49 | runs-on: ubuntu-20.04 50 | 51 | steps: 52 | - uses: actions/checkout@v2 53 | with: 54 | fetch-depth: 0 55 | 56 | - name: Set up Go 57 | uses: actions/setup-go@v2 58 | with: 59 | go-version: 1.19 60 | 61 | - name: Restore Go modules from cache 62 | uses: actions/cache@v2 63 | with: 64 | path: /home/runner/go/pkg/mod 65 | key: deps-${{ hashFiles('go.sum') }} 66 | 67 | - name: Update Go modules 68 | run: make dep 69 | 70 | - name: Build Docker image 71 | run: make image 72 | -------------------------------------------------------------------------------- /.github/workflows/dco.yml: -------------------------------------------------------------------------------- 1 | name: DCO check 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | commits_check_job: 10 | runs-on: ubuntu-latest 11 | name: Commits Check 12 | steps: 13 | - name: Get PR Commits 14 | id: 'get-pr-commits' 15 | uses: tim-actions/get-pr-commits@master 16 | with: 17 | token: ${{ secrets.GITHUB_TOKEN }} 18 | - name: DCO Check 19 | uses: tim-actions/dco@master 20 | with: 21 | commits: ${{ steps.get-pr-commits.outputs.commits }} 22 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | types: [opened, synchronize] 8 | paths-ignore: 9 | - '**/*.md' 10 | workflow_dispatch: 11 | 12 | jobs: 13 | lint: 14 | name: Lint 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: golangci-lint 20 | uses: golangci/golangci-lint-action@v2 21 | with: 22 | version: latest 23 | 24 | cover: 25 | name: Coverage 26 | runs-on: ubuntu-20.04 27 | 28 | env: 29 | CGO_ENABLED: 1 30 | steps: 31 | - uses: actions/checkout@v2 32 | with: 33 | fetch-depth: 0 34 | 35 | - name: Set up Go 36 | uses: actions/setup-go@v2 37 | with: 38 | go-version: 1.19 39 | 40 | - name: Restore Go modules from cache 41 | uses: actions/cache@v2 42 | with: 43 | path: /home/runner/go/pkg/mod 44 | key: deps-${{ hashFiles('go.sum') }} 45 | 46 | - name: Update Go modules 47 | run: make dep 48 | 49 | - name: Test and write coverage profile 50 | run: make cover 51 | 52 | - name: Upload coverage results to Codecov 53 | uses: codecov/codecov-action@v1 54 | with: 55 | fail_ci_if_error: false 56 | path_to_write_report: ./coverage.txt 57 | verbose: true 58 | 59 | tests: 60 | name: Tests 61 | runs-on: ubuntu-20.04 62 | strategy: 63 | matrix: 64 | go_versions: [ '1.17', '1.18.x', '1.19.x' ] 65 | fail-fast: false 66 | steps: 67 | - uses: actions/checkout@v2 68 | with: 69 | fetch-depth: 0 70 | 71 | - name: Set up Go 72 | uses: actions/setup-go@v2 73 | with: 74 | go-version: '${{ matrix.go_versions }}' 75 | 76 | - name: Restore Go modules from cache 77 | uses: actions/cache@v2 78 | with: 79 | path: /home/runner/go/pkg/mod 80 | key: deps-${{ hashFiles('go.sum') }} 81 | 82 | - name: Update Go modules 83 | run: make dep 84 | 85 | - name: Run tests 86 | run: make test 87 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | bin 3 | temp 4 | /plugins/ 5 | /vendor/ 6 | 7 | *.log 8 | 9 | .cache 10 | 11 | coverage.txt 12 | coverage.html 13 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | # This file contains all available configuration options 2 | # with their default values. 3 | 4 | # options for analysis running 5 | run: 6 | # timeout for analysis, e.g. 30s, 5m, default is 1m 7 | timeout: 5m 8 | 9 | # include test files or not, default is true 10 | tests: true 11 | 12 | # output configuration options 13 | output: 14 | # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" 15 | format: tab 16 | 17 | # all available settings of specific linters 18 | linters-settings: 19 | exhaustive: 20 | # indicates that switch statements are to be considered exhaustive if a 21 | # 'default' case is present, even if all enum members aren't listed in the 22 | # switch 23 | default-signifies-exhaustive: true 24 | govet: 25 | # report about shadowed variables 26 | check-shadowing: false 27 | 28 | linters: 29 | enable: 30 | # mandatory linters 31 | - govet 32 | - revive 33 | 34 | # some default golangci-lint linters 35 | - deadcode 36 | - errcheck 37 | - gosimple 38 | - ineffassign 39 | - staticcheck 40 | - structcheck 41 | - typecheck 42 | - unused 43 | - varcheck 44 | 45 | # extra linters 46 | - exhaustive 47 | - godot 48 | - gofmt 49 | - whitespace 50 | - goimports 51 | disable-all: true 52 | fast: false 53 | 54 | issues: 55 | include: 56 | - EXC0002 # should have a comment 57 | - EXC0003 # test/Test ... consider calling this 58 | - EXC0004 # govet 59 | - EXC0005 # C-style breaks 60 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | This document outlines major changes between releases. 4 | 5 | ## [Unreleased] 6 | 7 | ### Added 8 | - Stop pool dial on SIGINT (#76) 9 | 10 | ### Changed 11 | - Configuration parameters (#66, #71) 12 | 13 | ### Updating from v0.5.0 14 | 15 | Now all pool config parameters moved to `pool` section. So you need to change: 16 | 17 | * `peers` -> `pool.peers` (`REST_GW_PEERS` -> `REST_GW_POOL_PEERS`) 18 | * `node-dial-timeout` -> `pool.node-dial-timeout` (`REST_GW_NODE_DIAL_TIMEOUT` -> `REST_GW_POOL_NODE_DIAL_TIMEOUT`) 19 | * `healthcheck-timeout` -> `pool.healthcheck-timeout` (`REST_GW_HEALTHCHECK_TIMEOUT` -> `REST_GW_POOL_HEALTHCHECK_TIMEOUT`) 20 | * `rebalance-timer` -> `pool.rebalance-timer` (`REST_GW_REBALANCE_TIMER` -> `REST_GW_POOL_REBALANCE_TIMER`) 21 | * `pool-error-threshold` -> `pool.error-threshold` 22 | 23 | Besides all other parameters that doesn't belong any section, now in `server` section: 24 | * `listen-address` -> `server.listen-address` 25 | 26 | The same should be done for the following parameters as well: 27 | ``` 28 | scheme, cleanup-timeout, graceful-timeout, max-header-size, listen-limit, keep-alive, read-timeout, write-timeout, 29 | tls-listen-address, tls-certificate, tls-key, tls-ca, tls-listen-limit, tls-keep-alive, tls-read-timeout, tls-write-timeout 30 | ``` 31 | 32 | Environment variables should be changed appropriately. 33 | 34 | ## [0.5.0] "Undercity" - 2022-10-07 35 | 36 | ### Added 37 | - ACL sanity checks (#68, #69) 38 | - Cross platform builds (#26) 39 | 40 | ### Fixed 41 | - Fix expiration epoch calculation (#62) 42 | - Typos in Makefile (#65) 43 | - CORS for authentication (#73) 44 | 45 | ### Changed 46 | - Update go version for build to 1.19 (#61) 47 | 48 | ## [0.4.0] "Shadowglen" - 2022-08-30 49 | 50 | ### Fixed 51 | - NeoFS client metrics (#52) 52 | - Panic in go1.19 build (#53) 53 | - Add CORS Allow-Origin header (#56) 54 | 55 | ### Added 56 | - Canned ACL in container info (#38) 57 | - Native bearer token support (#32) 58 | - `Keys` target in extended ACL (#54) 59 | 60 | ### Changed 61 | - Unify application version format (#49) 62 | 63 | ## [0.3.0] "Thunder Bluff" - 2022-08-15 64 | 65 | ### Added 66 | - CORS headers (#39) 67 | - Expose metrics (#44) 68 | - Documentation for default params (#45) 69 | - Route to get NeoFS balance (#33) 70 | - New field for object search response (#40) 71 | - Building in docker (#46) 72 | 73 | ### Removed 74 | - Drop GO111MODULE from builds (#34) 75 | 76 | ## [0.2.1] "Razor Hill" - 2022-07-22 77 | 78 | ### Fixed 79 | - Fix application version (#30) 80 | 81 | ## [0.2.0] "Orgrimmar" - 2022-07-22 82 | 83 | ### Added 84 | - Support macOS build (#18) 85 | 86 | ### Changed 87 | - Update version calculating (#20) 88 | - New error response and auth request format (#15) 89 | - NeoFS SDK version update (#16) 90 | - Set container attributes in body rather than in headers (#25) 91 | 92 | ### Fixed 93 | - Fix .env variables in sample config (#22) 94 | - Fix typos and examples in spec (#24) 95 | 96 | ## Older versions 97 | 98 | Please refer to [GitHub releases](https://github.com/nspcc-dev/neofs-rest-gw/releases/) for older releases. 99 | 100 | [0.2.1]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.2.0...v0.2.1 101 | [0.2.0]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.1.0...v0.2.0 102 | [0.3.0]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.2.0...v0.3.0 103 | [0.4.0]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.3.0...v0.4.0 104 | [0.5.0]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.4.0...v0.5.0 105 | [Unreleased]: https://github.com/nspcc-dev/neofs-rest-gw/compare/v0.5.0...master 106 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.19 as basebuilder 2 | 3 | RUN set -x \ 4 | && apt-get update \ 5 | && apt-get install -y make jq 6 | 7 | FROM basebuilder as builder 8 | ENV GOGC off 9 | ENV CGO_ENABLED 0 10 | ARG VERSION=dev 11 | ARG REPO=repository 12 | 13 | WORKDIR /src 14 | COPY . /src 15 | 16 | RUN make 17 | 18 | # Executable image 19 | FROM scratch 20 | 21 | WORKDIR / 22 | 23 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ 24 | COPY --from=builder /src/bin/frostfs-rest-gw /bin/frostfs-rest-gw 25 | COPY --from=builder /src/static /static 26 | 27 | ENTRYPOINT ["/bin/frostfs-rest-gw"] 28 | -------------------------------------------------------------------------------- /Dockerfile.dirty: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | RUN apk add --update --no-cache bash ca-certificates 3 | 4 | WORKDIR / 5 | 6 | COPY bin/frostfs-rest-gw /bin/frostfs-rest-gw 7 | 8 | CMD ["frostfs-rest-gw"] 9 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | v0.5.0 2 | -------------------------------------------------------------------------------- /cmd/frostfs-rest-gw/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "os/signal" 6 | "syscall" 7 | 8 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/restapi" 9 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/restapi/operations" 10 | "github.com/go-openapi/loads" 11 | "go.uber.org/zap" 12 | ) 13 | 14 | func main() { 15 | ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) 16 | 17 | v := config() 18 | logger := newLogger(v) 19 | validateConfig(v, logger) 20 | 21 | frostfsAPI, err := newFrostfsAPI(ctx, logger, v) 22 | if err != nil { 23 | logger.Fatal("init frostfs", zap.Error(err)) 24 | } 25 | 26 | swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "") 27 | if err != nil { 28 | logger.Fatal("init spec", zap.Error(err)) 29 | } 30 | 31 | serverCfg := serverConfig(v) 32 | serverCfg.SuccessfulStartCallback = frostfsAPI.StartCallback 33 | 34 | api := operations.NewFrostfsRestGwAPI(swaggerSpec) 35 | server := restapi.NewServer(api, serverCfg) 36 | defer func() { 37 | if err = server.Shutdown(); err != nil { 38 | logger.Error("shutdown", zap.Error(err)) 39 | } 40 | }() 41 | 42 | server.ConfigureAPI(frostfsAPI.Configure) 43 | frostfsAPI.RunServices() 44 | 45 | // serve API 46 | if err = server.Serve(); err != nil { 47 | logger.Fatal("serve", zap.Error(err)) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /config/config.env: -------------------------------------------------------------------------------- 1 | # Path to wallet. 2 | REST_GW_WALLET_PATH=/path/to/wallet.json 3 | # Account address. If omitted default one will be used. 4 | REST_GW_WALLET_ADDRESS=NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP 5 | # Password to decrypt wallet. 6 | REST_GW_WALLET_PASSPHRASE=pwd 7 | 8 | # Enable metrics. 9 | REST_GW_PPROF_ENABLED=true 10 | REST_GW_PPROF_ADDRESS=localhost:8091 11 | 12 | REST_GW_PROMETHEUS_ENABLED=true 13 | REST_GW_PROMETHEUS_ADDRESS=localhost:8092 14 | 15 | # Log level. 16 | REST_GW_LOGGER_LEVEL=debug 17 | 18 | # Nodes configuration. 19 | # This configuration make gateway use the first node (grpc://s01.frostfs.devenv:8080) 20 | # while it's healthy. Otherwise, gateway use the second node (grpc://s01.frostfs.devenv:8080) 21 | # for 10% of requests and the third node for 90% of requests. 22 | # Endpoint. 23 | REST_GW_POOL_PEERS_0_ADDRESS=grpc://s01.frostfs.devenv:8080 24 | # Until nodes with the same priority level are healthy 25 | # nodes with other priority are not used. 26 | # Еhe lower the value, the higher the priority. 27 | REST_GW_POOL_PEERS_0_PRIORITY=1 28 | # Load distribution proportion for nodes with the same priority. 29 | REST_GW_POOL_PEERS_0_WEIGHT=1 30 | 31 | REST_GW_POOL_PEERS_1_ADDRESS=grpc://s02.frostfs.devenv:8080 32 | REST_GW_POOL_PEERS_1_PRIORITY=2 33 | REST_GW_POOL_PEERS_1_WEIGHT=1 34 | 35 | REST_GW_POOL_PEERS_2_ADDRESS=grpc://s03.frostfs.devenv:8080 36 | REST_GW_POOL_PEERS_2_PRIORITY=2 37 | REST_GW_POOL_PEERS_3_WEIGHT=9 38 | 39 | # Timeout to dial node. 40 | REST_GW_POOL_NODE_DIAL_TIMEOUT=10s 41 | # Timeout to check node health during rebalance. 42 | REST_GW_POOL_HEALTHCHECK_TIMEOUT=15s 43 | # Interval to check nodes health. 44 | REST_GW_POOL_REBALANCE_TIMER=60s 45 | # The number of errors on connection after which node is considered as unhealthy. 46 | REST_GW_POOL_ERROR_THRESHOLD=100 47 | 48 | # Grace period for which to wait before killing idle connections 49 | REST_GW_SERVER_CLEANUP_TIMEOUT=10s 50 | # Grace period for which to wait before shutting down the server 51 | REST_GW_SERVER_GRACEFUL_TIMEOUT=15s 52 | # Controls the maximum number of bytes the server will read parsing the request header's keys and values, 53 | # including the request line. It does not limit the size of the request body. 54 | REST_GW_SERVER_MAX_HEADER_SIZE=1000000 55 | 56 | # The IP and port to listen on. 57 | REST_GW_SERVER_LISTEN_ADDRESS=localhost:8080 58 | # Limit the number of outstanding requests. 59 | REST_GW_SERVER_LISTEN_LIMIT=0 60 | # Sets the TCP keep-alive timeouts on accepted connections. 61 | # It prunes dead TCP connections ( e.g. closing laptop mid-download). 62 | REST_GW_SERVER_KEEP_ALIVE=3m 63 | # Maximum duration before timing out read of the request. 64 | REST_GW_SERVER_READ_TIMEOUT=30s 65 | # Maximum duration before timing out write of the response. 66 | REST_GW_SERVER_WRITE_TIMEOUT=30s 67 | 68 | # The IP and port to listen on. 69 | REST_GW_SERVER_TLS_LISTEN_ADDRESS=localhost:8081 70 | # The certificate file to use for secure connections. 71 | REST_GW_SERVER_TLS_CERTIFICATE=/path/to/tls/cert 72 | # The private key file to use for secure connections (without passphrase). 73 | REST_GW_SERVER_TLS_KEY=/path/to/tls/key 74 | # The certificate authority certificate file to be used with mutual tls auth. 75 | REST_GW_SERVER_TLS_CA=/path/to/tls/ca 76 | # Limit the number of outstanding requests. 77 | REST_GW_SERVER_TLS_LISTEN_LIMIT=0 78 | # Sets the TCP keep-alive timeouts on accepted connections. 79 | # It prunes dead TCP connections ( e.g. closing laptop mid-download). 80 | REST_GW_SERVER_TLS_KEEP_ALIVE=3m 81 | # Maximum duration before timing out read of the request. 82 | REST_GW_SERVER_TLS_READ_TIMEOUT=30s 83 | # Maximum duration before timing out write of the response. 84 | REST_GW_SERVER_TLS_WRITE_TIMEOUT=30s 85 | -------------------------------------------------------------------------------- /config/config.yaml: -------------------------------------------------------------------------------- 1 | wallet: 2 | # Path to wallet. 3 | path: /path/to/wallet.json 4 | # Account address. If omitted default one will be used. 5 | address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP 6 | # Password to decrypt wallet. 7 | passphrase: pwd 8 | 9 | pprof: 10 | enabled: true # Enable pprof. 11 | address: localhost:8091 12 | prometheus: 13 | enabled: true # Enable metrics. 14 | address: localhost:8092 15 | 16 | logger: 17 | # Log level. 18 | level: debug 19 | 20 | pool: 21 | # Timeout to dial node. 22 | node-dial-timeout: 5s 23 | # Timeout to check node health during rebalance. 24 | healthcheck-timeout: 5s 25 | # Interval to check nodes' health. 26 | rebalance-timer: 30s 27 | # The number of errors on connection after which node is considered as unhealthy. 28 | error-threshold: 100 29 | 30 | # Nodes configuration. 31 | # This configuration make gateway use the first node (grpc://s01.frostfs.devenv:8080) 32 | # while it's healthy. Otherwise, gateway use the second node (grpc://s01.frostfs.devenv:8080) 33 | # for 10% of requests and the third node for 90% of requests. 34 | peers: 35 | 0: 36 | # Endpoint. 37 | address: grpc://s01.frostfs.devenv:8080 38 | # Until nodes with the same priority level are healthy 39 | # nodes with other priority are not used. 40 | # Еhe lower the value, the higher the priority. 41 | priority: 1 42 | # Load distribution proportion for nodes with the same priority. 43 | weight: 1 44 | 1: 45 | address: grpc://s02.frostfs.devenv:8080 46 | priority: 2 47 | weight: 1 48 | 2: 49 | address: grpc://s03.frostfs.devenv:8080 50 | priority: 2 51 | weight: 9 52 | 53 | server: 54 | # The listeners to enable, this can be repeated and defaults to the schemes in the swagger spec. 55 | scheme: [ http ] 56 | # Grace period for which to wait before killing idle connections 57 | cleanup-timeout: 10s 58 | # Grace period for which to wait before shutting down the server 59 | graceful-timeout: 15s 60 | # Controls the maximum number of bytes the server will read parsing the request header's keys and values, 61 | # including the request line. It does not limit the size of the request body. 62 | max-header-size: 1000000 63 | 64 | # The IP and port to listen on. 65 | listen-address: localhost:8080 66 | # Limit the number of outstanding requests. 67 | listen-limit: 0 68 | # Sets the TCP keep-alive timeouts on accepted connections. 69 | # It prunes dead TCP connections ( e.g. closing laptop mid-download). 70 | keep-alive: 3m 71 | # Maximum duration before timing out read of the request. 72 | read-timeout: 30s 73 | # Maximum duration before timing out write of the response. 74 | write-timeout: 30s 75 | 76 | # The IP and port to listen on. 77 | tls-listen-address: localhost:8081 78 | # The certificate file to use for secure connections. 79 | tls-certificate: /path/to/tls/cert 80 | # The private key file to use for secure connections (without passphrase). 81 | tls-key: /path/to/tls/key 82 | # The certificate authority certificate file to be used with mutual tls auth. 83 | tls-ca: /path/to/tls/ca 84 | # Limit the number of outstanding requests. 85 | tls-listen-limit: 0 86 | # Sets the TCP keep-alive timeouts on accepted connections. 87 | # It prunes dead TCP connections ( e.g. closing laptop mid-download). 88 | tls-keep-alive: 3m 89 | # Maximum duration before timing out read of the request. 90 | tls-read-timeout: 30s 91 | # Maximum duration before timing out write of the response. 92 | tls-write-timeout: 30s 93 | -------------------------------------------------------------------------------- /gen/models/action.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Action Rule execution result action in FrostFS EACL. Either allows or denies access if the rule's filters match. 18 | // 19 | // swagger:model Action 20 | type Action string 21 | 22 | func NewAction(value Action) *Action { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated Action. 27 | func (m Action) Pointer() *Action { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // ActionALLOW captures enum value "ALLOW" 34 | ActionALLOW Action = "ALLOW" 35 | 36 | // ActionDENY captures enum value "DENY" 37 | ActionDENY Action = "DENY" 38 | ) 39 | 40 | // for schema 41 | var actionEnum []interface{} 42 | 43 | func init() { 44 | var res []Action 45 | if err := json.Unmarshal([]byte(`["ALLOW","DENY"]`), &res); err != nil { 46 | panic(err) 47 | } 48 | for _, v := range res { 49 | actionEnum = append(actionEnum, v) 50 | } 51 | } 52 | 53 | func (m Action) validateActionEnum(path, location string, value Action) error { 54 | if err := validate.EnumCase(path, location, value, actionEnum, true); err != nil { 55 | return err 56 | } 57 | return nil 58 | } 59 | 60 | // Validate validates this action 61 | func (m Action) Validate(formats strfmt.Registry) error { 62 | var res []error 63 | 64 | // value enum 65 | if err := m.validateActionEnum("", "body", m); err != nil { 66 | return err 67 | } 68 | 69 | if len(res) > 0 { 70 | return errors.CompositeValidationError(res...) 71 | } 72 | return nil 73 | } 74 | 75 | // ContextValidate validates this action based on context it is used 76 | func (m Action) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /gen/models/address.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Address Address of the object in FrostFS. 18 | // Example: {"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"} 19 | // 20 | // swagger:model Address 21 | type Address struct { 22 | 23 | // container Id 24 | // Required: true 25 | ContainerID *string `json:"containerId"` 26 | 27 | // object Id 28 | // Required: true 29 | ObjectID *string `json:"objectId"` 30 | } 31 | 32 | // Validate validates this address 33 | func (m *Address) Validate(formats strfmt.Registry) error { 34 | var res []error 35 | 36 | if err := m.validateContainerID(formats); err != nil { 37 | res = append(res, err) 38 | } 39 | 40 | if err := m.validateObjectID(formats); err != nil { 41 | res = append(res, err) 42 | } 43 | 44 | if len(res) > 0 { 45 | return errors.CompositeValidationError(res...) 46 | } 47 | return nil 48 | } 49 | 50 | func (m *Address) validateContainerID(formats strfmt.Registry) error { 51 | 52 | if err := validate.Required("containerId", "body", m.ContainerID); err != nil { 53 | return err 54 | } 55 | 56 | return nil 57 | } 58 | 59 | func (m *Address) validateObjectID(formats strfmt.Registry) error { 60 | 61 | if err := validate.Required("objectId", "body", m.ObjectID); err != nil { 62 | return err 63 | } 64 | 65 | return nil 66 | } 67 | 68 | // ContextValidate validates this address based on context it is used 69 | func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 70 | return nil 71 | } 72 | 73 | // MarshalBinary interface implementation 74 | func (m *Address) MarshalBinary() ([]byte, error) { 75 | if m == nil { 76 | return nil, nil 77 | } 78 | return swag.WriteJSON(m) 79 | } 80 | 81 | // UnmarshalBinary interface implementation 82 | func (m *Address) UnmarshalBinary(b []byte) error { 83 | var res Address 84 | if err := swag.ReadJSON(b, &res); err != nil { 85 | return err 86 | } 87 | *m = res 88 | return nil 89 | } 90 | -------------------------------------------------------------------------------- /gen/models/attribute.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Attribute Attribute is a pair of strings that can be attached to a container or an object. 18 | // Example: {"key":"User-Defined-Tag","value":"tag value"} 19 | // 20 | // swagger:model Attribute 21 | type Attribute struct { 22 | 23 | // key 24 | // Required: true 25 | Key *string `json:"key"` 26 | 27 | // value 28 | // Required: true 29 | Value *string `json:"value"` 30 | } 31 | 32 | // Validate validates this attribute 33 | func (m *Attribute) Validate(formats strfmt.Registry) error { 34 | var res []error 35 | 36 | if err := m.validateKey(formats); err != nil { 37 | res = append(res, err) 38 | } 39 | 40 | if err := m.validateValue(formats); err != nil { 41 | res = append(res, err) 42 | } 43 | 44 | if len(res) > 0 { 45 | return errors.CompositeValidationError(res...) 46 | } 47 | return nil 48 | } 49 | 50 | func (m *Attribute) validateKey(formats strfmt.Registry) error { 51 | 52 | if err := validate.Required("key", "body", m.Key); err != nil { 53 | return err 54 | } 55 | 56 | return nil 57 | } 58 | 59 | func (m *Attribute) validateValue(formats strfmt.Registry) error { 60 | 61 | if err := validate.Required("value", "body", m.Value); err != nil { 62 | return err 63 | } 64 | 65 | return nil 66 | } 67 | 68 | // ContextValidate validates this attribute based on context it is used 69 | func (m *Attribute) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 70 | return nil 71 | } 72 | 73 | // MarshalBinary interface implementation 74 | func (m *Attribute) MarshalBinary() ([]byte, error) { 75 | if m == nil { 76 | return nil, nil 77 | } 78 | return swag.WriteJSON(m) 79 | } 80 | 81 | // UnmarshalBinary interface implementation 82 | func (m *Attribute) UnmarshalBinary(b []byte) error { 83 | var res Attribute 84 | if err := swag.ReadJSON(b, &res); err != nil { 85 | return err 86 | } 87 | *m = res 88 | return nil 89 | } 90 | -------------------------------------------------------------------------------- /gen/models/balance.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Balance balance 18 | // 19 | // swagger:model Balance 20 | type Balance struct { 21 | 22 | // address 23 | // Required: true 24 | Address *string `json:"address"` 25 | 26 | // precision 27 | // Required: true 28 | Precision *int64 `json:"precision"` 29 | 30 | // value 31 | // Required: true 32 | Value *string `json:"value"` 33 | } 34 | 35 | // Validate validates this balance 36 | func (m *Balance) Validate(formats strfmt.Registry) error { 37 | var res []error 38 | 39 | if err := m.validateAddress(formats); err != nil { 40 | res = append(res, err) 41 | } 42 | 43 | if err := m.validatePrecision(formats); err != nil { 44 | res = append(res, err) 45 | } 46 | 47 | if err := m.validateValue(formats); err != nil { 48 | res = append(res, err) 49 | } 50 | 51 | if len(res) > 0 { 52 | return errors.CompositeValidationError(res...) 53 | } 54 | return nil 55 | } 56 | 57 | func (m *Balance) validateAddress(formats strfmt.Registry) error { 58 | 59 | if err := validate.Required("address", "body", m.Address); err != nil { 60 | return err 61 | } 62 | 63 | return nil 64 | } 65 | 66 | func (m *Balance) validatePrecision(formats strfmt.Registry) error { 67 | 68 | if err := validate.Required("precision", "body", m.Precision); err != nil { 69 | return err 70 | } 71 | 72 | return nil 73 | } 74 | 75 | func (m *Balance) validateValue(formats strfmt.Registry) error { 76 | 77 | if err := validate.Required("value", "body", m.Value); err != nil { 78 | return err 79 | } 80 | 81 | return nil 82 | } 83 | 84 | // ContextValidate validates this balance based on context it is used 85 | func (m *Balance) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 86 | return nil 87 | } 88 | 89 | // MarshalBinary interface implementation 90 | func (m *Balance) MarshalBinary() ([]byte, error) { 91 | if m == nil { 92 | return nil, nil 93 | } 94 | return swag.WriteJSON(m) 95 | } 96 | 97 | // UnmarshalBinary interface implementation 98 | func (m *Balance) UnmarshalBinary(b []byte) error { 99 | var res Balance 100 | if err := swag.ReadJSON(b, &res); err != nil { 101 | return err 102 | } 103 | *m = res 104 | return nil 105 | } 106 | -------------------------------------------------------------------------------- /gen/models/binary_bearer.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // BinaryBearer Bearer token for object operations that is represented in binary form. 18 | // Example: {"token":"ChIKDAoAGggIARABIgIIAxoCCGQSZgohA+J5jFWFMiOpyvMZBu9wwPTKsWsG0q206kVe63iuWP/wEkEE4SIV0QngnKppDf54QezUKmar7UQby6HzufT5yVIOvj7QEqZnOavrKW0chCeCwP0khda/j9k00ct6NMEDxQFW+g=="} 19 | // 20 | // swagger:model BinaryBearer 21 | type BinaryBearer struct { 22 | 23 | // Base64 encoded bearer token. 24 | // Required: true 25 | Token *string `json:"token"` 26 | } 27 | 28 | // Validate validates this binary bearer 29 | func (m *BinaryBearer) Validate(formats strfmt.Registry) error { 30 | var res []error 31 | 32 | if err := m.validateToken(formats); err != nil { 33 | res = append(res, err) 34 | } 35 | 36 | if len(res) > 0 { 37 | return errors.CompositeValidationError(res...) 38 | } 39 | return nil 40 | } 41 | 42 | func (m *BinaryBearer) validateToken(formats strfmt.Registry) error { 43 | 44 | if err := validate.Required("token", "body", m.Token); err != nil { 45 | return err 46 | } 47 | 48 | return nil 49 | } 50 | 51 | // ContextValidate validates this binary bearer based on context it is used 52 | func (m *BinaryBearer) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 53 | return nil 54 | } 55 | 56 | // MarshalBinary interface implementation 57 | func (m *BinaryBearer) MarshalBinary() ([]byte, error) { 58 | if m == nil { 59 | return nil, nil 60 | } 61 | return swag.WriteJSON(m) 62 | } 63 | 64 | // UnmarshalBinary interface implementation 65 | func (m *BinaryBearer) UnmarshalBinary(b []byte) error { 66 | var res BinaryBearer 67 | if err := swag.ReadJSON(b, &res); err != nil { 68 | return err 69 | } 70 | *m = res 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /gen/models/container_put_info.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "strconv" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/swag" 15 | ) 16 | 17 | // ContainerPutInfo Request body to create container. To specify container name use appropriate property (name provided in attributes will be ignored). 18 | // Example: {"attributes":[{"key":"Custom-Attribute","value":"value"}],"basicAcl":"public-read-write","containerName":"container","placementPolicy":"REP 3"} 19 | // 20 | // swagger:model ContainerPutInfo 21 | type ContainerPutInfo struct { 22 | 23 | // attributes 24 | Attributes []*Attribute `json:"attributes"` 25 | 26 | // basic Acl 27 | BasicACL string `json:"basicAcl,omitempty"` 28 | 29 | // container name 30 | ContainerName string `json:"containerName,omitempty"` 31 | 32 | // placement policy 33 | PlacementPolicy string `json:"placementPolicy,omitempty"` 34 | } 35 | 36 | // Validate validates this container put info 37 | func (m *ContainerPutInfo) Validate(formats strfmt.Registry) error { 38 | var res []error 39 | 40 | if err := m.validateAttributes(formats); err != nil { 41 | res = append(res, err) 42 | } 43 | 44 | if len(res) > 0 { 45 | return errors.CompositeValidationError(res...) 46 | } 47 | return nil 48 | } 49 | 50 | func (m *ContainerPutInfo) validateAttributes(formats strfmt.Registry) error { 51 | if swag.IsZero(m.Attributes) { // not required 52 | return nil 53 | } 54 | 55 | for i := 0; i < len(m.Attributes); i++ { 56 | if swag.IsZero(m.Attributes[i]) { // not required 57 | continue 58 | } 59 | 60 | if m.Attributes[i] != nil { 61 | if err := m.Attributes[i].Validate(formats); err != nil { 62 | if ve, ok := err.(*errors.Validation); ok { 63 | return ve.ValidateName("attributes" + "." + strconv.Itoa(i)) 64 | } else if ce, ok := err.(*errors.CompositeError); ok { 65 | return ce.ValidateName("attributes" + "." + strconv.Itoa(i)) 66 | } 67 | return err 68 | } 69 | } 70 | 71 | } 72 | 73 | return nil 74 | } 75 | 76 | // ContextValidate validate this container put info based on the context it is used 77 | func (m *ContainerPutInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 78 | var res []error 79 | 80 | if err := m.contextValidateAttributes(ctx, formats); err != nil { 81 | res = append(res, err) 82 | } 83 | 84 | if len(res) > 0 { 85 | return errors.CompositeValidationError(res...) 86 | } 87 | return nil 88 | } 89 | 90 | func (m *ContainerPutInfo) contextValidateAttributes(ctx context.Context, formats strfmt.Registry) error { 91 | 92 | for i := 0; i < len(m.Attributes); i++ { 93 | 94 | if m.Attributes[i] != nil { 95 | if err := m.Attributes[i].ContextValidate(ctx, formats); err != nil { 96 | if ve, ok := err.(*errors.Validation); ok { 97 | return ve.ValidateName("attributes" + "." + strconv.Itoa(i)) 98 | } else if ce, ok := err.(*errors.CompositeError); ok { 99 | return ce.ValidateName("attributes" + "." + strconv.Itoa(i)) 100 | } 101 | return err 102 | } 103 | } 104 | 105 | } 106 | 107 | return nil 108 | } 109 | 110 | // MarshalBinary interface implementation 111 | func (m *ContainerPutInfo) MarshalBinary() ([]byte, error) { 112 | if m == nil { 113 | return nil, nil 114 | } 115 | return swag.WriteJSON(m) 116 | } 117 | 118 | // UnmarshalBinary interface implementation 119 | func (m *ContainerPutInfo) UnmarshalBinary(b []byte) error { 120 | var res ContainerPutInfo 121 | if err := swag.ReadJSON(b, &res); err != nil { 122 | return err 123 | } 124 | *m = res 125 | return nil 126 | } 127 | -------------------------------------------------------------------------------- /gen/models/eacl.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "strconv" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/swag" 15 | "github.com/go-openapi/validate" 16 | ) 17 | 18 | // Eacl EACL FrostFS table. 19 | // Example: {"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","records":[{"action":"GET","filters":[{"headerType":"OBJECT","key":"FileName","matchType":"STRING_EQUAL","value":"myfile"}],"operation":"ALLOW","targets":[{"role":"OTHERS"}]}]} 20 | // 21 | // swagger:model Eacl 22 | type Eacl struct { 23 | 24 | // container Id 25 | // Read Only: true 26 | ContainerID string `json:"containerId,omitempty"` 27 | 28 | // records 29 | // Required: true 30 | Records []*Record `json:"records"` 31 | } 32 | 33 | // Validate validates this eacl 34 | func (m *Eacl) Validate(formats strfmt.Registry) error { 35 | var res []error 36 | 37 | if err := m.validateRecords(formats); err != nil { 38 | res = append(res, err) 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | 47 | func (m *Eacl) validateRecords(formats strfmt.Registry) error { 48 | 49 | if err := validate.Required("records", "body", m.Records); err != nil { 50 | return err 51 | } 52 | 53 | for i := 0; i < len(m.Records); i++ { 54 | if swag.IsZero(m.Records[i]) { // not required 55 | continue 56 | } 57 | 58 | if m.Records[i] != nil { 59 | if err := m.Records[i].Validate(formats); err != nil { 60 | if ve, ok := err.(*errors.Validation); ok { 61 | return ve.ValidateName("records" + "." + strconv.Itoa(i)) 62 | } else if ce, ok := err.(*errors.CompositeError); ok { 63 | return ce.ValidateName("records" + "." + strconv.Itoa(i)) 64 | } 65 | return err 66 | } 67 | } 68 | 69 | } 70 | 71 | return nil 72 | } 73 | 74 | // ContextValidate validate this eacl based on the context it is used 75 | func (m *Eacl) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 76 | var res []error 77 | 78 | if err := m.contextValidateContainerID(ctx, formats); err != nil { 79 | res = append(res, err) 80 | } 81 | 82 | if err := m.contextValidateRecords(ctx, formats); err != nil { 83 | res = append(res, err) 84 | } 85 | 86 | if len(res) > 0 { 87 | return errors.CompositeValidationError(res...) 88 | } 89 | return nil 90 | } 91 | 92 | func (m *Eacl) contextValidateContainerID(ctx context.Context, formats strfmt.Registry) error { 93 | 94 | if err := validate.ReadOnly(ctx, "containerId", "body", string(m.ContainerID)); err != nil { 95 | return err 96 | } 97 | 98 | return nil 99 | } 100 | 101 | func (m *Eacl) contextValidateRecords(ctx context.Context, formats strfmt.Registry) error { 102 | 103 | for i := 0; i < len(m.Records); i++ { 104 | 105 | if m.Records[i] != nil { 106 | if err := m.Records[i].ContextValidate(ctx, formats); err != nil { 107 | if ve, ok := err.(*errors.Validation); ok { 108 | return ve.ValidateName("records" + "." + strconv.Itoa(i)) 109 | } else if ce, ok := err.(*errors.CompositeError); ok { 110 | return ce.ValidateName("records" + "." + strconv.Itoa(i)) 111 | } 112 | return err 113 | } 114 | } 115 | 116 | } 117 | 118 | return nil 119 | } 120 | 121 | // MarshalBinary interface implementation 122 | func (m *Eacl) MarshalBinary() ([]byte, error) { 123 | if m == nil { 124 | return nil, nil 125 | } 126 | return swag.WriteJSON(m) 127 | } 128 | 129 | // UnmarshalBinary interface implementation 130 | func (m *Eacl) UnmarshalBinary(b []byte) error { 131 | var res Eacl 132 | if err := swag.ReadJSON(b, &res); err != nil { 133 | return err 134 | } 135 | *m = res 136 | return nil 137 | } 138 | -------------------------------------------------------------------------------- /gen/models/error_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // ErrorResponse Error response. 18 | // Example: {"code":1024,"message":"incomplete object PUT by placement","type":"API"} 19 | // 20 | // swagger:model ErrorResponse 21 | type ErrorResponse struct { 22 | 23 | // code 24 | Code int64 `json:"code,omitempty"` 25 | 26 | // message 27 | // Required: true 28 | Message *string `json:"message"` 29 | 30 | // type 31 | // Required: true 32 | Type *ErrorType `json:"type"` 33 | } 34 | 35 | // Validate validates this error response 36 | func (m *ErrorResponse) Validate(formats strfmt.Registry) error { 37 | var res []error 38 | 39 | if err := m.validateMessage(formats); err != nil { 40 | res = append(res, err) 41 | } 42 | 43 | if err := m.validateType(formats); err != nil { 44 | res = append(res, err) 45 | } 46 | 47 | if len(res) > 0 { 48 | return errors.CompositeValidationError(res...) 49 | } 50 | return nil 51 | } 52 | 53 | func (m *ErrorResponse) validateMessage(formats strfmt.Registry) error { 54 | 55 | if err := validate.Required("message", "body", m.Message); err != nil { 56 | return err 57 | } 58 | 59 | return nil 60 | } 61 | 62 | func (m *ErrorResponse) validateType(formats strfmt.Registry) error { 63 | 64 | if err := validate.Required("type", "body", m.Type); err != nil { 65 | return err 66 | } 67 | 68 | if err := validate.Required("type", "body", m.Type); err != nil { 69 | return err 70 | } 71 | 72 | if m.Type != nil { 73 | if err := m.Type.Validate(formats); err != nil { 74 | if ve, ok := err.(*errors.Validation); ok { 75 | return ve.ValidateName("type") 76 | } else if ce, ok := err.(*errors.CompositeError); ok { 77 | return ce.ValidateName("type") 78 | } 79 | return err 80 | } 81 | } 82 | 83 | return nil 84 | } 85 | 86 | // ContextValidate validate this error response based on the context it is used 87 | func (m *ErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 88 | var res []error 89 | 90 | if err := m.contextValidateType(ctx, formats); err != nil { 91 | res = append(res, err) 92 | } 93 | 94 | if len(res) > 0 { 95 | return errors.CompositeValidationError(res...) 96 | } 97 | return nil 98 | } 99 | 100 | func (m *ErrorResponse) contextValidateType(ctx context.Context, formats strfmt.Registry) error { 101 | 102 | if m.Type != nil { 103 | if err := m.Type.ContextValidate(ctx, formats); err != nil { 104 | if ve, ok := err.(*errors.Validation); ok { 105 | return ve.ValidateName("type") 106 | } else if ce, ok := err.(*errors.CompositeError); ok { 107 | return ce.ValidateName("type") 108 | } 109 | return err 110 | } 111 | } 112 | 113 | return nil 114 | } 115 | 116 | // MarshalBinary interface implementation 117 | func (m *ErrorResponse) MarshalBinary() ([]byte, error) { 118 | if m == nil { 119 | return nil, nil 120 | } 121 | return swag.WriteJSON(m) 122 | } 123 | 124 | // UnmarshalBinary interface implementation 125 | func (m *ErrorResponse) UnmarshalBinary(b []byte) error { 126 | var res ErrorResponse 127 | if err := swag.ReadJSON(b, &res); err != nil { 128 | return err 129 | } 130 | *m = res 131 | return nil 132 | } 133 | -------------------------------------------------------------------------------- /gen/models/error_type.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // ErrorType Error type. Allow determine source of the error. 18 | // 19 | // swagger:model ErrorType 20 | type ErrorType string 21 | 22 | func NewErrorType(value ErrorType) *ErrorType { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated ErrorType. 27 | func (m ErrorType) Pointer() *ErrorType { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // ErrorTypeGW captures enum value "GW" 34 | ErrorTypeGW ErrorType = "GW" 35 | 36 | // ErrorTypeAPI captures enum value "API" 37 | ErrorTypeAPI ErrorType = "API" 38 | ) 39 | 40 | // for schema 41 | var errorTypeEnum []interface{} 42 | 43 | func init() { 44 | var res []ErrorType 45 | if err := json.Unmarshal([]byte(`["GW","API"]`), &res); err != nil { 46 | panic(err) 47 | } 48 | for _, v := range res { 49 | errorTypeEnum = append(errorTypeEnum, v) 50 | } 51 | } 52 | 53 | func (m ErrorType) validateErrorTypeEnum(path, location string, value ErrorType) error { 54 | if err := validate.EnumCase(path, location, value, errorTypeEnum, true); err != nil { 55 | return err 56 | } 57 | return nil 58 | } 59 | 60 | // Validate validates this error type 61 | func (m ErrorType) Validate(formats strfmt.Registry) error { 62 | var res []error 63 | 64 | // value enum 65 | if err := m.validateErrorTypeEnum("", "body", m); err != nil { 66 | return err 67 | } 68 | 69 | if len(res) > 0 { 70 | return errors.CompositeValidationError(res...) 71 | } 72 | return nil 73 | } 74 | 75 | // ContextValidate validates this error type based on context it is used 76 | func (m ErrorType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /gen/models/header_type.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // HeaderType Enumeration of possible sources of Headers to apply filters in FrostFS EACL. 18 | // 19 | // swagger:model HeaderType 20 | type HeaderType string 21 | 22 | func NewHeaderType(value HeaderType) *HeaderType { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated HeaderType. 27 | func (m HeaderType) Pointer() *HeaderType { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // HeaderTypeREQUEST captures enum value "REQUEST" 34 | HeaderTypeREQUEST HeaderType = "REQUEST" 35 | 36 | // HeaderTypeOBJECT captures enum value "OBJECT" 37 | HeaderTypeOBJECT HeaderType = "OBJECT" 38 | 39 | // HeaderTypeSERVICE captures enum value "SERVICE" 40 | HeaderTypeSERVICE HeaderType = "SERVICE" 41 | ) 42 | 43 | // for schema 44 | var headerTypeEnum []interface{} 45 | 46 | func init() { 47 | var res []HeaderType 48 | if err := json.Unmarshal([]byte(`["REQUEST","OBJECT","SERVICE"]`), &res); err != nil { 49 | panic(err) 50 | } 51 | for _, v := range res { 52 | headerTypeEnum = append(headerTypeEnum, v) 53 | } 54 | } 55 | 56 | func (m HeaderType) validateHeaderTypeEnum(path, location string, value HeaderType) error { 57 | if err := validate.EnumCase(path, location, value, headerTypeEnum, true); err != nil { 58 | return err 59 | } 60 | return nil 61 | } 62 | 63 | // Validate validates this header type 64 | func (m HeaderType) Validate(formats strfmt.Registry) error { 65 | var res []error 66 | 67 | // value enum 68 | if err := m.validateHeaderTypeEnum("", "body", m); err != nil { 69 | return err 70 | } 71 | 72 | if len(res) > 0 { 73 | return errors.CompositeValidationError(res...) 74 | } 75 | return nil 76 | } 77 | 78 | // ContextValidate validates this header type based on context it is used 79 | func (m HeaderType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /gen/models/match_type.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // MatchType Match type in FrostFS EACL filter. 18 | // 19 | // swagger:model MatchType 20 | type MatchType string 21 | 22 | func NewMatchType(value MatchType) *MatchType { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated MatchType. 27 | func (m MatchType) Pointer() *MatchType { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // MatchTypeSTRINGEQUAL captures enum value "STRING_EQUAL" 34 | MatchTypeSTRINGEQUAL MatchType = "STRING_EQUAL" 35 | 36 | // MatchTypeSTRINGNOTEQUAL captures enum value "STRING_NOT_EQUAL" 37 | MatchTypeSTRINGNOTEQUAL MatchType = "STRING_NOT_EQUAL" 38 | ) 39 | 40 | // for schema 41 | var matchTypeEnum []interface{} 42 | 43 | func init() { 44 | var res []MatchType 45 | if err := json.Unmarshal([]byte(`["STRING_EQUAL","STRING_NOT_EQUAL"]`), &res); err != nil { 46 | panic(err) 47 | } 48 | for _, v := range res { 49 | matchTypeEnum = append(matchTypeEnum, v) 50 | } 51 | } 52 | 53 | func (m MatchType) validateMatchTypeEnum(path, location string, value MatchType) error { 54 | if err := validate.EnumCase(path, location, value, matchTypeEnum, true); err != nil { 55 | return err 56 | } 57 | return nil 58 | } 59 | 60 | // Validate validates this match type 61 | func (m MatchType) Validate(formats strfmt.Registry) error { 62 | var res []error 63 | 64 | // value enum 65 | if err := m.validateMatchTypeEnum("", "body", m); err != nil { 66 | return err 67 | } 68 | 69 | if len(res) > 0 { 70 | return errors.CompositeValidationError(res...) 71 | } 72 | return nil 73 | } 74 | 75 | // ContextValidate validates this match type based on context it is used 76 | func (m MatchType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /gen/models/object_base_info.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // ObjectBaseInfo Basic object information. 18 | // Example: {"address":{"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"},"filePath":"/my/object/name.txt","name":"name.txt"} 19 | // 20 | // swagger:model ObjectBaseInfo 21 | type ObjectBaseInfo struct { 22 | 23 | // address 24 | // Required: true 25 | Address *Address `json:"address"` 26 | 27 | // file path 28 | FilePath string `json:"filePath,omitempty"` 29 | 30 | // name 31 | Name string `json:"name,omitempty"` 32 | } 33 | 34 | // Validate validates this object base info 35 | func (m *ObjectBaseInfo) Validate(formats strfmt.Registry) error { 36 | var res []error 37 | 38 | if err := m.validateAddress(formats); err != nil { 39 | res = append(res, err) 40 | } 41 | 42 | if len(res) > 0 { 43 | return errors.CompositeValidationError(res...) 44 | } 45 | return nil 46 | } 47 | 48 | func (m *ObjectBaseInfo) validateAddress(formats strfmt.Registry) error { 49 | 50 | if err := validate.Required("address", "body", m.Address); err != nil { 51 | return err 52 | } 53 | 54 | if m.Address != nil { 55 | if err := m.Address.Validate(formats); err != nil { 56 | if ve, ok := err.(*errors.Validation); ok { 57 | return ve.ValidateName("address") 58 | } else if ce, ok := err.(*errors.CompositeError); ok { 59 | return ce.ValidateName("address") 60 | } 61 | return err 62 | } 63 | } 64 | 65 | return nil 66 | } 67 | 68 | // ContextValidate validate this object base info based on the context it is used 69 | func (m *ObjectBaseInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 70 | var res []error 71 | 72 | if err := m.contextValidateAddress(ctx, formats); err != nil { 73 | res = append(res, err) 74 | } 75 | 76 | if len(res) > 0 { 77 | return errors.CompositeValidationError(res...) 78 | } 79 | return nil 80 | } 81 | 82 | func (m *ObjectBaseInfo) contextValidateAddress(ctx context.Context, formats strfmt.Registry) error { 83 | 84 | if m.Address != nil { 85 | if err := m.Address.ContextValidate(ctx, formats); err != nil { 86 | if ve, ok := err.(*errors.Validation); ok { 87 | return ve.ValidateName("address") 88 | } else if ce, ok := err.(*errors.CompositeError); ok { 89 | return ce.ValidateName("address") 90 | } 91 | return err 92 | } 93 | } 94 | 95 | return nil 96 | } 97 | 98 | // MarshalBinary interface implementation 99 | func (m *ObjectBaseInfo) MarshalBinary() ([]byte, error) { 100 | if m == nil { 101 | return nil, nil 102 | } 103 | return swag.WriteJSON(m) 104 | } 105 | 106 | // UnmarshalBinary interface implementation 107 | func (m *ObjectBaseInfo) UnmarshalBinary(b []byte) error { 108 | var res ObjectBaseInfo 109 | if err := swag.ReadJSON(b, &res); err != nil { 110 | return err 111 | } 112 | *m = res 113 | return nil 114 | } 115 | -------------------------------------------------------------------------------- /gen/models/object_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "strconv" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/swag" 15 | "github.com/go-openapi/validate" 16 | ) 17 | 18 | // ObjectList List of objects. 19 | // Example: {"objects":[{"address":{"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"},"name":"/my/object/name"},{"address":{"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"3GbmMWusaWgMHokWui2zDunxMTzButuQMVLbtL3cDn8s"},"name":"/my/object/some/other/name"}],"size":2} 20 | // 21 | // swagger:model ObjectList 22 | type ObjectList struct { 23 | 24 | // objects 25 | // Required: true 26 | Objects []*ObjectBaseInfo `json:"objects"` 27 | 28 | // size 29 | // Required: true 30 | Size *int64 `json:"size"` 31 | } 32 | 33 | // Validate validates this object list 34 | func (m *ObjectList) Validate(formats strfmt.Registry) error { 35 | var res []error 36 | 37 | if err := m.validateObjects(formats); err != nil { 38 | res = append(res, err) 39 | } 40 | 41 | if err := m.validateSize(formats); err != nil { 42 | res = append(res, err) 43 | } 44 | 45 | if len(res) > 0 { 46 | return errors.CompositeValidationError(res...) 47 | } 48 | return nil 49 | } 50 | 51 | func (m *ObjectList) validateObjects(formats strfmt.Registry) error { 52 | 53 | if err := validate.Required("objects", "body", m.Objects); err != nil { 54 | return err 55 | } 56 | 57 | for i := 0; i < len(m.Objects); i++ { 58 | if swag.IsZero(m.Objects[i]) { // not required 59 | continue 60 | } 61 | 62 | if m.Objects[i] != nil { 63 | if err := m.Objects[i].Validate(formats); err != nil { 64 | if ve, ok := err.(*errors.Validation); ok { 65 | return ve.ValidateName("objects" + "." + strconv.Itoa(i)) 66 | } else if ce, ok := err.(*errors.CompositeError); ok { 67 | return ce.ValidateName("objects" + "." + strconv.Itoa(i)) 68 | } 69 | return err 70 | } 71 | } 72 | 73 | } 74 | 75 | return nil 76 | } 77 | 78 | func (m *ObjectList) validateSize(formats strfmt.Registry) error { 79 | 80 | if err := validate.Required("size", "body", m.Size); err != nil { 81 | return err 82 | } 83 | 84 | return nil 85 | } 86 | 87 | // ContextValidate validate this object list based on the context it is used 88 | func (m *ObjectList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 89 | var res []error 90 | 91 | if err := m.contextValidateObjects(ctx, formats); err != nil { 92 | res = append(res, err) 93 | } 94 | 95 | if len(res) > 0 { 96 | return errors.CompositeValidationError(res...) 97 | } 98 | return nil 99 | } 100 | 101 | func (m *ObjectList) contextValidateObjects(ctx context.Context, formats strfmt.Registry) error { 102 | 103 | for i := 0; i < len(m.Objects); i++ { 104 | 105 | if m.Objects[i] != nil { 106 | if err := m.Objects[i].ContextValidate(ctx, formats); err != nil { 107 | if ve, ok := err.(*errors.Validation); ok { 108 | return ve.ValidateName("objects" + "." + strconv.Itoa(i)) 109 | } else if ce, ok := err.(*errors.CompositeError); ok { 110 | return ce.ValidateName("objects" + "." + strconv.Itoa(i)) 111 | } 112 | return err 113 | } 114 | } 115 | 116 | } 117 | 118 | return nil 119 | } 120 | 121 | // MarshalBinary interface implementation 122 | func (m *ObjectList) MarshalBinary() ([]byte, error) { 123 | if m == nil { 124 | return nil, nil 125 | } 126 | return swag.WriteJSON(m) 127 | } 128 | 129 | // UnmarshalBinary interface implementation 130 | func (m *ObjectList) UnmarshalBinary(b []byte) error { 131 | var res ObjectList 132 | if err := swag.ReadJSON(b, &res); err != nil { 133 | return err 134 | } 135 | *m = res 136 | return nil 137 | } 138 | -------------------------------------------------------------------------------- /gen/models/operation.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Operation Request's operation type to match in FrostFS EACL if the rule is applicable to a particular request. 18 | // 19 | // swagger:model Operation 20 | type Operation string 21 | 22 | func NewOperation(value Operation) *Operation { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated Operation. 27 | func (m Operation) Pointer() *Operation { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // OperationGET captures enum value "GET" 34 | OperationGET Operation = "GET" 35 | 36 | // OperationHEAD captures enum value "HEAD" 37 | OperationHEAD Operation = "HEAD" 38 | 39 | // OperationPUT captures enum value "PUT" 40 | OperationPUT Operation = "PUT" 41 | 42 | // OperationDELETE captures enum value "DELETE" 43 | OperationDELETE Operation = "DELETE" 44 | 45 | // OperationSEARCH captures enum value "SEARCH" 46 | OperationSEARCH Operation = "SEARCH" 47 | 48 | // OperationRANGE captures enum value "RANGE" 49 | OperationRANGE Operation = "RANGE" 50 | 51 | // OperationRANGEHASH captures enum value "RANGEHASH" 52 | OperationRANGEHASH Operation = "RANGEHASH" 53 | ) 54 | 55 | // for schema 56 | var operationEnum []interface{} 57 | 58 | func init() { 59 | var res []Operation 60 | if err := json.Unmarshal([]byte(`["GET","HEAD","PUT","DELETE","SEARCH","RANGE","RANGEHASH"]`), &res); err != nil { 61 | panic(err) 62 | } 63 | for _, v := range res { 64 | operationEnum = append(operationEnum, v) 65 | } 66 | } 67 | 68 | func (m Operation) validateOperationEnum(path, location string, value Operation) error { 69 | if err := validate.EnumCase(path, location, value, operationEnum, true); err != nil { 70 | return err 71 | } 72 | return nil 73 | } 74 | 75 | // Validate validates this operation 76 | func (m Operation) Validate(formats strfmt.Registry) error { 77 | var res []error 78 | 79 | // value enum 80 | if err := m.validateOperationEnum("", "body", m); err != nil { 81 | return err 82 | } 83 | 84 | if len(res) > 0 { 85 | return errors.CompositeValidationError(res...) 86 | } 87 | return nil 88 | } 89 | 90 | // ContextValidate validates this operation based on context it is used 91 | func (m Operation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 92 | return nil 93 | } 94 | -------------------------------------------------------------------------------- /gen/models/principal.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/strfmt" 12 | ) 13 | 14 | // Principal principal 15 | // 16 | // swagger:model Principal 17 | type Principal string 18 | 19 | // Validate validates this principal 20 | func (m Principal) Validate(formats strfmt.Registry) error { 21 | return nil 22 | } 23 | 24 | // ContextValidate validates this principal based on context it is used 25 | func (m Principal) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /gen/models/role.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Role Role for target in EACL. 18 | // 19 | // swagger:model Role 20 | type Role string 21 | 22 | func NewRole(value Role) *Role { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated Role. 27 | func (m Role) Pointer() *Role { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // RoleUSER captures enum value "USER" 34 | RoleUSER Role = "USER" 35 | 36 | // RoleSYSTEM captures enum value "SYSTEM" 37 | RoleSYSTEM Role = "SYSTEM" 38 | 39 | // RoleOTHERS captures enum value "OTHERS" 40 | RoleOTHERS Role = "OTHERS" 41 | 42 | // RoleKEYS captures enum value "KEYS" 43 | RoleKEYS Role = "KEYS" 44 | ) 45 | 46 | // for schema 47 | var roleEnum []interface{} 48 | 49 | func init() { 50 | var res []Role 51 | if err := json.Unmarshal([]byte(`["USER","SYSTEM","OTHERS","KEYS"]`), &res); err != nil { 52 | panic(err) 53 | } 54 | for _, v := range res { 55 | roleEnum = append(roleEnum, v) 56 | } 57 | } 58 | 59 | func (m Role) validateRoleEnum(path, location string, value Role) error { 60 | if err := validate.EnumCase(path, location, value, roleEnum, true); err != nil { 61 | return err 62 | } 63 | return nil 64 | } 65 | 66 | // Validate validates this role 67 | func (m Role) Validate(formats strfmt.Registry) error { 68 | var res []error 69 | 70 | // value enum 71 | if err := m.validateRoleEnum("", "body", m); err != nil { 72 | return err 73 | } 74 | 75 | if len(res) > 0 { 76 | return errors.CompositeValidationError(res...) 77 | } 78 | return nil 79 | } 80 | 81 | // ContextValidate validates this role based on context it is used 82 | func (m Role) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /gen/models/rule.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Rule Container session token rule. 18 | // Example: {"containerId":"6jvKJCQr6e47Yx8SsbSN3fNgzroUJVkY66Q9wqxYcAjc","verb":"DELETE"} 19 | // 20 | // swagger:model Rule 21 | type Rule struct { 22 | 23 | // container Id 24 | ContainerID string `json:"containerId,omitempty"` 25 | 26 | // verb 27 | // Required: true 28 | Verb *Verb `json:"verb"` 29 | } 30 | 31 | // Validate validates this rule 32 | func (m *Rule) Validate(formats strfmt.Registry) error { 33 | var res []error 34 | 35 | if err := m.validateVerb(formats); err != nil { 36 | res = append(res, err) 37 | } 38 | 39 | if len(res) > 0 { 40 | return errors.CompositeValidationError(res...) 41 | } 42 | return nil 43 | } 44 | 45 | func (m *Rule) validateVerb(formats strfmt.Registry) error { 46 | 47 | if err := validate.Required("verb", "body", m.Verb); err != nil { 48 | return err 49 | } 50 | 51 | if err := validate.Required("verb", "body", m.Verb); err != nil { 52 | return err 53 | } 54 | 55 | if m.Verb != nil { 56 | if err := m.Verb.Validate(formats); err != nil { 57 | if ve, ok := err.(*errors.Validation); ok { 58 | return ve.ValidateName("verb") 59 | } else if ce, ok := err.(*errors.CompositeError); ok { 60 | return ce.ValidateName("verb") 61 | } 62 | return err 63 | } 64 | } 65 | 66 | return nil 67 | } 68 | 69 | // ContextValidate validate this rule based on the context it is used 70 | func (m *Rule) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 71 | var res []error 72 | 73 | if err := m.contextValidateVerb(ctx, formats); err != nil { 74 | res = append(res, err) 75 | } 76 | 77 | if len(res) > 0 { 78 | return errors.CompositeValidationError(res...) 79 | } 80 | return nil 81 | } 82 | 83 | func (m *Rule) contextValidateVerb(ctx context.Context, formats strfmt.Registry) error { 84 | 85 | if m.Verb != nil { 86 | if err := m.Verb.ContextValidate(ctx, formats); err != nil { 87 | if ve, ok := err.(*errors.Validation); ok { 88 | return ve.ValidateName("verb") 89 | } else if ce, ok := err.(*errors.CompositeError); ok { 90 | return ce.ValidateName("verb") 91 | } 92 | return err 93 | } 94 | } 95 | 96 | return nil 97 | } 98 | 99 | // MarshalBinary interface implementation 100 | func (m *Rule) MarshalBinary() ([]byte, error) { 101 | if m == nil { 102 | return nil, nil 103 | } 104 | return swag.WriteJSON(m) 105 | } 106 | 107 | // UnmarshalBinary interface implementation 108 | func (m *Rule) UnmarshalBinary(b []byte) error { 109 | var res Rule 110 | if err := swag.ReadJSON(b, &res); err != nil { 111 | return err 112 | } 113 | *m = res 114 | return nil 115 | } 116 | -------------------------------------------------------------------------------- /gen/models/search_filter.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // SearchFilter Search filter to find objects. 18 | // Example: {"key":"FileName","match":"MatchStringEqual","value":"object-name"} 19 | // 20 | // swagger:model SearchFilter 21 | type SearchFilter struct { 22 | 23 | // key 24 | // Required: true 25 | Key *string `json:"key"` 26 | 27 | // match 28 | // Required: true 29 | Match *SearchMatch `json:"match"` 30 | 31 | // value 32 | // Required: true 33 | Value *string `json:"value"` 34 | } 35 | 36 | // Validate validates this search filter 37 | func (m *SearchFilter) Validate(formats strfmt.Registry) error { 38 | var res []error 39 | 40 | if err := m.validateKey(formats); err != nil { 41 | res = append(res, err) 42 | } 43 | 44 | if err := m.validateMatch(formats); err != nil { 45 | res = append(res, err) 46 | } 47 | 48 | if err := m.validateValue(formats); err != nil { 49 | res = append(res, err) 50 | } 51 | 52 | if len(res) > 0 { 53 | return errors.CompositeValidationError(res...) 54 | } 55 | return nil 56 | } 57 | 58 | func (m *SearchFilter) validateKey(formats strfmt.Registry) error { 59 | 60 | if err := validate.Required("key", "body", m.Key); err != nil { 61 | return err 62 | } 63 | 64 | return nil 65 | } 66 | 67 | func (m *SearchFilter) validateMatch(formats strfmt.Registry) error { 68 | 69 | if err := validate.Required("match", "body", m.Match); err != nil { 70 | return err 71 | } 72 | 73 | if err := validate.Required("match", "body", m.Match); err != nil { 74 | return err 75 | } 76 | 77 | if m.Match != nil { 78 | if err := m.Match.Validate(formats); err != nil { 79 | if ve, ok := err.(*errors.Validation); ok { 80 | return ve.ValidateName("match") 81 | } else if ce, ok := err.(*errors.CompositeError); ok { 82 | return ce.ValidateName("match") 83 | } 84 | return err 85 | } 86 | } 87 | 88 | return nil 89 | } 90 | 91 | func (m *SearchFilter) validateValue(formats strfmt.Registry) error { 92 | 93 | if err := validate.Required("value", "body", m.Value); err != nil { 94 | return err 95 | } 96 | 97 | return nil 98 | } 99 | 100 | // ContextValidate validate this search filter based on the context it is used 101 | func (m *SearchFilter) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 102 | var res []error 103 | 104 | if err := m.contextValidateMatch(ctx, formats); err != nil { 105 | res = append(res, err) 106 | } 107 | 108 | if len(res) > 0 { 109 | return errors.CompositeValidationError(res...) 110 | } 111 | return nil 112 | } 113 | 114 | func (m *SearchFilter) contextValidateMatch(ctx context.Context, formats strfmt.Registry) error { 115 | 116 | if m.Match != nil { 117 | if err := m.Match.ContextValidate(ctx, formats); err != nil { 118 | if ve, ok := err.(*errors.Validation); ok { 119 | return ve.ValidateName("match") 120 | } else if ce, ok := err.(*errors.CompositeError); ok { 121 | return ce.ValidateName("match") 122 | } 123 | return err 124 | } 125 | } 126 | 127 | return nil 128 | } 129 | 130 | // MarshalBinary interface implementation 131 | func (m *SearchFilter) MarshalBinary() ([]byte, error) { 132 | if m == nil { 133 | return nil, nil 134 | } 135 | return swag.WriteJSON(m) 136 | } 137 | 138 | // UnmarshalBinary interface implementation 139 | func (m *SearchFilter) UnmarshalBinary(b []byte) error { 140 | var res SearchFilter 141 | if err := swag.ReadJSON(b, &res); err != nil { 142 | return err 143 | } 144 | *m = res 145 | return nil 146 | } 147 | -------------------------------------------------------------------------------- /gen/models/search_filters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "strconv" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/swag" 15 | "github.com/go-openapi/validate" 16 | ) 17 | 18 | // SearchFilters List of SearchFilter elements. 19 | // Example: {"filters":[{"key":"FileName","match":"MatchCommonPrefix","value":"some/prefix"},{"key":"CustomAttribute","match":"MatchStringEqual","value":"tag-value"}]} 20 | // 21 | // swagger:model SearchFilters 22 | type SearchFilters struct { 23 | 24 | // filters 25 | // Required: true 26 | Filters []*SearchFilter `json:"filters"` 27 | } 28 | 29 | // Validate validates this search filters 30 | func (m *SearchFilters) Validate(formats strfmt.Registry) error { 31 | var res []error 32 | 33 | if err := m.validateFilters(formats); err != nil { 34 | res = append(res, err) 35 | } 36 | 37 | if len(res) > 0 { 38 | return errors.CompositeValidationError(res...) 39 | } 40 | return nil 41 | } 42 | 43 | func (m *SearchFilters) validateFilters(formats strfmt.Registry) error { 44 | 45 | if err := validate.Required("filters", "body", m.Filters); err != nil { 46 | return err 47 | } 48 | 49 | for i := 0; i < len(m.Filters); i++ { 50 | if swag.IsZero(m.Filters[i]) { // not required 51 | continue 52 | } 53 | 54 | if m.Filters[i] != nil { 55 | if err := m.Filters[i].Validate(formats); err != nil { 56 | if ve, ok := err.(*errors.Validation); ok { 57 | return ve.ValidateName("filters" + "." + strconv.Itoa(i)) 58 | } else if ce, ok := err.(*errors.CompositeError); ok { 59 | return ce.ValidateName("filters" + "." + strconv.Itoa(i)) 60 | } 61 | return err 62 | } 63 | } 64 | 65 | } 66 | 67 | return nil 68 | } 69 | 70 | // ContextValidate validate this search filters based on the context it is used 71 | func (m *SearchFilters) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 72 | var res []error 73 | 74 | if err := m.contextValidateFilters(ctx, formats); err != nil { 75 | res = append(res, err) 76 | } 77 | 78 | if len(res) > 0 { 79 | return errors.CompositeValidationError(res...) 80 | } 81 | return nil 82 | } 83 | 84 | func (m *SearchFilters) contextValidateFilters(ctx context.Context, formats strfmt.Registry) error { 85 | 86 | for i := 0; i < len(m.Filters); i++ { 87 | 88 | if m.Filters[i] != nil { 89 | if err := m.Filters[i].ContextValidate(ctx, formats); err != nil { 90 | if ve, ok := err.(*errors.Validation); ok { 91 | return ve.ValidateName("filters" + "." + strconv.Itoa(i)) 92 | } else if ce, ok := err.(*errors.CompositeError); ok { 93 | return ce.ValidateName("filters" + "." + strconv.Itoa(i)) 94 | } 95 | return err 96 | } 97 | } 98 | 99 | } 100 | 101 | return nil 102 | } 103 | 104 | // MarshalBinary interface implementation 105 | func (m *SearchFilters) MarshalBinary() ([]byte, error) { 106 | if m == nil { 107 | return nil, nil 108 | } 109 | return swag.WriteJSON(m) 110 | } 111 | 112 | // UnmarshalBinary interface implementation 113 | func (m *SearchFilters) UnmarshalBinary(b []byte) error { 114 | var res SearchFilters 115 | if err := swag.ReadJSON(b, &res); err != nil { 116 | return err 117 | } 118 | *m = res 119 | return nil 120 | } 121 | -------------------------------------------------------------------------------- /gen/models/search_match.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // SearchMatch Search match type. 18 | // 19 | // swagger:model SearchMatch 20 | type SearchMatch string 21 | 22 | func NewSearchMatch(value SearchMatch) *SearchMatch { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated SearchMatch. 27 | func (m SearchMatch) Pointer() *SearchMatch { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // SearchMatchMatchStringEqual captures enum value "MatchStringEqual" 34 | SearchMatchMatchStringEqual SearchMatch = "MatchStringEqual" 35 | 36 | // SearchMatchMatchStringNotEqual captures enum value "MatchStringNotEqual" 37 | SearchMatchMatchStringNotEqual SearchMatch = "MatchStringNotEqual" 38 | 39 | // SearchMatchMatchNotPresent captures enum value "MatchNotPresent" 40 | SearchMatchMatchNotPresent SearchMatch = "MatchNotPresent" 41 | 42 | // SearchMatchMatchCommonPrefix captures enum value "MatchCommonPrefix" 43 | SearchMatchMatchCommonPrefix SearchMatch = "MatchCommonPrefix" 44 | ) 45 | 46 | // for schema 47 | var searchMatchEnum []interface{} 48 | 49 | func init() { 50 | var res []SearchMatch 51 | if err := json.Unmarshal([]byte(`["MatchStringEqual","MatchStringNotEqual","MatchNotPresent","MatchCommonPrefix"]`), &res); err != nil { 52 | panic(err) 53 | } 54 | for _, v := range res { 55 | searchMatchEnum = append(searchMatchEnum, v) 56 | } 57 | } 58 | 59 | func (m SearchMatch) validateSearchMatchEnum(path, location string, value SearchMatch) error { 60 | if err := validate.EnumCase(path, location, value, searchMatchEnum, true); err != nil { 61 | return err 62 | } 63 | return nil 64 | } 65 | 66 | // Validate validates this search match 67 | func (m SearchMatch) Validate(formats strfmt.Registry) error { 68 | var res []error 69 | 70 | // value enum 71 | if err := m.validateSearchMatchEnum("", "body", m); err != nil { 72 | return err 73 | } 74 | 75 | if len(res) > 0 { 76 | return errors.CompositeValidationError(res...) 77 | } 78 | return nil 79 | } 80 | 81 | // ContextValidate validates this search match based on context it is used 82 | func (m SearchMatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /gen/models/success_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // SuccessResponse Success response. 18 | // Example: {"success":true} 19 | // 20 | // swagger:model SuccessResponse 21 | type SuccessResponse struct { 22 | 23 | // success 24 | // Required: true 25 | Success *bool `json:"success"` 26 | } 27 | 28 | // Validate validates this success response 29 | func (m *SuccessResponse) Validate(formats strfmt.Registry) error { 30 | var res []error 31 | 32 | if err := m.validateSuccess(formats); err != nil { 33 | res = append(res, err) 34 | } 35 | 36 | if len(res) > 0 { 37 | return errors.CompositeValidationError(res...) 38 | } 39 | return nil 40 | } 41 | 42 | func (m *SuccessResponse) validateSuccess(formats strfmt.Registry) error { 43 | 44 | if err := validate.Required("success", "body", m.Success); err != nil { 45 | return err 46 | } 47 | 48 | return nil 49 | } 50 | 51 | // ContextValidate validates this success response based on context it is used 52 | func (m *SuccessResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 53 | return nil 54 | } 55 | 56 | // MarshalBinary interface implementation 57 | func (m *SuccessResponse) MarshalBinary() ([]byte, error) { 58 | if m == nil { 59 | return nil, nil 60 | } 61 | return swag.WriteJSON(m) 62 | } 63 | 64 | // UnmarshalBinary interface implementation 65 | func (m *SuccessResponse) UnmarshalBinary(b []byte) error { 66 | var res SuccessResponse 67 | if err := swag.ReadJSON(b, &res); err != nil { 68 | return err 69 | } 70 | *m = res 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /gen/models/target.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Target Target to apply the ACL rule. Can be a subject's role class or a list of public keys to match (KEYS role). 18 | // Example: {"keys":["021dc56fc6d81d581ae7605a8e00e0e0bab6cbad566a924a527339475a97a8e38e"],"role":"KEYS"} 19 | // 20 | // swagger:model Target 21 | type Target struct { 22 | 23 | // keys 24 | // Required: true 25 | Keys []string `json:"keys"` 26 | 27 | // role 28 | // Required: true 29 | Role *Role `json:"role"` 30 | } 31 | 32 | // Validate validates this target 33 | func (m *Target) Validate(formats strfmt.Registry) error { 34 | var res []error 35 | 36 | if err := m.validateKeys(formats); err != nil { 37 | res = append(res, err) 38 | } 39 | 40 | if err := m.validateRole(formats); err != nil { 41 | res = append(res, err) 42 | } 43 | 44 | if len(res) > 0 { 45 | return errors.CompositeValidationError(res...) 46 | } 47 | return nil 48 | } 49 | 50 | func (m *Target) validateKeys(formats strfmt.Registry) error { 51 | 52 | if err := validate.Required("keys", "body", m.Keys); err != nil { 53 | return err 54 | } 55 | 56 | return nil 57 | } 58 | 59 | func (m *Target) validateRole(formats strfmt.Registry) error { 60 | 61 | if err := validate.Required("role", "body", m.Role); err != nil { 62 | return err 63 | } 64 | 65 | if err := validate.Required("role", "body", m.Role); err != nil { 66 | return err 67 | } 68 | 69 | if m.Role != nil { 70 | if err := m.Role.Validate(formats); err != nil { 71 | if ve, ok := err.(*errors.Validation); ok { 72 | return ve.ValidateName("role") 73 | } else if ce, ok := err.(*errors.CompositeError); ok { 74 | return ce.ValidateName("role") 75 | } 76 | return err 77 | } 78 | } 79 | 80 | return nil 81 | } 82 | 83 | // ContextValidate validate this target based on the context it is used 84 | func (m *Target) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 85 | var res []error 86 | 87 | if err := m.contextValidateRole(ctx, formats); err != nil { 88 | res = append(res, err) 89 | } 90 | 91 | if len(res) > 0 { 92 | return errors.CompositeValidationError(res...) 93 | } 94 | return nil 95 | } 96 | 97 | func (m *Target) contextValidateRole(ctx context.Context, formats strfmt.Registry) error { 98 | 99 | if m.Role != nil { 100 | if err := m.Role.ContextValidate(ctx, formats); err != nil { 101 | if ve, ok := err.(*errors.Validation); ok { 102 | return ve.ValidateName("role") 103 | } else if ce, ok := err.(*errors.CompositeError); ok { 104 | return ce.ValidateName("role") 105 | } 106 | return err 107 | } 108 | } 109 | 110 | return nil 111 | } 112 | 113 | // MarshalBinary interface implementation 114 | func (m *Target) MarshalBinary() ([]byte, error) { 115 | if m == nil { 116 | return nil, nil 117 | } 118 | return swag.WriteJSON(m) 119 | } 120 | 121 | // UnmarshalBinary interface implementation 122 | func (m *Target) UnmarshalBinary(b []byte) error { 123 | var res Target 124 | if err := swag.ReadJSON(b, &res); err != nil { 125 | return err 126 | } 127 | *m = res 128 | return nil 129 | } 130 | -------------------------------------------------------------------------------- /gen/models/token_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // TokenResponse Base64 encoded marshaled token (for container or for object operations). 18 | // Example: [{"token":"ClYKBAgCEA0aCAgDEAEiAggDGggIARACIgIIAxoICAIQAiICCAMaCAgDEAIiAggDGggIBBACIgIIAxoICAUQAiICCAMaCAgGEAIiAggDGggIBxACIgIIAxIbChk182WEDFuAqq3nssrGOaH0NK0ZhzF8bu+YGgQIaBgE","type":"object"},{"token":"ChCpanIBJCpJuJz42KOmGMSnEhsKGTWquaX2Lq6GhhO4faOYkLD0f9WkXuYJlq4aBAhnGAMiIQJgFcIEghQB5lq3AJZOVswInwc1IGhlQ7NCUh4DFO3UATIECAEQAQ==","type":"container"}] 19 | // 20 | // swagger:model TokenResponse 21 | type TokenResponse struct { 22 | 23 | // name 24 | Name string `json:"name,omitempty"` 25 | 26 | // token 27 | // Required: true 28 | Token *string `json:"token"` 29 | 30 | // type 31 | // Required: true 32 | Type *TokenType `json:"type"` 33 | } 34 | 35 | // Validate validates this token response 36 | func (m *TokenResponse) Validate(formats strfmt.Registry) error { 37 | var res []error 38 | 39 | if err := m.validateToken(formats); err != nil { 40 | res = append(res, err) 41 | } 42 | 43 | if err := m.validateType(formats); err != nil { 44 | res = append(res, err) 45 | } 46 | 47 | if len(res) > 0 { 48 | return errors.CompositeValidationError(res...) 49 | } 50 | return nil 51 | } 52 | 53 | func (m *TokenResponse) validateToken(formats strfmt.Registry) error { 54 | 55 | if err := validate.Required("token", "body", m.Token); err != nil { 56 | return err 57 | } 58 | 59 | return nil 60 | } 61 | 62 | func (m *TokenResponse) validateType(formats strfmt.Registry) error { 63 | 64 | if err := validate.Required("type", "body", m.Type); err != nil { 65 | return err 66 | } 67 | 68 | if err := validate.Required("type", "body", m.Type); err != nil { 69 | return err 70 | } 71 | 72 | if m.Type != nil { 73 | if err := m.Type.Validate(formats); err != nil { 74 | if ve, ok := err.(*errors.Validation); ok { 75 | return ve.ValidateName("type") 76 | } else if ce, ok := err.(*errors.CompositeError); ok { 77 | return ce.ValidateName("type") 78 | } 79 | return err 80 | } 81 | } 82 | 83 | return nil 84 | } 85 | 86 | // ContextValidate validate this token response based on the context it is used 87 | func (m *TokenResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 88 | var res []error 89 | 90 | if err := m.contextValidateType(ctx, formats); err != nil { 91 | res = append(res, err) 92 | } 93 | 94 | if len(res) > 0 { 95 | return errors.CompositeValidationError(res...) 96 | } 97 | return nil 98 | } 99 | 100 | func (m *TokenResponse) contextValidateType(ctx context.Context, formats strfmt.Registry) error { 101 | 102 | if m.Type != nil { 103 | if err := m.Type.ContextValidate(ctx, formats); err != nil { 104 | if ve, ok := err.(*errors.Validation); ok { 105 | return ve.ValidateName("type") 106 | } else if ce, ok := err.(*errors.CompositeError); ok { 107 | return ce.ValidateName("type") 108 | } 109 | return err 110 | } 111 | } 112 | 113 | return nil 114 | } 115 | 116 | // MarshalBinary interface implementation 117 | func (m *TokenResponse) MarshalBinary() ([]byte, error) { 118 | if m == nil { 119 | return nil, nil 120 | } 121 | return swag.WriteJSON(m) 122 | } 123 | 124 | // UnmarshalBinary interface implementation 125 | func (m *TokenResponse) UnmarshalBinary(b []byte) error { 126 | var res TokenResponse 127 | if err := swag.ReadJSON(b, &res); err != nil { 128 | return err 129 | } 130 | *m = res 131 | return nil 132 | } 133 | -------------------------------------------------------------------------------- /gen/models/token_type.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // TokenType Type of token. 18 | // 19 | // swagger:model TokenType 20 | type TokenType string 21 | 22 | func NewTokenType(value TokenType) *TokenType { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated TokenType. 27 | func (m TokenType) Pointer() *TokenType { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // TokenTypeObject captures enum value "object" 34 | TokenTypeObject TokenType = "object" 35 | 36 | // TokenTypeContainer captures enum value "container" 37 | TokenTypeContainer TokenType = "container" 38 | ) 39 | 40 | // for schema 41 | var tokenTypeEnum []interface{} 42 | 43 | func init() { 44 | var res []TokenType 45 | if err := json.Unmarshal([]byte(`["object","container"]`), &res); err != nil { 46 | panic(err) 47 | } 48 | for _, v := range res { 49 | tokenTypeEnum = append(tokenTypeEnum, v) 50 | } 51 | } 52 | 53 | func (m TokenType) validateTokenTypeEnum(path, location string, value TokenType) error { 54 | if err := validate.EnumCase(path, location, value, tokenTypeEnum, true); err != nil { 55 | return err 56 | } 57 | return nil 58 | } 59 | 60 | // Validate validates this token type 61 | func (m TokenType) Validate(formats strfmt.Registry) error { 62 | var res []error 63 | 64 | // value enum 65 | if err := m.validateTokenTypeEnum("", "body", m); err != nil { 66 | return err 67 | } 68 | 69 | if len(res) > 0 { 70 | return errors.CompositeValidationError(res...) 71 | } 72 | return nil 73 | } 74 | 75 | // ContextValidate validates this token type based on context it is used 76 | func (m TokenType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /gen/models/verb.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "context" 10 | "encoding/json" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/strfmt" 14 | "github.com/go-openapi/validate" 15 | ) 16 | 17 | // Verb Verb that describes the allowed container operation for token. 18 | // 19 | // swagger:model Verb 20 | type Verb string 21 | 22 | func NewVerb(value Verb) *Verb { 23 | return &value 24 | } 25 | 26 | // Pointer returns a pointer to a freshly-allocated Verb. 27 | func (m Verb) Pointer() *Verb { 28 | return &m 29 | } 30 | 31 | const ( 32 | 33 | // VerbPUT captures enum value "PUT" 34 | VerbPUT Verb = "PUT" 35 | 36 | // VerbDELETE captures enum value "DELETE" 37 | VerbDELETE Verb = "DELETE" 38 | 39 | // VerbSETEACL captures enum value "SETEACL" 40 | VerbSETEACL Verb = "SETEACL" 41 | ) 42 | 43 | // for schema 44 | var verbEnum []interface{} 45 | 46 | func init() { 47 | var res []Verb 48 | if err := json.Unmarshal([]byte(`["PUT","DELETE","SETEACL"]`), &res); err != nil { 49 | panic(err) 50 | } 51 | for _, v := range res { 52 | verbEnum = append(verbEnum, v) 53 | } 54 | } 55 | 56 | func (m Verb) validateVerbEnum(path, location string, value Verb) error { 57 | if err := validate.EnumCase(path, location, value, verbEnum, true); err != nil { 58 | return err 59 | } 60 | return nil 61 | } 62 | 63 | // Validate validates this verb 64 | func (m Verb) Validate(formats strfmt.Registry) error { 65 | var res []error 66 | 67 | // value enum 68 | if err := m.validateVerbEnum("", "body", m); err != nil { 69 | return err 70 | } 71 | 72 | if len(res) > 0 { 73 | return errors.CompositeValidationError(res...) 74 | } 75 | return nil 76 | } 77 | 78 | // ContextValidate validates this verb based on context it is used 79 | func (m Verb) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /gen/restapi/doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | // Package restapi REST API FrostFS 4 | // 5 | // REST API for native integration with FrostFS. 6 | // Schemes: 7 | // http 8 | // Host: localhost:8090 9 | // BasePath: /v1 10 | // Version: v1 11 | // 12 | // Consumes: 13 | // - application/json 14 | // 15 | // Produces: 16 | // - application/json 17 | // 18 | // swagger:meta 19 | package restapi 20 | -------------------------------------------------------------------------------- /gen/restapi/operations/auth.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // AuthHandlerFunc turns a function with the right signature into a auth handler 15 | type AuthHandlerFunc func(AuthParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn AuthHandlerFunc) Handle(params AuthParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // AuthHandler interface for that can handle valid auth params 23 | type AuthHandler interface { 24 | Handle(AuthParams) middleware.Responder 25 | } 26 | 27 | // NewAuth creates a new http.Handler for the auth operation 28 | func NewAuth(ctx *middleware.Context, handler AuthHandler) *Auth { 29 | return &Auth{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* Auth swagger:route POST /auth auth 33 | 34 | Form bearer token to further requests 35 | 36 | */ 37 | type Auth struct { 38 | Context *middleware.Context 39 | Handler AuthHandler 40 | } 41 | 42 | func (o *Auth) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewAuthParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/auth_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // AuthOKCode is the HTTP code returned for type AuthOK 17 | const AuthOKCode int = 200 18 | 19 | /*AuthOK Base64 encoded stable binary marshaled bearer token bodies. 20 | 21 | swagger:response authOK 22 | */ 23 | type AuthOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload []*models.TokenResponse `json:"body,omitempty"` 33 | } 34 | 35 | // NewAuthOK creates AuthOK with default headers values 36 | func NewAuthOK() *AuthOK { 37 | 38 | return &AuthOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the auth o k response 42 | func (o *AuthOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *AuthOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the auth o k response 48 | func (o *AuthOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the auth o k response 53 | func (o *AuthOK) WithPayload(payload []*models.TokenResponse) *AuthOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the auth o k response 59 | func (o *AuthOK) SetPayload(payload []*models.TokenResponse) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *AuthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | payload := o.Payload 75 | if payload == nil { 76 | // return empty array 77 | payload = make([]*models.TokenResponse, 0, 50) 78 | } 79 | 80 | if err := producer.Produce(rw, payload); err != nil { 81 | panic(err) // let the recovery middleware deal with this 82 | } 83 | } 84 | 85 | // AuthBadRequestCode is the HTTP code returned for type AuthBadRequest 86 | const AuthBadRequestCode int = 400 87 | 88 | /*AuthBadRequest Bad request 89 | 90 | swagger:response authBadRequest 91 | */ 92 | type AuthBadRequest struct { 93 | 94 | /* 95 | In: Body 96 | */ 97 | Payload *models.ErrorResponse `json:"body,omitempty"` 98 | } 99 | 100 | // NewAuthBadRequest creates AuthBadRequest with default headers values 101 | func NewAuthBadRequest() *AuthBadRequest { 102 | 103 | return &AuthBadRequest{} 104 | } 105 | 106 | // WithPayload adds the payload to the auth bad request response 107 | func (o *AuthBadRequest) WithPayload(payload *models.ErrorResponse) *AuthBadRequest { 108 | o.Payload = payload 109 | return o 110 | } 111 | 112 | // SetPayload sets the payload to the auth bad request response 113 | func (o *AuthBadRequest) SetPayload(payload *models.ErrorResponse) { 114 | o.Payload = payload 115 | } 116 | 117 | // WriteResponse to the client 118 | func (o *AuthBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 119 | 120 | rw.WriteHeader(400) 121 | if o.Payload != nil { 122 | payload := o.Payload 123 | if err := producer.Produce(rw, payload); err != nil { 124 | panic(err) // let the recovery middleware deal with this 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /gen/restapi/operations/delete_container.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // DeleteContainerHandlerFunc turns a function with the right signature into a delete container handler 17 | type DeleteContainerHandlerFunc func(DeleteContainerParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn DeleteContainerHandlerFunc) Handle(params DeleteContainerParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // DeleteContainerHandler interface for that can handle valid delete container params 25 | type DeleteContainerHandler interface { 26 | Handle(DeleteContainerParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewDeleteContainer creates a new http.Handler for the delete container operation 30 | func NewDeleteContainer(ctx *middleware.Context, handler DeleteContainerHandler) *DeleteContainer { 31 | return &DeleteContainer{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* DeleteContainer swagger:route DELETE /containers/{containerId} deleteContainer 35 | 36 | Delete container by id 37 | 38 | */ 39 | type DeleteContainer struct { 40 | Context *middleware.Context 41 | Handler DeleteContainerHandler 42 | } 43 | 44 | func (o *DeleteContainer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewDeleteContainerParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/delete_object.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // DeleteObjectHandlerFunc turns a function with the right signature into a delete object handler 17 | type DeleteObjectHandlerFunc func(DeleteObjectParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn DeleteObjectHandlerFunc) Handle(params DeleteObjectParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // DeleteObjectHandler interface for that can handle valid delete object params 25 | type DeleteObjectHandler interface { 26 | Handle(DeleteObjectParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewDeleteObject creates a new http.Handler for the delete object operation 30 | func NewDeleteObject(ctx *middleware.Context, handler DeleteObjectHandler) *DeleteObject { 31 | return &DeleteObject{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* DeleteObject swagger:route DELETE /objects/{containerId}/{objectId} deleteObject 35 | 36 | Remove object from FrostFS 37 | 38 | */ 39 | type DeleteObject struct { 40 | Context *middleware.Context 41 | Handler DeleteObjectHandler 42 | } 43 | 44 | func (o *DeleteObject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewDeleteObjectParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/delete_object_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // DeleteObjectOKCode is the HTTP code returned for type DeleteObjectOK 17 | const DeleteObjectOKCode int = 200 18 | 19 | /*DeleteObjectOK Successful deletion. 20 | 21 | swagger:response deleteObjectOK 22 | */ 23 | type DeleteObjectOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload *models.SuccessResponse `json:"body,omitempty"` 33 | } 34 | 35 | // NewDeleteObjectOK creates DeleteObjectOK with default headers values 36 | func NewDeleteObjectOK() *DeleteObjectOK { 37 | 38 | return &DeleteObjectOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the delete object o k response 42 | func (o *DeleteObjectOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *DeleteObjectOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the delete object o k response 48 | func (o *DeleteObjectOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the delete object o k response 53 | func (o *DeleteObjectOK) WithPayload(payload *models.SuccessResponse) *DeleteObjectOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the delete object o k response 59 | func (o *DeleteObjectOK) SetPayload(payload *models.SuccessResponse) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *DeleteObjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | if o.Payload != nil { 75 | payload := o.Payload 76 | if err := producer.Produce(rw, payload); err != nil { 77 | panic(err) // let the recovery middleware deal with this 78 | } 79 | } 80 | } 81 | 82 | // DeleteObjectBadRequestCode is the HTTP code returned for type DeleteObjectBadRequest 83 | const DeleteObjectBadRequestCode int = 400 84 | 85 | /*DeleteObjectBadRequest Bad request. 86 | 87 | swagger:response deleteObjectBadRequest 88 | */ 89 | type DeleteObjectBadRequest struct { 90 | 91 | /* 92 | In: Body 93 | */ 94 | Payload *models.ErrorResponse `json:"body,omitempty"` 95 | } 96 | 97 | // NewDeleteObjectBadRequest creates DeleteObjectBadRequest with default headers values 98 | func NewDeleteObjectBadRequest() *DeleteObjectBadRequest { 99 | 100 | return &DeleteObjectBadRequest{} 101 | } 102 | 103 | // WithPayload adds the payload to the delete object bad request response 104 | func (o *DeleteObjectBadRequest) WithPayload(payload *models.ErrorResponse) *DeleteObjectBadRequest { 105 | o.Payload = payload 106 | return o 107 | } 108 | 109 | // SetPayload sets the payload to the delete object bad request response 110 | func (o *DeleteObjectBadRequest) SetPayload(payload *models.ErrorResponse) { 111 | o.Payload = payload 112 | } 113 | 114 | // WriteResponse to the client 115 | func (o *DeleteObjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 116 | 117 | rw.WriteHeader(400) 118 | if o.Payload != nil { 119 | payload := o.Payload 120 | if err := producer.Produce(rw, payload); err != nil { 121 | panic(err) // let the recovery middleware deal with this 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /gen/restapi/operations/form_binary_bearer.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // FormBinaryBearerHandlerFunc turns a function with the right signature into a form binary bearer handler 17 | type FormBinaryBearerHandlerFunc func(FormBinaryBearerParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn FormBinaryBearerHandlerFunc) Handle(params FormBinaryBearerParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // FormBinaryBearerHandler interface for that can handle valid form binary bearer params 25 | type FormBinaryBearerHandler interface { 26 | Handle(FormBinaryBearerParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewFormBinaryBearer creates a new http.Handler for the form binary bearer operation 30 | func NewFormBinaryBearer(ctx *middleware.Context, handler FormBinaryBearerHandler) *FormBinaryBearer { 31 | return &FormBinaryBearer{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* FormBinaryBearer swagger:route GET /auth/bearer formBinaryBearer 35 | 36 | Form binary bearer token 37 | 38 | */ 39 | type FormBinaryBearer struct { 40 | Context *middleware.Context 41 | Handler FormBinaryBearerHandler 42 | } 43 | 44 | func (o *FormBinaryBearer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewFormBinaryBearerParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_balance.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetBalanceHandlerFunc turns a function with the right signature into a get balance handler 15 | type GetBalanceHandlerFunc func(GetBalanceParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetBalanceHandlerFunc) Handle(params GetBalanceParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetBalanceHandler interface for that can handle valid get balance params 23 | type GetBalanceHandler interface { 24 | Handle(GetBalanceParams) middleware.Responder 25 | } 26 | 27 | // NewGetBalance creates a new http.Handler for the get balance operation 28 | func NewGetBalance(ctx *middleware.Context, handler GetBalanceHandler) *GetBalance { 29 | return &GetBalance{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* GetBalance swagger:route GET /accounting/balance/{address} getBalance 33 | 34 | Get balance in FrostFS 35 | 36 | Getting balance of provided wallet address in FrostFS. 37 | 38 | */ 39 | type GetBalance struct { 40 | Context *middleware.Context 41 | Handler GetBalanceHandler 42 | } 43 | 44 | func (o *GetBalance) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewGetBalanceParams() 50 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 51 | o.Context.Respond(rw, r, route.Produces, route, err) 52 | return 53 | } 54 | 55 | res := o.Handler.Handle(Params) // actually handle the request 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_balance_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewGetBalanceParams creates a new GetBalanceParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewGetBalanceParams() GetBalanceParams { 20 | 21 | return GetBalanceParams{} 22 | } 23 | 24 | // GetBalanceParams contains all the bound params for the get balance operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters getBalance 28 | type GetBalanceParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded wallet address. 34 | Required: true 35 | In: path 36 | */ 37 | Address string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewGetBalanceParams() beforehand. 44 | func (o *GetBalanceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rAddress, rhkAddress, _ := route.Params.GetOK("address") 50 | if err := o.bindAddress(rAddress, rhkAddress, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindAddress binds and validates parameter Address from path. 60 | func (o *GetBalanceParams) bindAddress(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.Address = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_balance_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // GetBalanceOKCode is the HTTP code returned for type GetBalanceOK 17 | const GetBalanceOKCode int = 200 18 | 19 | /*GetBalanceOK Balance of address in FrostFS 20 | 21 | swagger:response getBalanceOK 22 | */ 23 | type GetBalanceOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload *models.Balance `json:"body,omitempty"` 33 | } 34 | 35 | // NewGetBalanceOK creates GetBalanceOK with default headers values 36 | func NewGetBalanceOK() *GetBalanceOK { 37 | 38 | return &GetBalanceOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the get balance o k response 42 | func (o *GetBalanceOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *GetBalanceOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the get balance o k response 48 | func (o *GetBalanceOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the get balance o k response 53 | func (o *GetBalanceOK) WithPayload(payload *models.Balance) *GetBalanceOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the get balance o k response 59 | func (o *GetBalanceOK) SetPayload(payload *models.Balance) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *GetBalanceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | if o.Payload != nil { 75 | payload := o.Payload 76 | if err := producer.Produce(rw, payload); err != nil { 77 | panic(err) // let the recovery middleware deal with this 78 | } 79 | } 80 | } 81 | 82 | // GetBalanceBadRequestCode is the HTTP code returned for type GetBalanceBadRequest 83 | const GetBalanceBadRequestCode int = 400 84 | 85 | /*GetBalanceBadRequest Bad request 86 | 87 | swagger:response getBalanceBadRequest 88 | */ 89 | type GetBalanceBadRequest struct { 90 | 91 | /* 92 | In: Body 93 | */ 94 | Payload *models.ErrorResponse `json:"body,omitempty"` 95 | } 96 | 97 | // NewGetBalanceBadRequest creates GetBalanceBadRequest with default headers values 98 | func NewGetBalanceBadRequest() *GetBalanceBadRequest { 99 | 100 | return &GetBalanceBadRequest{} 101 | } 102 | 103 | // WithPayload adds the payload to the get balance bad request response 104 | func (o *GetBalanceBadRequest) WithPayload(payload *models.ErrorResponse) *GetBalanceBadRequest { 105 | o.Payload = payload 106 | return o 107 | } 108 | 109 | // SetPayload sets the payload to the get balance bad request response 110 | func (o *GetBalanceBadRequest) SetPayload(payload *models.ErrorResponse) { 111 | o.Payload = payload 112 | } 113 | 114 | // WriteResponse to the client 115 | func (o *GetBalanceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 116 | 117 | rw.WriteHeader(400) 118 | if o.Payload != nil { 119 | payload := o.Payload 120 | if err := producer.Produce(rw, payload); err != nil { 121 | panic(err) // let the recovery middleware deal with this 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_container.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetContainerHandlerFunc turns a function with the right signature into a get container handler 15 | type GetContainerHandlerFunc func(GetContainerParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetContainerHandlerFunc) Handle(params GetContainerParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetContainerHandler interface for that can handle valid get container params 23 | type GetContainerHandler interface { 24 | Handle(GetContainerParams) middleware.Responder 25 | } 26 | 27 | // NewGetContainer creates a new http.Handler for the get container operation 28 | func NewGetContainer(ctx *middleware.Context, handler GetContainerHandler) *GetContainer { 29 | return &GetContainer{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* GetContainer swagger:route GET /containers/{containerId} getContainer 33 | 34 | Get container by id 35 | 36 | */ 37 | type GetContainer struct { 38 | Context *middleware.Context 39 | Handler GetContainerHandler 40 | } 41 | 42 | func (o *GetContainer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewGetContainerParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_container_e_acl.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetContainerEACLHandlerFunc turns a function with the right signature into a get container e ACL handler 15 | type GetContainerEACLHandlerFunc func(GetContainerEACLParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetContainerEACLHandlerFunc) Handle(params GetContainerEACLParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetContainerEACLHandler interface for that can handle valid get container e ACL params 23 | type GetContainerEACLHandler interface { 24 | Handle(GetContainerEACLParams) middleware.Responder 25 | } 26 | 27 | // NewGetContainerEACL creates a new http.Handler for the get container e ACL operation 28 | func NewGetContainerEACL(ctx *middleware.Context, handler GetContainerEACLHandler) *GetContainerEACL { 29 | return &GetContainerEACL{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* GetContainerEACL swagger:route GET /containers/{containerId}/eacl getContainerEAcl 33 | 34 | Get container EACL by id 35 | 36 | */ 37 | type GetContainerEACL struct { 38 | Context *middleware.Context 39 | Handler GetContainerEACLHandler 40 | } 41 | 42 | func (o *GetContainerEACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewGetContainerEACLParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_container_e_acl_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewGetContainerEACLParams creates a new GetContainerEACLParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewGetContainerEACLParams() GetContainerEACLParams { 20 | 21 | return GetContainerEACLParams{} 22 | } 23 | 24 | // GetContainerEACLParams contains all the bound params for the get container e ACL operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters getContainerEACL 28 | type GetContainerEACLParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewGetContainerEACLParams() beforehand. 44 | func (o *GetContainerEACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 50 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindContainerID binds and validates parameter ContainerID from path. 60 | func (o *GetContainerEACLParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.ContainerID = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_container_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewGetContainerParams creates a new GetContainerParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewGetContainerParams() GetContainerParams { 20 | 21 | return GetContainerParams{} 22 | } 23 | 24 | // GetContainerParams contains all the bound params for the get container operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters getContainer 28 | type GetContainerParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewGetContainerParams() beforehand. 44 | func (o *GetContainerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 50 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindContainerID binds and validates parameter ContainerID from path. 60 | func (o *GetContainerParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.ContainerID = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_container_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // GetContainerOKCode is the HTTP code returned for type GetContainerOK 17 | const GetContainerOKCode int = 200 18 | 19 | /*GetContainerOK Container info. 20 | 21 | swagger:response getContainerOK 22 | */ 23 | type GetContainerOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload *models.ContainerInfo `json:"body,omitempty"` 33 | } 34 | 35 | // NewGetContainerOK creates GetContainerOK with default headers values 36 | func NewGetContainerOK() *GetContainerOK { 37 | 38 | return &GetContainerOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the get container o k response 42 | func (o *GetContainerOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *GetContainerOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the get container o k response 48 | func (o *GetContainerOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the get container o k response 53 | func (o *GetContainerOK) WithPayload(payload *models.ContainerInfo) *GetContainerOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the get container o k response 59 | func (o *GetContainerOK) SetPayload(payload *models.ContainerInfo) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *GetContainerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | if o.Payload != nil { 75 | payload := o.Payload 76 | if err := producer.Produce(rw, payload); err != nil { 77 | panic(err) // let the recovery middleware deal with this 78 | } 79 | } 80 | } 81 | 82 | // GetContainerBadRequestCode is the HTTP code returned for type GetContainerBadRequest 83 | const GetContainerBadRequestCode int = 400 84 | 85 | /*GetContainerBadRequest Bad request. 86 | 87 | swagger:response getContainerBadRequest 88 | */ 89 | type GetContainerBadRequest struct { 90 | 91 | /* 92 | In: Body 93 | */ 94 | Payload *models.ErrorResponse `json:"body,omitempty"` 95 | } 96 | 97 | // NewGetContainerBadRequest creates GetContainerBadRequest with default headers values 98 | func NewGetContainerBadRequest() *GetContainerBadRequest { 99 | 100 | return &GetContainerBadRequest{} 101 | } 102 | 103 | // WithPayload adds the payload to the get container bad request response 104 | func (o *GetContainerBadRequest) WithPayload(payload *models.ErrorResponse) *GetContainerBadRequest { 105 | o.Payload = payload 106 | return o 107 | } 108 | 109 | // SetPayload sets the payload to the get container bad request response 110 | func (o *GetContainerBadRequest) SetPayload(payload *models.ErrorResponse) { 111 | o.Payload = payload 112 | } 113 | 114 | // WriteResponse to the client 115 | func (o *GetContainerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 116 | 117 | rw.WriteHeader(400) 118 | if o.Payload != nil { 119 | payload := o.Payload 120 | if err := producer.Produce(rw, payload); err != nil { 121 | panic(err) // let the recovery middleware deal with this 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /gen/restapi/operations/get_object_info.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // GetObjectInfoHandlerFunc turns a function with the right signature into a get object info handler 17 | type GetObjectInfoHandlerFunc func(GetObjectInfoParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn GetObjectInfoHandlerFunc) Handle(params GetObjectInfoParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // GetObjectInfoHandler interface for that can handle valid get object info params 25 | type GetObjectInfoHandler interface { 26 | Handle(GetObjectInfoParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewGetObjectInfo creates a new http.Handler for the get object info operation 30 | func NewGetObjectInfo(ctx *middleware.Context, handler GetObjectInfoHandler) *GetObjectInfo { 31 | return &GetObjectInfo{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* GetObjectInfo swagger:route GET /objects/{containerId}/{objectId} getObjectInfo 35 | 36 | Get object info by address 37 | 38 | */ 39 | type GetObjectInfo struct { 40 | Context *middleware.Context 41 | Handler GetObjectInfoHandler 42 | } 43 | 44 | func (o *GetObjectInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewGetObjectInfoParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/list_containers.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // ListContainersHandlerFunc turns a function with the right signature into a list containers handler 15 | type ListContainersHandlerFunc func(ListContainersParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn ListContainersHandlerFunc) Handle(params ListContainersParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // ListContainersHandler interface for that can handle valid list containers params 23 | type ListContainersHandler interface { 24 | Handle(ListContainersParams) middleware.Responder 25 | } 26 | 27 | // NewListContainers creates a new http.Handler for the list containers operation 28 | func NewListContainers(ctx *middleware.Context, handler ListContainersHandler) *ListContainers { 29 | return &ListContainers{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* ListContainers swagger:route GET /containers listContainers 33 | 34 | Get list of containers 35 | 36 | */ 37 | type ListContainers struct { 38 | Context *middleware.Context 39 | Handler ListContainersHandler 40 | } 41 | 42 | func (o *ListContainers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewListContainersParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsAuthHandlerFunc turns a function with the right signature into a options auth handler 15 | type OptionsAuthHandlerFunc func(OptionsAuthParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsAuthHandlerFunc) Handle(params OptionsAuthParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsAuthHandler interface for that can handle valid options auth params 23 | type OptionsAuthHandler interface { 24 | Handle(OptionsAuthParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsAuth creates a new http.Handler for the options auth operation 28 | func NewOptionsAuth(ctx *middleware.Context, handler OptionsAuthHandler) *OptionsAuth { 29 | return &OptionsAuth{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsAuth swagger:route OPTIONS /auth optionsAuth 33 | 34 | OptionsAuth options auth API 35 | 36 | */ 37 | type OptionsAuth struct { 38 | Context *middleware.Context 39 | Handler OptionsAuthHandler 40 | } 41 | 42 | func (o *OptionsAuth) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsAuthParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth_bearer.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsAuthBearerHandlerFunc turns a function with the right signature into a options auth bearer handler 15 | type OptionsAuthBearerHandlerFunc func(OptionsAuthBearerParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsAuthBearerHandlerFunc) Handle(params OptionsAuthBearerParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsAuthBearerHandler interface for that can handle valid options auth bearer params 23 | type OptionsAuthBearerHandler interface { 24 | Handle(OptionsAuthBearerParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsAuthBearer creates a new http.Handler for the options auth bearer operation 28 | func NewOptionsAuthBearer(ctx *middleware.Context, handler OptionsAuthBearerHandler) *OptionsAuthBearer { 29 | return &OptionsAuthBearer{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsAuthBearer swagger:route OPTIONS /auth/bearer optionsAuthBearer 33 | 34 | OptionsAuthBearer options auth bearer API 35 | 36 | */ 37 | type OptionsAuthBearer struct { 38 | Context *middleware.Context 39 | Handler OptionsAuthBearerHandler 40 | } 41 | 42 | func (o *OptionsAuthBearer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsAuthBearerParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth_bearer_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | ) 14 | 15 | // NewOptionsAuthBearerParams creates a new OptionsAuthBearerParams object 16 | // 17 | // There are no default values defined in the spec. 18 | func NewOptionsAuthBearerParams() OptionsAuthBearerParams { 19 | 20 | return OptionsAuthBearerParams{} 21 | } 22 | 23 | // OptionsAuthBearerParams contains all the bound params for the options auth bearer operation 24 | // typically these are obtained from a http.Request 25 | // 26 | // swagger:parameters optionsAuthBearer 27 | type OptionsAuthBearerParams struct { 28 | 29 | // HTTP Request Object 30 | HTTPRequest *http.Request `json:"-"` 31 | } 32 | 33 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 34 | // for simple values it will use straight method calls. 35 | // 36 | // To ensure default values, the struct must have been initialized with NewOptionsAuthBearerParams() beforehand. 37 | func (o *OptionsAuthBearerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 38 | var res []error 39 | 40 | o.HTTPRequest = r 41 | 42 | if len(res) > 0 { 43 | return errors.CompositeValidationError(res...) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth_bearer_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // OptionsAuthBearerOKCode is the HTTP code returned for type OptionsAuthBearerOK 15 | const OptionsAuthBearerOKCode int = 200 16 | 17 | /*OptionsAuthBearerOK CORS 18 | 19 | swagger:response optionsAuthBearerOK 20 | */ 21 | type OptionsAuthBearerOK struct { 22 | /* 23 | 24 | */ 25 | AccessControlAllowHeaders string `json:"Access-Control-Allow-Headers"` 26 | /* 27 | 28 | */ 29 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 30 | } 31 | 32 | // NewOptionsAuthBearerOK creates OptionsAuthBearerOK with default headers values 33 | func NewOptionsAuthBearerOK() *OptionsAuthBearerOK { 34 | 35 | return &OptionsAuthBearerOK{} 36 | } 37 | 38 | // WithAccessControlAllowHeaders adds the accessControlAllowHeaders to the options auth bearer o k response 39 | func (o *OptionsAuthBearerOK) WithAccessControlAllowHeaders(accessControlAllowHeaders string) *OptionsAuthBearerOK { 40 | o.AccessControlAllowHeaders = accessControlAllowHeaders 41 | return o 42 | } 43 | 44 | // SetAccessControlAllowHeaders sets the accessControlAllowHeaders to the options auth bearer o k response 45 | func (o *OptionsAuthBearerOK) SetAccessControlAllowHeaders(accessControlAllowHeaders string) { 46 | o.AccessControlAllowHeaders = accessControlAllowHeaders 47 | } 48 | 49 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the options auth bearer o k response 50 | func (o *OptionsAuthBearerOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *OptionsAuthBearerOK { 51 | o.AccessControlAllowOrigin = accessControlAllowOrigin 52 | return o 53 | } 54 | 55 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the options auth bearer o k response 56 | func (o *OptionsAuthBearerOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 57 | o.AccessControlAllowOrigin = accessControlAllowOrigin 58 | } 59 | 60 | // WriteResponse to the client 61 | func (o *OptionsAuthBearerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 62 | 63 | // response header Access-Control-Allow-Headers 64 | 65 | accessControlAllowHeaders := o.AccessControlAllowHeaders 66 | if accessControlAllowHeaders != "" { 67 | rw.Header().Set("Access-Control-Allow-Headers", accessControlAllowHeaders) 68 | } 69 | 70 | // response header Access-Control-Allow-Origin 71 | 72 | accessControlAllowOrigin := o.AccessControlAllowOrigin 73 | if accessControlAllowOrigin != "" { 74 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 75 | } 76 | 77 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 78 | 79 | rw.WriteHeader(200) 80 | } 81 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | ) 14 | 15 | // NewOptionsAuthParams creates a new OptionsAuthParams object 16 | // 17 | // There are no default values defined in the spec. 18 | func NewOptionsAuthParams() OptionsAuthParams { 19 | 20 | return OptionsAuthParams{} 21 | } 22 | 23 | // OptionsAuthParams contains all the bound params for the options auth operation 24 | // typically these are obtained from a http.Request 25 | // 26 | // swagger:parameters optionsAuth 27 | type OptionsAuthParams struct { 28 | 29 | // HTTP Request Object 30 | HTTPRequest *http.Request `json:"-"` 31 | } 32 | 33 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 34 | // for simple values it will use straight method calls. 35 | // 36 | // To ensure default values, the struct must have been initialized with NewOptionsAuthParams() beforehand. 37 | func (o *OptionsAuthParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 38 | var res []error 39 | 40 | o.HTTPRequest = r 41 | 42 | if len(res) > 0 { 43 | return errors.CompositeValidationError(res...) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_auth_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // OptionsAuthOKCode is the HTTP code returned for type OptionsAuthOK 15 | const OptionsAuthOKCode int = 200 16 | 17 | /*OptionsAuthOK CORS 18 | 19 | swagger:response optionsAuthOK 20 | */ 21 | type OptionsAuthOK struct { 22 | /* 23 | 24 | */ 25 | AccessControlAllowHeaders string `json:"Access-Control-Allow-Headers"` 26 | /* 27 | 28 | */ 29 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 30 | } 31 | 32 | // NewOptionsAuthOK creates OptionsAuthOK with default headers values 33 | func NewOptionsAuthOK() *OptionsAuthOK { 34 | 35 | return &OptionsAuthOK{} 36 | } 37 | 38 | // WithAccessControlAllowHeaders adds the accessControlAllowHeaders to the options auth o k response 39 | func (o *OptionsAuthOK) WithAccessControlAllowHeaders(accessControlAllowHeaders string) *OptionsAuthOK { 40 | o.AccessControlAllowHeaders = accessControlAllowHeaders 41 | return o 42 | } 43 | 44 | // SetAccessControlAllowHeaders sets the accessControlAllowHeaders to the options auth o k response 45 | func (o *OptionsAuthOK) SetAccessControlAllowHeaders(accessControlAllowHeaders string) { 46 | o.AccessControlAllowHeaders = accessControlAllowHeaders 47 | } 48 | 49 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the options auth o k response 50 | func (o *OptionsAuthOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *OptionsAuthOK { 51 | o.AccessControlAllowOrigin = accessControlAllowOrigin 52 | return o 53 | } 54 | 55 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the options auth o k response 56 | func (o *OptionsAuthOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 57 | o.AccessControlAllowOrigin = accessControlAllowOrigin 58 | } 59 | 60 | // WriteResponse to the client 61 | func (o *OptionsAuthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 62 | 63 | // response header Access-Control-Allow-Headers 64 | 65 | accessControlAllowHeaders := o.AccessControlAllowHeaders 66 | if accessControlAllowHeaders != "" { 67 | rw.Header().Set("Access-Control-Allow-Headers", accessControlAllowHeaders) 68 | } 69 | 70 | // response header Access-Control-Allow-Origin 71 | 72 | accessControlAllowOrigin := o.AccessControlAllowOrigin 73 | if accessControlAllowOrigin != "" { 74 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 75 | } 76 | 77 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 78 | 79 | rw.WriteHeader(200) 80 | } 81 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_e_acl.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsContainersEACLHandlerFunc turns a function with the right signature into a options containers e ACL handler 15 | type OptionsContainersEACLHandlerFunc func(OptionsContainersEACLParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsContainersEACLHandlerFunc) Handle(params OptionsContainersEACLParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsContainersEACLHandler interface for that can handle valid options containers e ACL params 23 | type OptionsContainersEACLHandler interface { 24 | Handle(OptionsContainersEACLParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsContainersEACL creates a new http.Handler for the options containers e ACL operation 28 | func NewOptionsContainersEACL(ctx *middleware.Context, handler OptionsContainersEACLHandler) *OptionsContainersEACL { 29 | return &OptionsContainersEACL{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsContainersEACL swagger:route OPTIONS /containers/{containerId}/eacl optionsContainersEAcl 33 | 34 | OptionsContainersEACL options containers e ACL API 35 | 36 | */ 37 | type OptionsContainersEACL struct { 38 | Context *middleware.Context 39 | Handler OptionsContainersEACLHandler 40 | } 41 | 42 | func (o *OptionsContainersEACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsContainersEACLParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_e_acl_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewOptionsContainersEACLParams creates a new OptionsContainersEACLParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewOptionsContainersEACLParams() OptionsContainersEACLParams { 20 | 21 | return OptionsContainersEACLParams{} 22 | } 23 | 24 | // OptionsContainersEACLParams contains all the bound params for the options containers e ACL operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters optionsContainersEACL 28 | type OptionsContainersEACLParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewOptionsContainersEACLParams() beforehand. 44 | func (o *OptionsContainersEACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 50 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindContainerID binds and validates parameter ContainerID from path. 60 | func (o *OptionsContainersEACLParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.ContainerID = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_e_acl_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // OptionsContainersEACLOKCode is the HTTP code returned for type OptionsContainersEACLOK 15 | const OptionsContainersEACLOKCode int = 200 16 | 17 | /*OptionsContainersEACLOK CORS 18 | 19 | swagger:response optionsContainersEAclOK 20 | */ 21 | type OptionsContainersEACLOK struct { 22 | /* 23 | 24 | */ 25 | AccessControlAllowHeaders string `json:"Access-Control-Allow-Headers"` 26 | /* 27 | 28 | */ 29 | AccessControlAllowMethods string `json:"Access-Control-Allow-Methods"` 30 | /* 31 | 32 | */ 33 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 34 | } 35 | 36 | // NewOptionsContainersEACLOK creates OptionsContainersEACLOK with default headers values 37 | func NewOptionsContainersEACLOK() *OptionsContainersEACLOK { 38 | 39 | return &OptionsContainersEACLOK{} 40 | } 41 | 42 | // WithAccessControlAllowHeaders adds the accessControlAllowHeaders to the options containers e Acl o k response 43 | func (o *OptionsContainersEACLOK) WithAccessControlAllowHeaders(accessControlAllowHeaders string) *OptionsContainersEACLOK { 44 | o.AccessControlAllowHeaders = accessControlAllowHeaders 45 | return o 46 | } 47 | 48 | // SetAccessControlAllowHeaders sets the accessControlAllowHeaders to the options containers e Acl o k response 49 | func (o *OptionsContainersEACLOK) SetAccessControlAllowHeaders(accessControlAllowHeaders string) { 50 | o.AccessControlAllowHeaders = accessControlAllowHeaders 51 | } 52 | 53 | // WithAccessControlAllowMethods adds the accessControlAllowMethods to the options containers e Acl o k response 54 | func (o *OptionsContainersEACLOK) WithAccessControlAllowMethods(accessControlAllowMethods string) *OptionsContainersEACLOK { 55 | o.AccessControlAllowMethods = accessControlAllowMethods 56 | return o 57 | } 58 | 59 | // SetAccessControlAllowMethods sets the accessControlAllowMethods to the options containers e Acl o k response 60 | func (o *OptionsContainersEACLOK) SetAccessControlAllowMethods(accessControlAllowMethods string) { 61 | o.AccessControlAllowMethods = accessControlAllowMethods 62 | } 63 | 64 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the options containers e Acl o k response 65 | func (o *OptionsContainersEACLOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *OptionsContainersEACLOK { 66 | o.AccessControlAllowOrigin = accessControlAllowOrigin 67 | return o 68 | } 69 | 70 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the options containers e Acl o k response 71 | func (o *OptionsContainersEACLOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 72 | o.AccessControlAllowOrigin = accessControlAllowOrigin 73 | } 74 | 75 | // WriteResponse to the client 76 | func (o *OptionsContainersEACLOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 77 | 78 | // response header Access-Control-Allow-Headers 79 | 80 | accessControlAllowHeaders := o.AccessControlAllowHeaders 81 | if accessControlAllowHeaders != "" { 82 | rw.Header().Set("Access-Control-Allow-Headers", accessControlAllowHeaders) 83 | } 84 | 85 | // response header Access-Control-Allow-Methods 86 | 87 | accessControlAllowMethods := o.AccessControlAllowMethods 88 | if accessControlAllowMethods != "" { 89 | rw.Header().Set("Access-Control-Allow-Methods", accessControlAllowMethods) 90 | } 91 | 92 | // response header Access-Control-Allow-Origin 93 | 94 | accessControlAllowOrigin := o.AccessControlAllowOrigin 95 | if accessControlAllowOrigin != "" { 96 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 97 | } 98 | 99 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 100 | 101 | rw.WriteHeader(200) 102 | } 103 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_get_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsContainersGetDeleteHandlerFunc turns a function with the right signature into a options containers get delete handler 15 | type OptionsContainersGetDeleteHandlerFunc func(OptionsContainersGetDeleteParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsContainersGetDeleteHandlerFunc) Handle(params OptionsContainersGetDeleteParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsContainersGetDeleteHandler interface for that can handle valid options containers get delete params 23 | type OptionsContainersGetDeleteHandler interface { 24 | Handle(OptionsContainersGetDeleteParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsContainersGetDelete creates a new http.Handler for the options containers get delete operation 28 | func NewOptionsContainersGetDelete(ctx *middleware.Context, handler OptionsContainersGetDeleteHandler) *OptionsContainersGetDelete { 29 | return &OptionsContainersGetDelete{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsContainersGetDelete swagger:route OPTIONS /containers/{containerId} optionsContainersGetDelete 33 | 34 | OptionsContainersGetDelete options containers get delete API 35 | 36 | */ 37 | type OptionsContainersGetDelete struct { 38 | Context *middleware.Context 39 | Handler OptionsContainersGetDeleteHandler 40 | } 41 | 42 | func (o *OptionsContainersGetDelete) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsContainersGetDeleteParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_get_delete_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewOptionsContainersGetDeleteParams creates a new OptionsContainersGetDeleteParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewOptionsContainersGetDeleteParams() OptionsContainersGetDeleteParams { 20 | 21 | return OptionsContainersGetDeleteParams{} 22 | } 23 | 24 | // OptionsContainersGetDeleteParams contains all the bound params for the options containers get delete operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters optionsContainersGetDelete 28 | type OptionsContainersGetDeleteParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewOptionsContainersGetDeleteParams() beforehand. 44 | func (o *OptionsContainersGetDeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 50 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindContainerID binds and validates parameter ContainerID from path. 60 | func (o *OptionsContainersGetDeleteParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.ContainerID = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_put_list.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsContainersPutListHandlerFunc turns a function with the right signature into a options containers put list handler 15 | type OptionsContainersPutListHandlerFunc func(OptionsContainersPutListParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsContainersPutListHandlerFunc) Handle(params OptionsContainersPutListParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsContainersPutListHandler interface for that can handle valid options containers put list params 23 | type OptionsContainersPutListHandler interface { 24 | Handle(OptionsContainersPutListParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsContainersPutList creates a new http.Handler for the options containers put list operation 28 | func NewOptionsContainersPutList(ctx *middleware.Context, handler OptionsContainersPutListHandler) *OptionsContainersPutList { 29 | return &OptionsContainersPutList{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsContainersPutList swagger:route OPTIONS /containers optionsContainersPutList 33 | 34 | OptionsContainersPutList options containers put list API 35 | 36 | */ 37 | type OptionsContainersPutList struct { 38 | Context *middleware.Context 39 | Handler OptionsContainersPutListHandler 40 | } 41 | 42 | func (o *OptionsContainersPutList) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsContainersPutListParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_containers_put_list_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | ) 14 | 15 | // NewOptionsContainersPutListParams creates a new OptionsContainersPutListParams object 16 | // 17 | // There are no default values defined in the spec. 18 | func NewOptionsContainersPutListParams() OptionsContainersPutListParams { 19 | 20 | return OptionsContainersPutListParams{} 21 | } 22 | 23 | // OptionsContainersPutListParams contains all the bound params for the options containers put list operation 24 | // typically these are obtained from a http.Request 25 | // 26 | // swagger:parameters optionsContainersPutList 27 | type OptionsContainersPutListParams struct { 28 | 29 | // HTTP Request Object 30 | HTTPRequest *http.Request `json:"-"` 31 | } 32 | 33 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 34 | // for simple values it will use straight method calls. 35 | // 36 | // To ensure default values, the struct must have been initialized with NewOptionsContainersPutListParams() beforehand. 37 | func (o *OptionsContainersPutListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 38 | var res []error 39 | 40 | o.HTTPRequest = r 41 | 42 | if len(res) > 0 { 43 | return errors.CompositeValidationError(res...) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_get_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsObjectsGetDeleteHandlerFunc turns a function with the right signature into a options objects get delete handler 15 | type OptionsObjectsGetDeleteHandlerFunc func(OptionsObjectsGetDeleteParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsObjectsGetDeleteHandlerFunc) Handle(params OptionsObjectsGetDeleteParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsObjectsGetDeleteHandler interface for that can handle valid options objects get delete params 23 | type OptionsObjectsGetDeleteHandler interface { 24 | Handle(OptionsObjectsGetDeleteParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsObjectsGetDelete creates a new http.Handler for the options objects get delete operation 28 | func NewOptionsObjectsGetDelete(ctx *middleware.Context, handler OptionsObjectsGetDeleteHandler) *OptionsObjectsGetDelete { 29 | return &OptionsObjectsGetDelete{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsObjectsGetDelete swagger:route OPTIONS /objects/{containerId}/{objectId} optionsObjectsGetDelete 33 | 34 | OptionsObjectsGetDelete options objects get delete API 35 | 36 | */ 37 | type OptionsObjectsGetDelete struct { 38 | Context *middleware.Context 39 | Handler OptionsObjectsGetDeleteHandler 40 | } 41 | 42 | func (o *OptionsObjectsGetDelete) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsObjectsGetDeleteParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_get_delete_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewOptionsObjectsGetDeleteParams creates a new OptionsObjectsGetDeleteParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewOptionsObjectsGetDeleteParams() OptionsObjectsGetDeleteParams { 20 | 21 | return OptionsObjectsGetDeleteParams{} 22 | } 23 | 24 | // OptionsObjectsGetDeleteParams contains all the bound params for the options objects get delete operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters optionsObjectsGetDelete 28 | type OptionsObjectsGetDeleteParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | /*Base58 encoded object id. 39 | Required: true 40 | In: path 41 | */ 42 | ObjectID string 43 | } 44 | 45 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 46 | // for simple values it will use straight method calls. 47 | // 48 | // To ensure default values, the struct must have been initialized with NewOptionsObjectsGetDeleteParams() beforehand. 49 | func (o *OptionsObjectsGetDeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 50 | var res []error 51 | 52 | o.HTTPRequest = r 53 | 54 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 55 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 56 | res = append(res, err) 57 | } 58 | 59 | rObjectID, rhkObjectID, _ := route.Params.GetOK("objectId") 60 | if err := o.bindObjectID(rObjectID, rhkObjectID, route.Formats); err != nil { 61 | res = append(res, err) 62 | } 63 | if len(res) > 0 { 64 | return errors.CompositeValidationError(res...) 65 | } 66 | return nil 67 | } 68 | 69 | // bindContainerID binds and validates parameter ContainerID from path. 70 | func (o *OptionsObjectsGetDeleteParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 71 | var raw string 72 | if len(rawData) > 0 { 73 | raw = rawData[len(rawData)-1] 74 | } 75 | 76 | // Required: true 77 | // Parameter is provided by construction from the route 78 | o.ContainerID = raw 79 | 80 | return nil 81 | } 82 | 83 | // bindObjectID binds and validates parameter ObjectID from path. 84 | func (o *OptionsObjectsGetDeleteParams) bindObjectID(rawData []string, hasKey bool, formats strfmt.Registry) error { 85 | var raw string 86 | if len(rawData) > 0 { 87 | raw = rawData[len(rawData)-1] 88 | } 89 | 90 | // Required: true 91 | // Parameter is provided by construction from the route 92 | o.ObjectID = raw 93 | 94 | return nil 95 | } 96 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_put.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsObjectsPutHandlerFunc turns a function with the right signature into a options objects put handler 15 | type OptionsObjectsPutHandlerFunc func(OptionsObjectsPutParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsObjectsPutHandlerFunc) Handle(params OptionsObjectsPutParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsObjectsPutHandler interface for that can handle valid options objects put params 23 | type OptionsObjectsPutHandler interface { 24 | Handle(OptionsObjectsPutParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsObjectsPut creates a new http.Handler for the options objects put operation 28 | func NewOptionsObjectsPut(ctx *middleware.Context, handler OptionsObjectsPutHandler) *OptionsObjectsPut { 29 | return &OptionsObjectsPut{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsObjectsPut swagger:route OPTIONS /objects optionsObjectsPut 33 | 34 | OptionsObjectsPut options objects put API 35 | 36 | */ 37 | type OptionsObjectsPut struct { 38 | Context *middleware.Context 39 | Handler OptionsObjectsPutHandler 40 | } 41 | 42 | func (o *OptionsObjectsPut) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsObjectsPutParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_put_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | ) 14 | 15 | // NewOptionsObjectsPutParams creates a new OptionsObjectsPutParams object 16 | // 17 | // There are no default values defined in the spec. 18 | func NewOptionsObjectsPutParams() OptionsObjectsPutParams { 19 | 20 | return OptionsObjectsPutParams{} 21 | } 22 | 23 | // OptionsObjectsPutParams contains all the bound params for the options objects put operation 24 | // typically these are obtained from a http.Request 25 | // 26 | // swagger:parameters optionsObjectsPut 27 | type OptionsObjectsPutParams struct { 28 | 29 | // HTTP Request Object 30 | HTTPRequest *http.Request `json:"-"` 31 | } 32 | 33 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 34 | // for simple values it will use straight method calls. 35 | // 36 | // To ensure default values, the struct must have been initialized with NewOptionsObjectsPutParams() beforehand. 37 | func (o *OptionsObjectsPutParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 38 | var res []error 39 | 40 | o.HTTPRequest = r 41 | 42 | if len(res) > 0 { 43 | return errors.CompositeValidationError(res...) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_put_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // OptionsObjectsPutOKCode is the HTTP code returned for type OptionsObjectsPutOK 15 | const OptionsObjectsPutOKCode int = 200 16 | 17 | /*OptionsObjectsPutOK CORS 18 | 19 | swagger:response optionsObjectsPutOK 20 | */ 21 | type OptionsObjectsPutOK struct { 22 | /* 23 | 24 | */ 25 | AccessControlAllowHeaders string `json:"Access-Control-Allow-Headers"` 26 | /* 27 | 28 | */ 29 | AccessControlAllowMethods string `json:"Access-Control-Allow-Methods"` 30 | /* 31 | 32 | */ 33 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 34 | } 35 | 36 | // NewOptionsObjectsPutOK creates OptionsObjectsPutOK with default headers values 37 | func NewOptionsObjectsPutOK() *OptionsObjectsPutOK { 38 | 39 | return &OptionsObjectsPutOK{} 40 | } 41 | 42 | // WithAccessControlAllowHeaders adds the accessControlAllowHeaders to the options objects put o k response 43 | func (o *OptionsObjectsPutOK) WithAccessControlAllowHeaders(accessControlAllowHeaders string) *OptionsObjectsPutOK { 44 | o.AccessControlAllowHeaders = accessControlAllowHeaders 45 | return o 46 | } 47 | 48 | // SetAccessControlAllowHeaders sets the accessControlAllowHeaders to the options objects put o k response 49 | func (o *OptionsObjectsPutOK) SetAccessControlAllowHeaders(accessControlAllowHeaders string) { 50 | o.AccessControlAllowHeaders = accessControlAllowHeaders 51 | } 52 | 53 | // WithAccessControlAllowMethods adds the accessControlAllowMethods to the options objects put o k response 54 | func (o *OptionsObjectsPutOK) WithAccessControlAllowMethods(accessControlAllowMethods string) *OptionsObjectsPutOK { 55 | o.AccessControlAllowMethods = accessControlAllowMethods 56 | return o 57 | } 58 | 59 | // SetAccessControlAllowMethods sets the accessControlAllowMethods to the options objects put o k response 60 | func (o *OptionsObjectsPutOK) SetAccessControlAllowMethods(accessControlAllowMethods string) { 61 | o.AccessControlAllowMethods = accessControlAllowMethods 62 | } 63 | 64 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the options objects put o k response 65 | func (o *OptionsObjectsPutOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *OptionsObjectsPutOK { 66 | o.AccessControlAllowOrigin = accessControlAllowOrigin 67 | return o 68 | } 69 | 70 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the options objects put o k response 71 | func (o *OptionsObjectsPutOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 72 | o.AccessControlAllowOrigin = accessControlAllowOrigin 73 | } 74 | 75 | // WriteResponse to the client 76 | func (o *OptionsObjectsPutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 77 | 78 | // response header Access-Control-Allow-Headers 79 | 80 | accessControlAllowHeaders := o.AccessControlAllowHeaders 81 | if accessControlAllowHeaders != "" { 82 | rw.Header().Set("Access-Control-Allow-Headers", accessControlAllowHeaders) 83 | } 84 | 85 | // response header Access-Control-Allow-Methods 86 | 87 | accessControlAllowMethods := o.AccessControlAllowMethods 88 | if accessControlAllowMethods != "" { 89 | rw.Header().Set("Access-Control-Allow-Methods", accessControlAllowMethods) 90 | } 91 | 92 | // response header Access-Control-Allow-Origin 93 | 94 | accessControlAllowOrigin := o.AccessControlAllowOrigin 95 | if accessControlAllowOrigin != "" { 96 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 97 | } 98 | 99 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 100 | 101 | rw.WriteHeader(200) 102 | } 103 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_search.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // OptionsObjectsSearchHandlerFunc turns a function with the right signature into a options objects search handler 15 | type OptionsObjectsSearchHandlerFunc func(OptionsObjectsSearchParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn OptionsObjectsSearchHandlerFunc) Handle(params OptionsObjectsSearchParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // OptionsObjectsSearchHandler interface for that can handle valid options objects search params 23 | type OptionsObjectsSearchHandler interface { 24 | Handle(OptionsObjectsSearchParams) middleware.Responder 25 | } 26 | 27 | // NewOptionsObjectsSearch creates a new http.Handler for the options objects search operation 28 | func NewOptionsObjectsSearch(ctx *middleware.Context, handler OptionsObjectsSearchHandler) *OptionsObjectsSearch { 29 | return &OptionsObjectsSearch{Context: ctx, Handler: handler} 30 | } 31 | 32 | /* OptionsObjectsSearch swagger:route OPTIONS /objects/{containerId}/search optionsObjectsSearch 33 | 34 | OptionsObjectsSearch options objects search API 35 | 36 | */ 37 | type OptionsObjectsSearch struct { 38 | Context *middleware.Context 39 | Handler OptionsObjectsSearchHandler 40 | } 41 | 42 | func (o *OptionsObjectsSearch) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | *r = *rCtx 46 | } 47 | var Params = NewOptionsObjectsSearchParams() 48 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 49 | o.Context.Respond(rw, r, route.Produces, route, err) 50 | return 51 | } 52 | 53 | res := o.Handler.Handle(Params) // actually handle the request 54 | o.Context.Respond(rw, r, route.Produces, route, res) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_search_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime/middleware" 13 | "github.com/go-openapi/strfmt" 14 | ) 15 | 16 | // NewOptionsObjectsSearchParams creates a new OptionsObjectsSearchParams object 17 | // 18 | // There are no default values defined in the spec. 19 | func NewOptionsObjectsSearchParams() OptionsObjectsSearchParams { 20 | 21 | return OptionsObjectsSearchParams{} 22 | } 23 | 24 | // OptionsObjectsSearchParams contains all the bound params for the options objects search operation 25 | // typically these are obtained from a http.Request 26 | // 27 | // swagger:parameters optionsObjectsSearch 28 | type OptionsObjectsSearchParams struct { 29 | 30 | // HTTP Request Object 31 | HTTPRequest *http.Request `json:"-"` 32 | 33 | /*Base58 encoded container id. 34 | Required: true 35 | In: path 36 | */ 37 | ContainerID string 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewOptionsObjectsSearchParams() beforehand. 44 | func (o *OptionsObjectsSearchParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | rContainerID, rhkContainerID, _ := route.Params.GetOK("containerId") 50 | if err := o.bindContainerID(rContainerID, rhkContainerID, route.Formats); err != nil { 51 | res = append(res, err) 52 | } 53 | if len(res) > 0 { 54 | return errors.CompositeValidationError(res...) 55 | } 56 | return nil 57 | } 58 | 59 | // bindContainerID binds and validates parameter ContainerID from path. 60 | func (o *OptionsObjectsSearchParams) bindContainerID(rawData []string, hasKey bool, formats strfmt.Registry) error { 61 | var raw string 62 | if len(rawData) > 0 { 63 | raw = rawData[len(rawData)-1] 64 | } 65 | 66 | // Required: true 67 | // Parameter is provided by construction from the route 68 | o.ContainerID = raw 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/options_objects_search_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // OptionsObjectsSearchOKCode is the HTTP code returned for type OptionsObjectsSearchOK 15 | const OptionsObjectsSearchOKCode int = 200 16 | 17 | /*OptionsObjectsSearchOK Base64 encoded stable binary marshaled bearer token. 18 | 19 | swagger:response optionsObjectsSearchOK 20 | */ 21 | type OptionsObjectsSearchOK struct { 22 | /* 23 | 24 | */ 25 | AccessControlAllowHeaders string `json:"Access-Control-Allow-Headers"` 26 | /* 27 | 28 | */ 29 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 30 | } 31 | 32 | // NewOptionsObjectsSearchOK creates OptionsObjectsSearchOK with default headers values 33 | func NewOptionsObjectsSearchOK() *OptionsObjectsSearchOK { 34 | 35 | return &OptionsObjectsSearchOK{} 36 | } 37 | 38 | // WithAccessControlAllowHeaders adds the accessControlAllowHeaders to the options objects search o k response 39 | func (o *OptionsObjectsSearchOK) WithAccessControlAllowHeaders(accessControlAllowHeaders string) *OptionsObjectsSearchOK { 40 | o.AccessControlAllowHeaders = accessControlAllowHeaders 41 | return o 42 | } 43 | 44 | // SetAccessControlAllowHeaders sets the accessControlAllowHeaders to the options objects search o k response 45 | func (o *OptionsObjectsSearchOK) SetAccessControlAllowHeaders(accessControlAllowHeaders string) { 46 | o.AccessControlAllowHeaders = accessControlAllowHeaders 47 | } 48 | 49 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the options objects search o k response 50 | func (o *OptionsObjectsSearchOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *OptionsObjectsSearchOK { 51 | o.AccessControlAllowOrigin = accessControlAllowOrigin 52 | return o 53 | } 54 | 55 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the options objects search o k response 56 | func (o *OptionsObjectsSearchOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 57 | o.AccessControlAllowOrigin = accessControlAllowOrigin 58 | } 59 | 60 | // WriteResponse to the client 61 | func (o *OptionsObjectsSearchOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 62 | 63 | // response header Access-Control-Allow-Headers 64 | 65 | accessControlAllowHeaders := o.AccessControlAllowHeaders 66 | if accessControlAllowHeaders != "" { 67 | rw.Header().Set("Access-Control-Allow-Headers", accessControlAllowHeaders) 68 | } 69 | 70 | // response header Access-Control-Allow-Origin 71 | 72 | accessControlAllowOrigin := o.AccessControlAllowOrigin 73 | if accessControlAllowOrigin != "" { 74 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 75 | } 76 | 77 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 78 | 79 | rw.WriteHeader(200) 80 | } 81 | -------------------------------------------------------------------------------- /gen/restapi/operations/put_container_e_acl.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // PutContainerEACLHandlerFunc turns a function with the right signature into a put container e ACL handler 17 | type PutContainerEACLHandlerFunc func(PutContainerEACLParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn PutContainerEACLHandlerFunc) Handle(params PutContainerEACLParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // PutContainerEACLHandler interface for that can handle valid put container e ACL params 25 | type PutContainerEACLHandler interface { 26 | Handle(PutContainerEACLParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewPutContainerEACL creates a new http.Handler for the put container e ACL operation 30 | func NewPutContainerEACL(ctx *middleware.Context, handler PutContainerEACLHandler) *PutContainerEACL { 31 | return &PutContainerEACL{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* PutContainerEACL swagger:route PUT /containers/{containerId}/eacl putContainerEAcl 35 | 36 | Set container EACL by id 37 | 38 | */ 39 | type PutContainerEACL struct { 40 | Context *middleware.Context 41 | Handler PutContainerEACLHandler 42 | } 43 | 44 | func (o *PutContainerEACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewPutContainerEACLParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/put_container_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // PutContainerOKCode is the HTTP code returned for type PutContainerOK 17 | const PutContainerOKCode int = 200 18 | 19 | /*PutContainerOK Identifier of the created container. 20 | 21 | swagger:response putContainerOK 22 | */ 23 | type PutContainerOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload *PutContainerOKBody `json:"body,omitempty"` 33 | } 34 | 35 | // NewPutContainerOK creates PutContainerOK with default headers values 36 | func NewPutContainerOK() *PutContainerOK { 37 | 38 | return &PutContainerOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the put container o k response 42 | func (o *PutContainerOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *PutContainerOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the put container o k response 48 | func (o *PutContainerOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the put container o k response 53 | func (o *PutContainerOK) WithPayload(payload *PutContainerOKBody) *PutContainerOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the put container o k response 59 | func (o *PutContainerOK) SetPayload(payload *PutContainerOKBody) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *PutContainerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | if o.Payload != nil { 75 | payload := o.Payload 76 | if err := producer.Produce(rw, payload); err != nil { 77 | panic(err) // let the recovery middleware deal with this 78 | } 79 | } 80 | } 81 | 82 | // PutContainerBadRequestCode is the HTTP code returned for type PutContainerBadRequest 83 | const PutContainerBadRequestCode int = 400 84 | 85 | /*PutContainerBadRequest Bad request. 86 | 87 | swagger:response putContainerBadRequest 88 | */ 89 | type PutContainerBadRequest struct { 90 | 91 | /* 92 | In: Body 93 | */ 94 | Payload *models.ErrorResponse `json:"body,omitempty"` 95 | } 96 | 97 | // NewPutContainerBadRequest creates PutContainerBadRequest with default headers values 98 | func NewPutContainerBadRequest() *PutContainerBadRequest { 99 | 100 | return &PutContainerBadRequest{} 101 | } 102 | 103 | // WithPayload adds the payload to the put container bad request response 104 | func (o *PutContainerBadRequest) WithPayload(payload *models.ErrorResponse) *PutContainerBadRequest { 105 | o.Payload = payload 106 | return o 107 | } 108 | 109 | // SetPayload sets the payload to the put container bad request response 110 | func (o *PutContainerBadRequest) SetPayload(payload *models.ErrorResponse) { 111 | o.Payload = payload 112 | } 113 | 114 | // WriteResponse to the client 115 | func (o *PutContainerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 116 | 117 | rw.WriteHeader(400) 118 | if o.Payload != nil { 119 | payload := o.Payload 120 | if err := producer.Produce(rw, payload); err != nil { 121 | panic(err) // let the recovery middleware deal with this 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /gen/restapi/operations/put_object.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // PutObjectHandlerFunc turns a function with the right signature into a put object handler 17 | type PutObjectHandlerFunc func(PutObjectParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn PutObjectHandlerFunc) Handle(params PutObjectParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // PutObjectHandler interface for that can handle valid put object params 25 | type PutObjectHandler interface { 26 | Handle(PutObjectParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewPutObject creates a new http.Handler for the put object operation 30 | func NewPutObject(ctx *middleware.Context, handler PutObjectHandler) *PutObject { 31 | return &PutObject{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* PutObject swagger:route PUT /objects putObject 35 | 36 | Upload object to FrostFS 37 | 38 | */ 39 | type PutObject struct { 40 | Context *middleware.Context 41 | Handler PutObjectHandler 42 | } 43 | 44 | func (o *PutObject) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewPutObjectParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/operations/put_object_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // PutObjectOKCode is the HTTP code returned for type PutObjectOK 17 | const PutObjectOKCode int = 200 18 | 19 | /*PutObjectOK Address of uploaded objects 20 | 21 | swagger:response putObjectOK 22 | */ 23 | type PutObjectOK struct { 24 | /* 25 | 26 | */ 27 | AccessControlAllowOrigin string `json:"Access-Control-Allow-Origin"` 28 | 29 | /* 30 | In: Body 31 | */ 32 | Payload *models.Address `json:"body,omitempty"` 33 | } 34 | 35 | // NewPutObjectOK creates PutObjectOK with default headers values 36 | func NewPutObjectOK() *PutObjectOK { 37 | 38 | return &PutObjectOK{} 39 | } 40 | 41 | // WithAccessControlAllowOrigin adds the accessControlAllowOrigin to the put object o k response 42 | func (o *PutObjectOK) WithAccessControlAllowOrigin(accessControlAllowOrigin string) *PutObjectOK { 43 | o.AccessControlAllowOrigin = accessControlAllowOrigin 44 | return o 45 | } 46 | 47 | // SetAccessControlAllowOrigin sets the accessControlAllowOrigin to the put object o k response 48 | func (o *PutObjectOK) SetAccessControlAllowOrigin(accessControlAllowOrigin string) { 49 | o.AccessControlAllowOrigin = accessControlAllowOrigin 50 | } 51 | 52 | // WithPayload adds the payload to the put object o k response 53 | func (o *PutObjectOK) WithPayload(payload *models.Address) *PutObjectOK { 54 | o.Payload = payload 55 | return o 56 | } 57 | 58 | // SetPayload sets the payload to the put object o k response 59 | func (o *PutObjectOK) SetPayload(payload *models.Address) { 60 | o.Payload = payload 61 | } 62 | 63 | // WriteResponse to the client 64 | func (o *PutObjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 65 | 66 | // response header Access-Control-Allow-Origin 67 | 68 | accessControlAllowOrigin := o.AccessControlAllowOrigin 69 | if accessControlAllowOrigin != "" { 70 | rw.Header().Set("Access-Control-Allow-Origin", accessControlAllowOrigin) 71 | } 72 | 73 | rw.WriteHeader(200) 74 | if o.Payload != nil { 75 | payload := o.Payload 76 | if err := producer.Produce(rw, payload); err != nil { 77 | panic(err) // let the recovery middleware deal with this 78 | } 79 | } 80 | } 81 | 82 | // PutObjectBadRequestCode is the HTTP code returned for type PutObjectBadRequest 83 | const PutObjectBadRequestCode int = 400 84 | 85 | /*PutObjectBadRequest Bad request 86 | 87 | swagger:response putObjectBadRequest 88 | */ 89 | type PutObjectBadRequest struct { 90 | 91 | /* 92 | In: Body 93 | */ 94 | Payload *models.ErrorResponse `json:"body,omitempty"` 95 | } 96 | 97 | // NewPutObjectBadRequest creates PutObjectBadRequest with default headers values 98 | func NewPutObjectBadRequest() *PutObjectBadRequest { 99 | 100 | return &PutObjectBadRequest{} 101 | } 102 | 103 | // WithPayload adds the payload to the put object bad request response 104 | func (o *PutObjectBadRequest) WithPayload(payload *models.ErrorResponse) *PutObjectBadRequest { 105 | o.Payload = payload 106 | return o 107 | } 108 | 109 | // SetPayload sets the payload to the put object bad request response 110 | func (o *PutObjectBadRequest) SetPayload(payload *models.ErrorResponse) { 111 | o.Payload = payload 112 | } 113 | 114 | // WriteResponse to the client 115 | func (o *PutObjectBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 116 | 117 | rw.WriteHeader(400) 118 | if o.Payload != nil { 119 | payload := o.Payload 120 | if err := producer.Produce(rw, payload); err != nil { 121 | panic(err) // let the recovery middleware deal with this 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /gen/restapi/operations/search_objects.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package operations 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | 13 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 14 | ) 15 | 16 | // SearchObjectsHandlerFunc turns a function with the right signature into a search objects handler 17 | type SearchObjectsHandlerFunc func(SearchObjectsParams, *models.Principal) middleware.Responder 18 | 19 | // Handle executing the request and returning a response 20 | func (fn SearchObjectsHandlerFunc) Handle(params SearchObjectsParams, principal *models.Principal) middleware.Responder { 21 | return fn(params, principal) 22 | } 23 | 24 | // SearchObjectsHandler interface for that can handle valid search objects params 25 | type SearchObjectsHandler interface { 26 | Handle(SearchObjectsParams, *models.Principal) middleware.Responder 27 | } 28 | 29 | // NewSearchObjects creates a new http.Handler for the search objects operation 30 | func NewSearchObjects(ctx *middleware.Context, handler SearchObjectsHandler) *SearchObjects { 31 | return &SearchObjects{Context: ctx, Handler: handler} 32 | } 33 | 34 | /* SearchObjects swagger:route POST /objects/{containerId}/search searchObjects 35 | 36 | Search objects by filters 37 | 38 | */ 39 | type SearchObjects struct { 40 | Context *middleware.Context 41 | Handler SearchObjectsHandler 42 | } 43 | 44 | func (o *SearchObjects) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 | route, rCtx, _ := o.Context.RouteInfo(r) 46 | if rCtx != nil { 47 | *r = *rCtx 48 | } 49 | var Params = NewSearchObjectsParams() 50 | uprinc, aCtx, err := o.Context.Authorize(r, route) 51 | if err != nil { 52 | o.Context.Respond(rw, r, route.Produces, route, err) 53 | return 54 | } 55 | if aCtx != nil { 56 | *r = *aCtx 57 | } 58 | var principal *models.Principal 59 | if uprinc != nil { 60 | principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 61 | } 62 | 63 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 64 | o.Context.Respond(rw, r, route.Produces, route, err) 65 | return 66 | } 67 | 68 | res := o.Handler.Handle(Params, principal) // actually handle the request 69 | o.Context.Respond(rw, r, route.Produces, route, res) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /gen/restapi/server_config.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package restapi 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/spf13/pflag" 9 | ) 10 | 11 | const ( 12 | FlagScheme = "scheme" 13 | FlagCleanupTimeout = "cleanup-timeout" 14 | FlagGracefulTimeout = "graceful-timeout" 15 | FlagMaxHeaderSize = "max-header-size" 16 | FlagListenAddress = "listen-address" 17 | FlagListenLimit = "listen-limit" 18 | FlagKeepAlive = "keep-alive" 19 | FlagReadTimeout = "read-timeout" 20 | FlagWriteTimeout = "write-timeout" 21 | FlagTLSListenAddress = "tls-listen-address" 22 | FlagTLSCertificate = "tls-certificate" 23 | FlagTLSKey = "tls-key" 24 | FlagTLSCa = "tls-ca" 25 | FlagTLSListenLimit = "tls-listen-limit" 26 | FlagTLSKeepAlive = "tls-keep-alive" 27 | FlagTLSReadTimeout = "tls-read-timeout" 28 | FlagTLSWriteTimeout = "tls-write-timeout" 29 | ) 30 | 31 | // BindDefaultFlag init default flag. 32 | func BindDefaultFlags(flagSet *pflag.FlagSet) { 33 | flagSet.StringSlice(FlagScheme, defaultSchemes, "the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec") 34 | 35 | flagSet.Duration(FlagCleanupTimeout, 10*time.Second, "grace period for which to wait before killing idle connections") 36 | flagSet.Duration(FlagGracefulTimeout, 15*time.Second, "grace period for which to wait before shutting down the server") 37 | flagSet.Int(FlagMaxHeaderSize, 1000000, "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") 38 | 39 | flagSet.String(FlagListenAddress, "localhost:8080", "the IP and port to listen on") 40 | flagSet.Int(FlagListenLimit, 0, "limit the number of outstanding requests") 41 | flagSet.Duration(FlagKeepAlive, 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") 42 | flagSet.Duration(FlagReadTimeout, 30*time.Second, "maximum duration before timing out read of the request") 43 | flagSet.Duration(FlagWriteTimeout, 30*time.Second, "maximum duration before timing out write of the response") 44 | 45 | flagSet.String(FlagTLSListenAddress, "localhost:8081", "the IP and port to listen on") 46 | flagSet.String(FlagTLSCertificate, "", "the certificate file to use for secure connections") 47 | flagSet.String(FlagTLSKey, "", "the private key file to use for secure connections (without passphrase)") 48 | flagSet.String(FlagTLSCa, "", "the certificate authority certificate file to be used with mutual tls auth") 49 | flagSet.Int(FlagTLSListenLimit, 0, "limit the number of outstanding requests") 50 | flagSet.Duration(FlagTLSKeepAlive, 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") 51 | flagSet.Duration(FlagTLSReadTimeout, 30*time.Second, "maximum duration before timing out read of the request") 52 | flagSet.Duration(FlagTLSWriteTimeout, 30*time.Second, "maximum duration before timing out write of the response") 53 | } 54 | -------------------------------------------------------------------------------- /handlers/auth_test.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | "encoding/base64" 6 | "encoding/hex" 7 | "math" 8 | "testing" 9 | 10 | "github.com/TrueCloudLab/frostfs-api-go/v2/acl" 11 | crypto "github.com/TrueCloudLab/frostfs-crypto" 12 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 13 | "github.com/TrueCloudLab/frostfs-rest-gw/internal/util" 14 | "github.com/TrueCloudLab/frostfs-sdk-go/user" 15 | "github.com/nspcc-dev/neo-go/pkg/crypto/keys" 16 | "github.com/stretchr/testify/require" 17 | ) 18 | 19 | const devenvPrivateKey = "1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb" 20 | 21 | func TestSign(t *testing.T) { 22 | key, err := keys.NewPrivateKeyFromHex(devenvPrivateKey) 23 | require.NoError(t, err) 24 | 25 | pubKeyHex := hex.EncodeToString(key.PublicKey().Bytes()) 26 | 27 | records := []*models.Record{{ 28 | Operation: models.NewOperation(models.OperationPUT), 29 | Action: models.NewAction(models.ActionALLOW), 30 | Filters: []*models.Filter{}, 31 | Targets: []*models.Target{{ 32 | Role: models.NewRole(models.RoleOTHERS), 33 | Keys: []string{}, 34 | }}, 35 | }} 36 | 37 | btoken, err := util.ToNativeObjectToken(records) 38 | require.NoError(t, err) 39 | 40 | btoken.SetExp(math.MaxInt64) 41 | 42 | ownerKey, err := keys.NewPublicKeyFromString(pubKeyHex) 43 | require.NoError(t, err) 44 | 45 | var owner user.ID 46 | user.IDFromKey(&owner, *(*ecdsa.PublicKey)(ownerKey)) 47 | btoken.ForUser(owner) 48 | 49 | var v2token acl.BearerToken 50 | btoken.WriteToV2(&v2token) 51 | 52 | binaryBearer := v2token.GetBody().StableMarshal(nil) 53 | bearerBase64 := base64.StdEncoding.EncodeToString(binaryBearer) 54 | 55 | signatureData, err := crypto.Sign(&key.PrivateKey, binaryBearer) 56 | require.NoError(t, err) 57 | 58 | bt := &BearerToken{ 59 | Token: bearerBase64, 60 | Signature: hex.EncodeToString(signatureData), 61 | Key: pubKeyHex, 62 | } 63 | 64 | _, err = prepareBearerToken(bt, false, false) 65 | require.NoError(t, err) 66 | } 67 | -------------------------------------------------------------------------------- /handlers/balance.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/models" 7 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/restapi/operations" 8 | "github.com/TrueCloudLab/frostfs-rest-gw/internal/util" 9 | "github.com/TrueCloudLab/frostfs-sdk-go/pool" 10 | "github.com/TrueCloudLab/frostfs-sdk-go/user" 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // Balance handler that get balance from FrostFS. 15 | func (a *API) Balance(params operations.GetBalanceParams) middleware.Responder { 16 | var ownerID user.ID 17 | if err := ownerID.DecodeString(params.Address); err != nil { 18 | resp := a.logAndGetErrorResponse("parse address", err) 19 | return operations.NewGetBalanceBadRequest().WithPayload(resp) 20 | } 21 | 22 | var prm pool.PrmBalanceGet 23 | prm.SetAccount(ownerID) 24 | 25 | frostfsBalance, err := a.pool.Balance(params.HTTPRequest.Context(), prm) 26 | if err != nil { 27 | resp := a.logAndGetErrorResponse("get balance", err) 28 | return operations.NewGetBalanceBadRequest().WithPayload(resp) 29 | } 30 | 31 | var resp models.Balance 32 | resp.Address = util.NewString(params.Address) 33 | resp.Value = util.NewString(strconv.FormatInt(frostfsBalance.Value(), 10)) 34 | resp.Precision = util.NewInteger(int64(frostfsBalance.Precision())) 35 | 36 | return operations.NewGetBalanceOK(). 37 | WithPayload(&resp). 38 | WithAccessControlAllowOrigin("*") 39 | } 40 | -------------------------------------------------------------------------------- /handlers/container_test.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "testing" 5 | 6 | sessionv2 "github.com/TrueCloudLab/frostfs-api-go/v2/session" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestCheckContainerName(t *testing.T) { 11 | name64 := "container-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 12 | name256 := "container-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 13 | 14 | for _, tc := range []struct { 15 | name string 16 | valid bool 17 | }{ 18 | {name: "container", valid: true}, 19 | {name: "container-name", valid: true}, 20 | {name: "container.name", valid: true}, 21 | {name: "container2", valid: true}, 22 | {name: "2container.name", valid: true}, 23 | {name: "containerName", valid: false}, 24 | {name: "-container", valid: false}, 25 | {name: "container-", valid: false}, 26 | {name: "container name", valid: false}, 27 | {name: "c", valid: false}, 28 | {name: name64 + ".name", valid: false}, 29 | {name: name256, valid: false}, 30 | } { 31 | err := checkNNSContainerName(tc.name) 32 | if tc.valid { 33 | require.NoError(t, err) 34 | } else { 35 | require.Error(t, err) 36 | } 37 | } 38 | } 39 | 40 | func TestPrepareSessionToken(t *testing.T) { 41 | st := &SessionToken{ 42 | BearerToken: BearerToken{ 43 | Token: "ChASxCTiXwREjLAG7nkxjDHVEhsKGTVxfQ56a0uQeFmOO63mqykBS1HNpw1rxSgaBgjIAhjkASIhAnLj82Qmdlcg7JtoyhDjJ1OsRFjtmxdXbzrwVkwxWAdWMgQIAxAB", 44 | Signature: "2ebdc1f2fea2bba397d1be6f982a6fe1b2bc9f46a348b700108fe2eba4e6531a1bb585febf9a40a3fa2e085fca5e2a75ca57f61166117c6d3e04a95ef9a2d2196f52648546784853e17c0b7ba762eae1", 45 | Key: "03bd9108c0b49f657e9eee50d1399022bd1e436118e5b7529a1b7cd606652f578f", 46 | }, 47 | Verb: sessionv2.ContainerVerbSetEACL, 48 | } 49 | 50 | _, err := prepareSessionToken(st, true) 51 | require.NoError(t, err) 52 | } 53 | -------------------------------------------------------------------------------- /handlers/objects_test.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/restapi/operations" 7 | "github.com/TrueCloudLab/frostfs-rest-gw/internal/util" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestPrepareOffset(t *testing.T) { 12 | for _, tc := range []struct { 13 | err bool 14 | expectedOffset uint64 15 | expectedLength uint64 16 | params operations.GetObjectInfoParams 17 | objSize uint64 18 | }{ 19 | { 20 | params: operations.GetObjectInfoParams{ 21 | RangeLength: util.NewInteger(1), 22 | RangeOffset: util.NewInteger(0), 23 | }, 24 | objSize: 1, 25 | expectedOffset: 0, 26 | expectedLength: 1, 27 | }, 28 | { 29 | params: operations.GetObjectInfoParams{ 30 | RangeLength: util.NewInteger(3), 31 | RangeOffset: util.NewInteger(1), 32 | }, 33 | objSize: 5, 34 | expectedOffset: 1, 35 | expectedLength: 3, 36 | }, 37 | { 38 | objSize: 1, 39 | expectedOffset: 0, 40 | expectedLength: 1, 41 | }, 42 | { 43 | err: true, 44 | params: operations.GetObjectInfoParams{ 45 | RangeLength: util.NewInteger(1), 46 | RangeOffset: nil, 47 | }, 48 | }, 49 | { 50 | err: true, 51 | params: operations.GetObjectInfoParams{ 52 | RangeLength: nil, 53 | RangeOffset: util.NewInteger(1), 54 | }, 55 | }, 56 | { 57 | err: true, 58 | params: operations.GetObjectInfoParams{ 59 | RangeLength: util.NewInteger(1), 60 | RangeOffset: util.NewInteger(0), 61 | }, 62 | objSize: 0, 63 | }, 64 | } { 65 | t.Run("", func(t *testing.T) { 66 | offset, length, err := prepareOffsetLength(tc.params, tc.objSize) 67 | if tc.err { 68 | require.Error(t, err) 69 | return 70 | } 71 | 72 | require.NoError(t, err) 73 | require.Equal(t, tc.expectedOffset, offset) 74 | require.Equal(t, tc.expectedLength, length) 75 | }) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /handlers/preflight.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "github.com/TrueCloudLab/frostfs-rest-gw/gen/restapi/operations" 5 | "github.com/go-openapi/runtime/middleware" 6 | ) 7 | 8 | const ( 9 | allOrigins = "*" 10 | allowMethods = "PUT, DELETE" 11 | allowHeaders = "X-Bearer-For-All-Users, X-Bearer-Lifetime, X-Bearer-Owner-Id, X-Bearer-Signature, X-Bearer-Signature-Key, Content-Type, Authorization" 12 | ) 13 | 14 | func (a *API) OptionsAuth(operations.OptionsAuthParams) middleware.Responder { 15 | return operations.NewOptionsAuthOK(). 16 | WithAccessControlAllowOrigin(allOrigins). 17 | WithAccessControlAllowHeaders(allowHeaders) 18 | } 19 | 20 | func (a *API) OptionsAuthBearer(operations.OptionsAuthBearerParams) middleware.Responder { 21 | return operations.NewOptionsAuthBearerOK(). 22 | WithAccessControlAllowOrigin(allOrigins). 23 | WithAccessControlAllowHeaders(allowHeaders) 24 | } 25 | 26 | func (a *API) OptionsObjectSearch(operations.OptionsObjectsSearchParams) middleware.Responder { 27 | return operations.NewOptionsObjectsSearchOK(). 28 | WithAccessControlAllowOrigin(allOrigins). 29 | WithAccessControlAllowHeaders(allowHeaders) 30 | } 31 | 32 | func (a *API) OptionsObjectsPut(operations.OptionsObjectsPutParams) middleware.Responder { 33 | return operations.NewOptionsObjectsPutOK(). 34 | WithAccessControlAllowOrigin(allOrigins). 35 | WithAccessControlAllowHeaders(allowHeaders). 36 | WithAccessControlAllowMethods(allowMethods) 37 | } 38 | 39 | func (a *API) OptionsObjectsGetDelete(operations.OptionsObjectsGetDeleteParams) middleware.Responder { 40 | return operations.NewOptionsObjectsGetDeleteOK(). 41 | WithAccessControlAllowOrigin(allOrigins). 42 | WithAccessControlAllowHeaders(allowHeaders). 43 | WithAccessControlAllowMethods(allowMethods) 44 | } 45 | 46 | func (a *API) OptionsContainersPutList(operations.OptionsContainersPutListParams) middleware.Responder { 47 | return operations.NewOptionsContainersPutListOK(). 48 | WithAccessControlAllowOrigin(allOrigins). 49 | WithAccessControlAllowHeaders(allowHeaders). 50 | WithAccessControlAllowMethods(allowMethods) 51 | } 52 | 53 | func (a *API) OptionsContainersGetDelete(operations.OptionsContainersGetDeleteParams) middleware.Responder { 54 | return operations.NewOptionsContainersGetDeleteOK(). 55 | WithAccessControlAllowOrigin(allOrigins). 56 | WithAccessControlAllowHeaders(allowHeaders). 57 | WithAccessControlAllowMethods(allowMethods) 58 | } 59 | 60 | func (a *API) OptionsContainersEACL(operations.OptionsContainersEACLParams) middleware.Responder { 61 | return operations.NewOptionsContainersEACLOK(). 62 | WithAccessControlAllowOrigin(allOrigins). 63 | WithAccessControlAllowHeaders(allowHeaders). 64 | WithAccessControlAllowMethods(allowMethods) 65 | } 66 | -------------------------------------------------------------------------------- /internal/util/transformers_test.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "fmt" 7 | "testing" 8 | 9 | apistatus "github.com/TrueCloudLab/frostfs-sdk-go/client/status" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestErrors(t *testing.T) { 14 | apiErr := fmt.Errorf("some context: %w", apistatus.ContainerNotFound{}) 15 | 16 | resp := NewErrorResponse(apiErr) 17 | data, err := json.Marshal(resp) 18 | require.NoError(t, err) 19 | require.Equal(t, `{"code":3072,"message":"some context: status: code = 3072","type":"API"}`, string(data)) 20 | 21 | gwErr := fmt.Errorf("some context: %w", errors.New("sanity check error")) 22 | 23 | resp = NewErrorResponse(gwErr) 24 | data, err = json.Marshal(resp) 25 | require.NoError(t, err) 26 | require.Equal(t, `{"message":"some context: sanity check error","type":"GW"}`, string(data)) 27 | } 28 | -------------------------------------------------------------------------------- /metrics/pprof.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "net/http" 5 | "net/http/pprof" 6 | 7 | "go.uber.org/zap" 8 | ) 9 | 10 | // NewPprofService creates a new service for gathering pprof metrics. 11 | func NewPprofService(l *zap.Logger, cfg Config) *Service { 12 | handler := http.NewServeMux() 13 | handler.HandleFunc("/debug/pprof/", pprof.Index) 14 | handler.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) 15 | handler.HandleFunc("/debug/pprof/profile", pprof.Profile) 16 | handler.HandleFunc("/debug/pprof/symbol", pprof.Symbol) 17 | handler.HandleFunc("/debug/pprof/trace", pprof.Trace) 18 | 19 | // Manually add support for paths linked to by index page at /debug/pprof/ 20 | for _, item := range []string{"allocs", "block", "heap", "goroutine", "mutex", "threadcreate"} { 21 | handler.Handle("/debug/pprof/"+item, pprof.Handler(item)) 22 | } 23 | 24 | return &Service{ 25 | Server: &http.Server{ 26 | Addr: cfg.Address, 27 | Handler: handler, 28 | }, 29 | enabled: cfg.Enabled, 30 | serviceType: "Pprof", 31 | log: l.With(zap.String("service", "Pprof")), 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /metrics/service.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | 7 | "go.uber.org/zap" 8 | ) 9 | 10 | // Service serves metrics. 11 | type Service struct { 12 | *http.Server 13 | enabled bool 14 | log *zap.Logger 15 | serviceType string 16 | } 17 | 18 | // Config is a params to configure service. 19 | type Config struct { 20 | Address string 21 | Enabled bool 22 | } 23 | 24 | // Start runs http service with the exposed endpoint on the configured port. 25 | func (ms *Service) Start() { 26 | if ms.enabled { 27 | ms.log.Info("service is running", zap.String("endpoint", ms.Addr)) 28 | err := ms.ListenAndServe() 29 | if err != nil && err != http.ErrServerClosed { 30 | ms.log.Warn("service couldn't start on configured port") 31 | } 32 | } else { 33 | ms.log.Info("service hasn't started since it's disabled") 34 | } 35 | } 36 | 37 | // ShutDown stops the service. 38 | func (ms *Service) ShutDown(ctx context.Context) { 39 | ms.log.Info("shutting down service", zap.String("endpoint", ms.Addr)) 40 | err := ms.Shutdown(ctx) 41 | if err != nil { 42 | ms.log.Panic("can't shut down service", zap.Error(err)) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /static/docs/docs.md: -------------------------------------------------------------------------------- 1 | 2 | # frostfs-rest-gw 3 | 4 | FrostFS REST Gateway bridges FrostFS internal protocol and REST API server. 5 | 6 | ### Open API specification 7 | 8 | See full [API spec](/v1/docs). 9 | 10 | ### Basic concept 11 | 12 | Using this API you can interact with FrostFS nodes and manage containers and objects. 13 | 14 | #### Container 15 | 16 | To create container you must provide `PlacementPolicy` and `BasicACL`. 17 | 18 | ##### Placement policy 19 | 20 | Placement policy allows you control where and how container (and its object) is stored. 21 | For example, you want to store 3 copy of every object, so you can use the following policy: 22 | 23 | ``` 24 | REP 3 25 | ``` 26 | 27 | [More about policy](https://github.com/nspcc-dev/neofs-spec/blob/7ae698ebbe68c689cab2aba518312e7d3eea403c/01-arch/02-policy.md). 28 | 29 | ##### Basic ACL 30 | 31 | Basic ACL is a part of the container structure, and it is always created simultaneously with the container. 32 | Therefore, it is never subject to any changes. It is a 32-bit integer with a bit field in the following format: 33 | 34 | acl-basic 35 | 36 | | Symbol | Meaning | Description | 37 | |--------|:--------|------------------------------------------------------------------------------------------------| 38 | | **B** | Bearer | Allows using Bear Token ACL rules to replace eACL rules | 39 | | **U** | User | The owner of the container identified by the public key linked to the container | 40 | | **S** | System | Inner Ring and/or container nodes in the current version of network map | 41 | | | | IR nodes can only perform `GetRangeHash`, `Head`, and `Search` necessary for data audit. | 42 | | | | Container nodes can only do things required for the replication. | 43 | | **O** | Others | Clients that do not match any of the categories above | 44 | | **F** | Final | Flag denying Extended ACL. If set, Basic ACL check is final, Extended ACL is ignored | 45 | | **X** | Sticky | Flag denying different owners of the request and the object | 46 | | | | If set, object in `Put` request must have one `Owner` and be signed with the same signature | 47 | | | | If not set, the object must be correct but can be of any owner. | 48 | | | | The nodes falling for `SYSTEM` role are exception from this rule. For them the bit is ignored. | 49 | | **0** | Deny | Denies operation of the identified category | 50 | | **1** | Allow | Allows operation of the identified category | 51 | 52 | To upload objects with bearer token your container must have Bearer bits set. 53 | For example, you can use `0x0FBFBFFF` or predefined `eacl-public-read-write` values. 54 | 55 | Also don't forget set appropriate eACL to restrict your container. 56 | 57 | [More about ACL](https://github.com/nspcc-dev/neofs-spec/blob/4f8d945dfbd2a313ebd406746cf38b9de9da6038/01-arch/07-acl.md). 58 | 59 | #### Object 60 | To create object you must provide `containerId` and `fileName`. 61 | Additionally, you can provide `payload` (base64 encoded data) and `attributes`. 62 | 63 | Attribute is key value data that is stored with object. Key and value must be in utf8 format and must not be empty. 64 | 65 | Valid attribute: 66 | * `MyAttribute: 'some value'` 67 | 68 | Invalid attribute: 69 | * `MyAttribute: ''` 70 | 71 | Also, you can use this attribute to further object searching. 72 | 73 | ### Status codes 74 | 75 | More about FrostFS status code you can 76 | find [here](https://github.com/nspcc-dev/neofs-spec/blob/master/20-api-v2/status.md). 77 | 78 | 79 | -------------------------------------------------------------------------------- /static/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FrostFS REST GW 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /templates/server-config.yaml: -------------------------------------------------------------------------------- 1 | layout: 2 | application: 3 | - name: main 4 | source: asset:serverMain 5 | target: "{{ joinFilePath .Target \"cmd\" (dasherize (pascalize .Name)) }}-server" 6 | file_name: "main.go" 7 | - name: embedded_spec 8 | source: asset:swaggerJsonEmbed 9 | target: "{{ joinFilePath .Target .ServerPackage }}" 10 | file_name: "embedded_spec.go" 11 | - name: server 12 | source: serverServer 13 | target: "{{ joinFilePath .Target .ServerPackage }}" 14 | file_name: "server.go" 15 | - name: server_config 16 | source: serverConfig 17 | target: "{{ joinFilePath .Target .ServerPackage }}" 18 | file_name: "server_config.go" 19 | - name: builder 20 | source: asset:serverBuilder 21 | target: "{{ joinFilePath .Target .ServerPackage .Package }}" 22 | file_name: "{{ snakize (pascalize .Name) }}_api.go" 23 | - name: doc 24 | source: asset:serverDoc 25 | target: "{{ joinFilePath .Target .ServerPackage }}" 26 | file_name: "doc.go" 27 | models: 28 | - name: definition 29 | source: asset:model 30 | target: "{{ joinFilePath .Target .ModelPackage }}" 31 | file_name: "{{ (snakize (pascalize .Name)) }}.go" 32 | operations: 33 | - name: parameters 34 | source: asset:serverParameter 35 | target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}" 36 | file_name: "{{ (snakize (pascalize .Name)) }}_parameters.go" 37 | - name: responses 38 | source: asset:serverResponses 39 | target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}" 40 | file_name: "{{ (snakize (pascalize .Name)) }}_responses.go" 41 | - name: handler 42 | source: asset:serverOperation 43 | target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}" 44 | file_name: "{{ (snakize (pascalize .Name)) }}.go" 45 | operation_groups: 46 | -------------------------------------------------------------------------------- /templates/server/config.gotmpl: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | 4 | {{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }} 5 | 6 | 7 | package {{ .APIPackage }} 8 | 9 | import ( 10 | "time" 11 | 12 | "github.com/spf13/pflag" 13 | ) 14 | 15 | const ( 16 | FlagScheme = "scheme" 17 | FlagCleanupTimeout = "cleanup-timeout" 18 | FlagGracefulTimeout = "graceful-timeout" 19 | FlagMaxHeaderSize = "max-header-size" 20 | FlagListenAddress = "listen-address" 21 | FlagListenLimit = "listen-limit" 22 | FlagKeepAlive = "keep-alive" 23 | FlagReadTimeout = "read-timeout" 24 | FlagWriteTimeout = "write-timeout" 25 | FlagTLSListenAddress = "tls-listen-address" 26 | FlagTLSCertificate = "tls-certificate" 27 | FlagTLSKey = "tls-key" 28 | FlagTLSCa = "tls-ca" 29 | FlagTLSListenLimit = "tls-listen-limit" 30 | FlagTLSKeepAlive = "tls-keep-alive" 31 | FlagTLSReadTimeout = "tls-read-timeout" 32 | FlagTLSWriteTimeout = "tls-write-timeout" 33 | ) 34 | 35 | // BindDefaultFlag init default flag. 36 | func BindDefaultFlags(flagSet *pflag.FlagSet) { 37 | flagSet.StringSlice(FlagScheme, defaultSchemes, "the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec") 38 | 39 | flagSet.Duration(FlagCleanupTimeout, 10*time.Second, "grace period for which to wait before killing idle connections") 40 | flagSet.Duration(FlagGracefulTimeout, 15*time.Second, "grace period for which to wait before shutting down the server") 41 | flagSet.Int(FlagMaxHeaderSize, 1000000, "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") 42 | 43 | flagSet.String(FlagListenAddress, "localhost:8080", "the IP and port to listen on") 44 | flagSet.Int(FlagListenLimit, 0, "limit the number of outstanding requests") 45 | flagSet.Duration(FlagKeepAlive, 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") 46 | flagSet.Duration(FlagReadTimeout, 30*time.Second, "maximum duration before timing out read of the request") 47 | flagSet.Duration(FlagWriteTimeout, 30*time.Second, "maximum duration before timing out write of the response") 48 | 49 | flagSet.String(FlagTLSListenAddress, "localhost:8081", "the IP and port to listen on") 50 | flagSet.String(FlagTLSCertificate, "", "the certificate file to use for secure connections") 51 | flagSet.String(FlagTLSKey, "", "the private key file to use for secure connections (without passphrase)") 52 | flagSet.String(FlagTLSCa, "", "the certificate authority certificate file to be used with mutual tls auth") 53 | flagSet.Int(FlagTLSListenLimit, 0, "limit the number of outstanding requests") 54 | flagSet.Duration(FlagTLSKeepAlive, 3*time.Minute, "sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)") 55 | flagSet.Duration(FlagTLSReadTimeout, 30*time.Second, "maximum duration before timing out read of the request") 56 | flagSet.Duration(FlagTLSWriteTimeout, 30*time.Second, "maximum duration before timing out write of the response") 57 | } 58 | --------------------------------------------------------------------------------