From 39e7ac3fdeb4f6b7bfed254700a68605a563bfe9 Mon Sep 17 00:00:00 2001 From: Ian Ngethe Muchiri <100555904+ianmuchyri@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:35:30 +0300 Subject: [PATCH] NOISSUE - Sync with new Mainflux (#74) * add new mainflux sdk to UI Signed-off-by: ianmuchyri * remove policy endpoints Signed-off-by: ianmuchyri * fix functionality of current services Signed-off-by: ianmuchyri * add missing functionality Signed-off-by: ianmuchyri * add usergroups.html file Signed-off-by: ianmuchyri * update ui to sync with new mainflux Signed-off-by: ianmuchyri * fix errors Signed-off-by: ianmuchyri * add period to end of comment Signed-off-by: ianmuchyri * add period to comment Signed-off-by: ianmuchyri * fix port Signed-off-by: ianmuchyri * fix port in env Signed-off-by: ianmuchyri * fix rebase error Signed-off-by: ianmuchyri * update error handling of new functions Signed-off-by: ianmuchyri * fix linter error Signed-off-by: ianmuchyri * add empty line to html files Signed-off-by: ianmuchyri --------- Signed-off-by: ianmuchyri --- cmd/ui/main.go | 4 +- docker/.env | 4 +- go.mod | 48 +- go.sum | 199 +- ui/api/endpoint.go | 919 ++-- ui/api/logging.go | 449 +- ui/api/metrics.go | 430 +- ui/api/requests.go | 322 +- ui/api/transport.go | 742 ++- ui/service.go | 1371 +++-- ui/web/static/css/styles.css | 1 + ui/web/template/bootstrap.html | 19 +- ui/web/template/channel.html | 38 +- ui/web/template/channelconn.html | 418 -- ui/web/template/channelgroups.html | 245 + ui/web/template/channels.html | 8 +- ui/web/template/channelthings.html | 216 + ui/web/template/channelusers.html | 258 + ui/web/template/group.html | 35 +- ui/web/template/groupchannels.html | 221 + ui/web/template/groupconn.html | 289 - ui/web/template/groups.html | 8 +- ui/web/template/groupusers.html | 282 + ui/web/template/navbar.html | 24 - ui/web/template/thing.html | 34 +- ui/web/template/thingchannels.html | 221 + ui/web/template/thingconn.html | 349 -- ui/web/template/things.html | 8 +- ui/web/template/thingspolicies.html | 459 -- ui/web/template/thingusers.html | 249 + ui/web/template/user.html | 58 +- ui/web/template/userchannels.html | 245 + ui/web/template/usergroups.html | 246 + ui/web/template/users.html | 8 +- ui/web/template/userspolicies.html | 454 -- ui/web/template/userthings.html | 106 + .../decred/dcrd/dcrec/secp256k1/v4/LICENSE | 17 - .../decred/dcrd/dcrec/secp256k1/v4/README.md | 72 - .../secp256k1/v4/compressedbytepoints.go | 18 - .../decred/dcrd/dcrec/secp256k1/v4/curve.go | 1272 ----- .../decred/dcrd/dcrec/secp256k1/v4/doc.go | 59 - .../decred/dcrd/dcrec/secp256k1/v4/ecdh.go | 21 - .../dcrec/secp256k1/v4/ellipticadaptor.go | 255 - .../decred/dcrd/dcrec/secp256k1/v4/error.go | 67 - .../decred/dcrd/dcrec/secp256k1/v4/field.go | 1681 ------ .../dcrec/secp256k1/v4/loadprecomputed.go | 91 - .../dcrd/dcrec/secp256k1/v4/modnscalar.go | 1101 ---- .../decred/dcrd/dcrec/secp256k1/v4/nonce.go | 263 - .../decred/dcrd/dcrec/secp256k1/v4/privkey.go | 111 - .../decred/dcrd/dcrec/secp256k1/v4/pubkey.go | 237 - .../eclipse/paho.mqtt.golang/README.md | 6 +- .../eclipse/paho.mqtt.golang/backoff.go | 104 + .../eclipse/paho.mqtt.golang/client.go | 22 +- .../eclipse/paho.mqtt.golang/netconn.go | 8 +- .../eclipse/paho.mqtt.golang/ping.go | 8 +- .../fxamacker/cbor/v2/.golangci.yml | 15 +- .../fxamacker/cbor/v2/CBOR_BENCHMARKS.md | 264 - .../fxamacker/cbor/v2/CBOR_GOLANG.md | 32 - .../fxamacker/cbor/v2/CODE_OF_CONDUCT.md | 153 +- .../fxamacker/cbor/v2/CONTRIBUTING.md | 39 +- vendor/github.com/fxamacker/cbor/v2/README.md | 1137 +--- .../fxamacker/cbor/v2/bytestring.go | 62 + vendor/github.com/fxamacker/cbor/v2/decode.go | 341 +- .../github.com/fxamacker/cbor/v2/diagnose.go | 741 +++ vendor/github.com/fxamacker/cbor/v2/doc.go | 6 +- vendor/github.com/fxamacker/cbor/v2/encode.go | 50 +- .../fxamacker/cbor/v2/simplevalue.go | 17 + vendor/github.com/fxamacker/cbor/v2/stream.go | 120 +- vendor/github.com/fxamacker/cbor/v2/valid.go | 56 +- .../kit/transport/http/intercepting_writer.go | 257 + .../go-kit/kit/transport/http/server.go | 21 +- vendor/github.com/goccy/go-json/.codecov.yml | 32 - vendor/github.com/goccy/go-json/.gitignore | 2 - vendor/github.com/goccy/go-json/.golangci.yml | 83 - vendor/github.com/goccy/go-json/CHANGELOG.md | 425 -- vendor/github.com/goccy/go-json/LICENSE | 21 - vendor/github.com/goccy/go-json/Makefile | 39 - vendor/github.com/goccy/go-json/README.md | 529 -- vendor/github.com/goccy/go-json/color.go | 68 - vendor/github.com/goccy/go-json/decode.go | 263 - .../goccy/go-json/docker-compose.yml | 13 - vendor/github.com/goccy/go-json/encode.go | 326 -- vendor/github.com/goccy/go-json/error.go | 41 - .../internal/decoder/anonymous_field.go | 41 - .../goccy/go-json/internal/decoder/array.go | 176 - .../goccy/go-json/internal/decoder/assign.go | 438 -- .../goccy/go-json/internal/decoder/bool.go | 83 - .../goccy/go-json/internal/decoder/bytes.go | 118 - .../goccy/go-json/internal/decoder/compile.go | 487 -- .../internal/decoder/compile_norace.go | 29 - .../go-json/internal/decoder/compile_race.go | 37 - .../goccy/go-json/internal/decoder/context.go | 254 - .../goccy/go-json/internal/decoder/float.go | 170 - .../goccy/go-json/internal/decoder/func.go | 146 - .../goccy/go-json/internal/decoder/int.go | 246 - .../go-json/internal/decoder/interface.go | 528 -- .../goccy/go-json/internal/decoder/invalid.go | 55 - .../goccy/go-json/internal/decoder/map.go | 280 - .../goccy/go-json/internal/decoder/number.go | 123 - .../goccy/go-json/internal/decoder/option.go | 17 - .../goccy/go-json/internal/decoder/path.go | 670 --- .../goccy/go-json/internal/decoder/ptr.go | 96 - .../goccy/go-json/internal/decoder/slice.go | 380 -- .../goccy/go-json/internal/decoder/stream.go | 556 -- .../goccy/go-json/internal/decoder/string.go | 452 -- .../goccy/go-json/internal/decoder/struct.go | 845 --- .../goccy/go-json/internal/decoder/type.go | 30 - .../goccy/go-json/internal/decoder/uint.go | 194 - .../internal/decoder/unmarshal_json.go | 104 - .../internal/decoder/unmarshal_text.go | 285 - .../internal/decoder/wrapped_string.go | 73 - .../goccy/go-json/internal/encoder/code.go | 1023 ---- .../goccy/go-json/internal/encoder/compact.go | 286 - .../go-json/internal/encoder/compiler.go | 935 ---- .../internal/encoder/compiler_norace.go | 32 - .../go-json/internal/encoder/compiler_race.go | 45 - .../goccy/go-json/internal/encoder/context.go | 105 - .../go-json/internal/encoder/decode_rune.go | 126 - .../goccy/go-json/internal/encoder/encoder.go | 596 -- .../goccy/go-json/internal/encoder/indent.go | 211 - .../goccy/go-json/internal/encoder/int.go | 152 - .../goccy/go-json/internal/encoder/map112.go | 9 - .../goccy/go-json/internal/encoder/map113.go | 9 - .../goccy/go-json/internal/encoder/opcode.go | 752 --- .../goccy/go-json/internal/encoder/option.go | 48 - .../goccy/go-json/internal/encoder/optype.go | 932 ---- .../goccy/go-json/internal/encoder/query.go | 135 - .../goccy/go-json/internal/encoder/string.go | 459 -- .../go-json/internal/encoder/string_table.go | 415 -- .../go-json/internal/encoder/vm/debug_vm.go | 41 - .../goccy/go-json/internal/encoder/vm/hack.go | 9 - .../goccy/go-json/internal/encoder/vm/util.go | 207 - .../goccy/go-json/internal/encoder/vm/vm.go | 4859 ----------------- .../internal/encoder/vm_color/debug_vm.go | 35 - .../go-json/internal/encoder/vm_color/hack.go | 9 - .../go-json/internal/encoder/vm_color/util.go | 274 - .../go-json/internal/encoder/vm_color/vm.go | 4859 ----------------- .../encoder/vm_color_indent/debug_vm.go | 35 - .../internal/encoder/vm_color_indent/util.go | 297 - .../internal/encoder/vm_color_indent/vm.go | 4859 ----------------- .../internal/encoder/vm_indent/debug_vm.go | 35 - .../internal/encoder/vm_indent/hack.go | 9 - .../internal/encoder/vm_indent/util.go | 230 - .../go-json/internal/encoder/vm_indent/vm.go | 4859 ----------------- .../goccy/go-json/internal/errors/error.go | 183 - .../goccy/go-json/internal/runtime/rtype.go | 263 - .../go-json/internal/runtime/struct_field.go | 91 - .../goccy/go-json/internal/runtime/type.go | 100 - vendor/github.com/goccy/go-json/json.go | 371 -- vendor/github.com/goccy/go-json/option.go | 79 - vendor/github.com/goccy/go-json/path.go | 84 - vendor/github.com/goccy/go-json/query.go | 47 - vendor/github.com/google/uuid/.travis.yml | 9 - vendor/github.com/google/uuid/CHANGELOG.md | 10 + vendor/github.com/google/uuid/CONTRIBUTING.md | 16 + vendor/github.com/google/uuid/README.md | 10 +- vendor/github.com/google/uuid/node_js.go | 2 +- vendor/github.com/google/uuid/uuid.go | 10 +- .../klauspost/compress/flate/deflate.go | 29 + .../klauspost/compress/flate/fast_encoder.go | 23 - .../klauspost/compress/flate/level5.go | 398 ++ .../compress/flate/matchlen_amd64.go | 16 + .../klauspost/compress/flate/matchlen_amd64.s | 68 + .../compress/flate/matchlen_generic.go | 33 + .../lestrrat-go/blackmagic/.gitignore | 15 - .../github.com/lestrrat-go/blackmagic/LICENSE | 21 - .../lestrrat-go/blackmagic/README.md | 3 - .../lestrrat-go/blackmagic/blackmagic.go | 54 - .../github.com/lestrrat-go/httpcc/.gitignore | 15 - vendor/github.com/lestrrat-go/httpcc/LICENSE | 21 - .../github.com/lestrrat-go/httpcc/README.md | 35 - .../lestrrat-go/httpcc/directives.go | 117 - .../github.com/lestrrat-go/httpcc/httpcc.go | 310 -- .../github.com/lestrrat-go/httprc/.gitignore | 15 - .../lestrrat-go/httprc/.golangci.yml | 84 - vendor/github.com/lestrrat-go/httprc/Changes | 17 - vendor/github.com/lestrrat-go/httprc/LICENSE | 21 - .../github.com/lestrrat-go/httprc/README.md | 130 - vendor/github.com/lestrrat-go/httprc/cache.go | 172 - .../github.com/lestrrat-go/httprc/fetcher.go | 182 - .../github.com/lestrrat-go/httprc/httprc.go | 22 - .../lestrrat-go/httprc/options.yaml | 119 - .../lestrrat-go/httprc/options_gen.go | 221 - vendor/github.com/lestrrat-go/httprc/queue.go | 459 -- .../lestrrat-go/httprc/whitelist.go | 73 - vendor/github.com/lestrrat-go/iter/LICENSE | 21 - .../lestrrat-go/iter/arrayiter/arrayiter.go | 192 - .../lestrrat-go/iter/mapiter/mapiter.go | 195 - .../lestrrat-go/jwx/v2/.bazelignore | 4 - vendor/github.com/lestrrat-go/jwx/v2/.bazelrc | 1 - .../lestrrat-go/jwx/v2/.bazelversion | 1 - .../github.com/lestrrat-go/jwx/v2/.gitignore | 39 - .../lestrrat-go/jwx/v2/.golangci.yml | 97 - vendor/github.com/lestrrat-go/jwx/v2/BUILD | 58 - vendor/github.com/lestrrat-go/jwx/v2/Changes | 275 - .../lestrrat-go/jwx/v2/Changes-v2.md | 390 -- vendor/github.com/lestrrat-go/jwx/v2/LICENSE | 22 - vendor/github.com/lestrrat-go/jwx/v2/Makefile | 89 - .../github.com/lestrrat-go/jwx/v2/README.md | 252 - .../github.com/lestrrat-go/jwx/v2/WORKSPACE | 46 - .../lestrrat-go/jwx/v2/cert/BUILD.bazel | 32 - .../lestrrat-go/jwx/v2/cert/cert.go | 48 - .../lestrrat-go/jwx/v2/cert/chain.go | 78 - .../github.com/lestrrat-go/jwx/v2/codecov.yml | 2 - vendor/github.com/lestrrat-go/jwx/v2/deps.bzl | 186 - .../github.com/lestrrat-go/jwx/v2/format.go | 102 - .../jwx/v2/formatkind_string_gen.go | 29 - .../jwx/v2/internal/base64/BUILD.bazel | 21 - .../jwx/v2/internal/base64/asmbase64.go | 39 - .../jwx/v2/internal/base64/base64.go | 134 - .../jwx/v2/internal/ecutil/BUILD.bazel | 15 - .../jwx/v2/internal/ecutil/ecutil.go | 110 - .../jwx/v2/internal/iter/BUILD.bazel | 15 - .../jwx/v2/internal/iter/mapiter.go | 36 - .../jwx/v2/internal/json/BUILD.bazel | 19 - .../lestrrat-go/jwx/v2/internal/json/goccy.go | 51 - .../lestrrat-go/jwx/v2/internal/json/json.go | 112 - .../jwx/v2/internal/json/registry.go | 52 - .../jwx/v2/internal/json/stdlib.go | 49 - .../jwx/v2/internal/keyconv/BUILD.bazel | 31 - .../jwx/v2/internal/keyconv/keyconv.go | 177 - .../jwx/v2/internal/pool/BUILD.bazel | 14 - .../lestrrat-go/jwx/v2/internal/pool/pool.go | 61 - .../lestrrat-go/jwx/v2/jwa/BUILD.bazel | 39 - .../lestrrat-go/jwx/v2/jwa/README.md | 3 - .../lestrrat-go/jwx/v2/jwa/compression_gen.go | 101 - .../jwx/v2/jwa/content_encryption_gen.go | 109 - .../lestrrat-go/jwx/v2/jwa/elliptic_gen.go | 112 - .../github.com/lestrrat-go/jwx/v2/jwa/jwa.go | 61 - .../jwx/v2/jwa/key_encryption_gen.go | 140 - .../lestrrat-go/jwx/v2/jwa/key_type_gen.go | 106 - .../lestrrat-go/jwx/v2/jwa/secp2561k.go | 11 - .../lestrrat-go/jwx/v2/jwa/signature_gen.go | 127 - .../lestrrat-go/jwx/v2/jwe/BUILD.bazel | 68 - .../lestrrat-go/jwx/v2/jwe/README.md | 94 - .../lestrrat-go/jwx/v2/jwe/compress.go | 36 - .../lestrrat-go/jwx/v2/jwe/decrypt.go | 306 -- .../lestrrat-go/jwx/v2/jwe/headers.go | 122 - .../lestrrat-go/jwx/v2/jwe/headers_gen.go | 715 --- .../lestrrat-go/jwx/v2/jwe/interface.go | 214 - .../jwx/v2/jwe/internal/aescbc/BUILD.bazel | 21 - .../jwx/v2/jwe/internal/aescbc/aescbc.go | 235 - .../jwx/v2/jwe/internal/cipher/BUILD.bazel | 32 - .../jwx/v2/jwe/internal/cipher/cipher.go | 161 - .../jwx/v2/jwe/internal/cipher/interface.go | 34 - .../jwx/v2/jwe/internal/concatkdf/BUILD.bazel | 24 - .../v2/jwe/internal/concatkdf/concatkdf.go | 66 - .../v2/jwe/internal/content_crypt/BUILD.bazel | 21 - .../internal/content_crypt/content_crypt.go | 43 - .../jwe/internal/content_crypt/interface.go | 20 - .../jwx/v2/jwe/internal/keyenc/BUILD.bazel | 37 - .../jwx/v2/jwe/internal/keyenc/interface.go | 100 - .../jwx/v2/jwe/internal/keyenc/keyenc.go | 660 --- .../jwx/v2/jwe/internal/keygen/BUILD.bazel | 25 - .../jwx/v2/jwe/internal/keygen/interface.go | 72 - .../jwx/v2/jwe/internal/keygen/keygen.go | 185 - .../github.com/lestrrat-go/jwx/v2/jwe/io.go | 33 - .../github.com/lestrrat-go/jwx/v2/jwe/jwe.go | 824 --- .../lestrrat-go/jwx/v2/jwe/key_provider.go | 161 - .../lestrrat-go/jwx/v2/jwe/message.go | 547 -- .../lestrrat-go/jwx/v2/jwe/options.go | 107 - .../lestrrat-go/jwx/v2/jwe/options.yaml | 122 - .../lestrrat-go/jwx/v2/jwe/options_gen.go | 255 - .../lestrrat-go/jwx/v2/jwk/BUILD.bazel | 78 - .../lestrrat-go/jwx/v2/jwk/README.md | 217 - .../lestrrat-go/jwx/v2/jwk/cache.go | 410 -- .../lestrrat-go/jwx/v2/jwk/ecdsa.go | 228 - .../lestrrat-go/jwx/v2/jwk/ecdsa_gen.go | 1181 ---- .../lestrrat-go/jwx/v2/jwk/es256k.go | 14 - .../lestrrat-go/jwx/v2/jwk/fetch.go | 134 - .../lestrrat-go/jwx/v2/jwk/interface.go | 137 - .../lestrrat-go/jwx/v2/jwk/interface_gen.go | 116 - .../github.com/lestrrat-go/jwx/v2/jwk/io.go | 39 - .../github.com/lestrrat-go/jwx/v2/jwk/jwk.go | 729 --- .../lestrrat-go/jwx/v2/jwk/key_ops.go | 58 - .../github.com/lestrrat-go/jwx/v2/jwk/okp.go | 183 - .../lestrrat-go/jwx/v2/jwk/okp_gen.go | 1119 ---- .../lestrrat-go/jwx/v2/jwk/options.go | 38 - .../lestrrat-go/jwx/v2/jwk/options.yaml | 142 - .../lestrrat-go/jwx/v2/jwk/options_gen.go | 274 - .../github.com/lestrrat-go/jwx/v2/jwk/rsa.go | 243 - .../lestrrat-go/jwx/v2/jwk/rsa_gen.go | 1250 ----- .../github.com/lestrrat-go/jwx/v2/jwk/set.go | 338 -- .../lestrrat-go/jwx/v2/jwk/symmetric.go | 60 - .../lestrrat-go/jwx/v2/jwk/symmetric_gen.go | 520 -- .../lestrrat-go/jwx/v2/jwk/usage.go | 30 - .../lestrrat-go/jwx/v2/jwk/whitelist.go | 69 - .../lestrrat-go/jwx/v2/jws/BUILD.bazel | 69 - .../lestrrat-go/jwx/v2/jws/README.md | 111 - .../lestrrat-go/jwx/v2/jws/ecdsa.go | 197 - .../lestrrat-go/jwx/v2/jws/eddsa.go | 73 - .../lestrrat-go/jwx/v2/jws/es256k.go | 12 - .../lestrrat-go/jwx/v2/jws/headers.go | 71 - .../lestrrat-go/jwx/v2/jws/headers_gen.go | 565 -- .../github.com/lestrrat-go/jwx/v2/jws/hmac.go | 77 - .../lestrrat-go/jwx/v2/jws/interface.go | 106 - .../github.com/lestrrat-go/jwx/v2/jws/io.go | 33 - .../github.com/lestrrat-go/jwx/v2/jws/jws.go | 749 --- .../lestrrat-go/jwx/v2/jws/key_provider.go | 276 - .../lestrrat-go/jwx/v2/jws/message.go | 503 -- .../lestrrat-go/jwx/v2/jws/options.go | 204 - .../lestrrat-go/jwx/v2/jws/options.yaml | 167 - .../lestrrat-go/jwx/v2/jws/options_gen.go | 331 -- .../github.com/lestrrat-go/jwx/v2/jws/rsa.go | 142 - .../lestrrat-go/jwx/v2/jws/signer.go | 106 - .../lestrrat-go/jwx/v2/jws/verifier.go | 96 - .../lestrrat-go/jwx/v2/jwt/BUILD.bazel | 65 - .../lestrrat-go/jwx/v2/jwt/README.md | 224 - .../lestrrat-go/jwx/v2/jwt/builder_gen.go | 70 - .../github.com/lestrrat-go/jwx/v2/jwt/http.go | 188 - .../lestrrat-go/jwx/v2/jwt/interface.go | 14 - .../jwx/v2/jwt/internal/types/BUILD.bazel | 32 - .../jwx/v2/jwt/internal/types/date.go | 191 - .../jwx/v2/jwt/internal/types/string.go | 43 - .../github.com/lestrrat-go/jwx/v2/jwt/io.go | 39 - .../github.com/lestrrat-go/jwx/v2/jwt/jwt.go | 470 -- .../lestrrat-go/jwx/v2/jwt/options.go | 303 - .../lestrrat-go/jwx/v2/jwt/options.yaml | 207 - .../lestrrat-go/jwx/v2/jwt/options_gen.go | 383 -- .../lestrrat-go/jwx/v2/jwt/serialize.go | 264 - .../lestrrat-go/jwx/v2/jwt/token_gen.go | 539 -- .../lestrrat-go/jwx/v2/jwt/token_options.go | 78 - .../jwx/v2/jwt/token_options_gen.go | 25 - .../lestrrat-go/jwx/v2/jwt/validate.go | 557 -- vendor/github.com/lestrrat-go/jwx/v2/jwx.go | 44 - .../github.com/lestrrat-go/jwx/v2/options.go | 30 - .../lestrrat-go/jwx/v2/x25519/BUILD.bazel | 24 - .../lestrrat-go/jwx/v2/x25519/x25519.go | 115 - .../github.com/lestrrat-go/option/.gitignore | 15 - vendor/github.com/lestrrat-go/option/LICENSE | 21 - .../github.com/lestrrat-go/option/README.md | 245 - .../github.com/lestrrat-go/option/option.go | 38 - .../mainflux/mainflux/.golangci.yml | 48 +- vendor/github.com/mainflux/mainflux/Makefile | 62 +- .../github.com/mainflux/mainflux/auth.pb.go | 2056 +++++++ .../github.com/mainflux/mainflux/auth.proto | 169 + .../mainflux/mainflux/auth_grpc.pb.go | 650 +++ .../mainflux/mainflux/bootstrap/service.go | 20 +- .../github.com/mainflux/mainflux/config.toml | 8 +- vendor/github.com/mainflux/mainflux/env.go | 26 - .../mainflux/internal/apiutil/errors.go | 9 + .../mainflux/mainflux/logger/exit.go | 3 + .../mainflux/mainflux/pkg/clients/clients.go | 4 +- .../mainflux/mainflux/pkg/clients/page.go | 28 +- .../mainflux/mainflux/pkg/clients/roles.go | 3 + .../mainflux/mainflux/pkg/clients/status.go | 3 + .../mainflux/mainflux/pkg/clients/types.go | 3 + .../mainflux/mainflux/pkg/errors/types.go | 2 + .../mainflux/pkg/messaging/message.pb.go | 2 +- .../mainflux/mainflux/pkg/sdk/go/channels.go | 124 + .../mainflux/mainflux/pkg/sdk/go/groups.go | 77 +- .../mainflux/mainflux/pkg/sdk/go/policies.go | 250 - .../mainflux/mainflux/pkg/sdk/go/requests.go | 18 +- .../mainflux/mainflux/pkg/sdk/go/responses.go | 16 +- .../mainflux/mainflux/pkg/sdk/go/sdk.go | 345 +- .../mainflux/mainflux/pkg/sdk/go/things.go | 50 +- .../mainflux/mainflux/pkg/sdk/go/tokens.go | 3 + .../mainflux/mainflux/pkg/sdk/go/users.go | 57 + .../mainflux/mainflux/users/jwt/doc.go | 6 - .../mainflux/mainflux/users/jwt/jwt.go | 50 - .../mainflux/mainflux/users/jwt/tokens.go | 97 - .../mainflux/users/policies/auth.pb.go | 379 -- .../mainflux/users/policies/auth.proto | 37 - .../mainflux/users/policies/auth_grpc.pb.go | 155 - .../mainflux/mainflux/users/policies/doc.go | 6 - .../mainflux/mainflux/users/policies/page.go | 31 - .../mainflux/users/policies/policies.go | 224 - .../mainflux/users/policies/service.go | 179 - .../github.com/nats-io/nats.go/.golangci.yaml | 3 + vendor/github.com/nats-io/nats.go/.travis.yml | 19 +- vendor/github.com/nats-io/nats.go/README.md | 100 +- vendor/github.com/nats-io/nats.go/context.go | 2 +- vendor/github.com/nats-io/nats.go/enc.go | 14 +- .../nats.go/encoders/builtin/default_enc.go | 4 +- .../nats.go/encoders/builtin/gob_enc.go | 4 +- .../nats.go/encoders/builtin/json_enc.go | 4 +- vendor/github.com/nats-io/nats.go/go_test.mod | 14 +- vendor/github.com/nats-io/nats.go/go_test.sum | 29 +- vendor/github.com/nats-io/nats.go/js.go | 278 +- vendor/github.com/nats-io/nats.go/jserrors.go | 49 +- vendor/github.com/nats-io/nats.go/jsm.go | 136 +- vendor/github.com/nats-io/nats.go/kv.go | 63 +- .../nats-io/nats.go/legacy_jetstream.md | 83 + vendor/github.com/nats-io/nats.go/nats.go | 29 +- vendor/github.com/nats-io/nats.go/netchan.go | 8 +- vendor/github.com/nats-io/nats.go/object.go | 59 +- .../github.com/nats-io/nkeys/.goreleaser.yml | 28 +- vendor/github.com/nats-io/nkeys/nkeys.go | 2 +- vendor/github.com/nats-io/nkeys/strkey.go | 14 +- .../client_golang/prometheus/counter.go | 26 +- .../client_golang/prometheus/desc.go | 28 +- .../prometheus/expvar_collector.go | 2 +- .../client_golang/prometheus/gauge.go | 8 +- .../client_golang/prometheus/histogram.go | 118 +- .../prometheus/internal/difflib.go | 2 +- .../client_golang/prometheus/labels.go | 58 +- .../client_golang/prometheus/metric.go | 3 + .../prometheus/promhttp/instrument_server.go | 9 +- .../client_golang/prometheus/registry.go | 6 +- .../client_golang/prometheus/summary.go | 41 +- .../client_golang/prometheus/value.go | 55 +- .../client_golang/prometheus/vec.go | 106 +- .../prometheus/client_model/go/metrics.pb.go | 350 +- .../prometheus/procfs/Makefile.common | 8 +- vendor/github.com/prometheus/procfs/fs.go | 8 +- .../prometheus/procfs/fs_statfs_notype.go | 4 +- .../prometheus/procfs/fs_statfs_type.go | 4 +- .../prometheus/procfs/mountstats.go | 83 +- vendor/github.com/prometheus/procfs/proc.go | 2 +- .../prometheus/procfs/proc_fdinfo.go | 8 +- .../github.com/prometheus/procfs/proc_maps.go | 20 +- .../github.com/prometheus/procfs/proc_psi.go | 4 +- .../prometheus/procfs/proc_smaps.go | 4 +- .../prometheus/procfs/proc_status.go | 21 +- vendor/github.com/prometheus/procfs/stat.go | 4 + vendor/github.com/prometheus/procfs/thread.go | 6 +- vendor/github.com/segmentio/asm/LICENSE | 21 - .../github.com/segmentio/asm/base64/base64.go | 67 - .../segmentio/asm/base64/base64_amd64.go | 78 - .../segmentio/asm/base64/base64_arm64.go | 42 - .../segmentio/asm/base64/base64_asm.go | 94 - .../segmentio/asm/base64/base64_default.go | 14 - .../segmentio/asm/base64/decode_amd64.go | 9 - .../segmentio/asm/base64/decode_amd64.s | 143 - .../segmentio/asm/base64/decode_arm64.go | 7 - .../segmentio/asm/base64/decode_arm64.s | 203 - .../segmentio/asm/base64/encode_amd64.go | 7 - .../segmentio/asm/base64/encode_amd64.s | 87 - .../segmentio/asm/base64/encode_arm64.go | 6 - .../segmentio/asm/base64/encode_arm64.s | 97 - .../github.com/segmentio/asm/cpu/arm/arm.go | 80 - .../segmentio/asm/cpu/arm64/arm64.go | 74 - vendor/github.com/segmentio/asm/cpu/cpu.go | 22 - .../segmentio/asm/cpu/cpuid/cpuid.go | 32 - .../github.com/segmentio/asm/cpu/x86/x86.go | 76 - .../asm/internal/unsafebytes/unsafebytes.go | 20 - vendor/github.com/subosito/gotenv/.env | 1 - .../github.com/subosito/gotenv/.env.invalid | 1 - vendor/github.com/subosito/gotenv/.gitignore | 4 - .../github.com/subosito/gotenv/.golangci.yaml | 7 - .../github.com/subosito/gotenv/CHANGELOG.md | 68 - vendor/github.com/subosito/gotenv/LICENSE | 21 - vendor/github.com/subosito/gotenv/README.md | 129 - vendor/github.com/subosito/gotenv/gotenv.go | 381 -- vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go | 77 - vendor/golang.org/x/exp/slices/cmp.go | 44 + vendor/golang.org/x/exp/slices/slices.go | 353 +- vendor/golang.org/x/exp/slices/sort.go | 115 +- .../slices/{zsortfunc.go => zsortanyfunc.go} | 154 +- .../golang.org/x/exp/slices/zsortordered.go | 34 +- vendor/golang.org/x/net/http2/Dockerfile | 51 - vendor/golang.org/x/net/http2/Makefile | 3 - vendor/golang.org/x/net/http2/server.go | 86 +- vendor/golang.org/x/net/http2/transport.go | 38 +- vendor/golang.org/x/sys/cpu/cpu.go | 5 +- vendor/golang.org/x/sys/cpu/cpu_riscv64.go | 2 +- vendor/golang.org/x/sys/cpu/cpu_x86.go | 7 + vendor/golang.org/x/sys/cpu/hwcap_linux.go | 4 +- .../sys/internal/unsafeheader/unsafeheader.go | 30 - vendor/golang.org/x/sys/unix/mkerrors.sh | 3 +- vendor/golang.org/x/sys/unix/mmap_nomremap.go | 14 + vendor/golang.org/x/sys/unix/mremap.go | 21 +- vendor/golang.org/x/sys/unix/ptrace_darwin.go | 6 - vendor/golang.org/x/sys/unix/ptrace_ios.go | 6 - vendor/golang.org/x/sys/unix/syscall_aix.go | 17 - vendor/golang.org/x/sys/unix/syscall_bsd.go | 14 - .../golang.org/x/sys/unix/syscall_darwin.go | 236 +- .../x/sys/unix/syscall_darwin_amd64.go | 1 - .../x/sys/unix/syscall_darwin_arm64.go | 1 - .../x/sys/unix/syscall_dragonfly.go | 198 - .../golang.org/x/sys/unix/syscall_freebsd.go | 192 - vendor/golang.org/x/sys/unix/syscall_linux.go | 199 +- .../x/sys/unix/syscall_linux_amd64.go | 2 +- .../x/sys/unix/syscall_linux_arm64.go | 2 +- .../x/sys/unix/syscall_linux_loong64.go | 2 +- .../x/sys/unix/syscall_linux_mips64x.go | 2 +- .../x/sys/unix/syscall_linux_riscv64.go | 13 +- .../golang.org/x/sys/unix/syscall_netbsd.go | 272 +- .../golang.org/x/sys/unix/syscall_openbsd.go | 74 - .../golang.org/x/sys/unix/syscall_solaris.go | 32 - vendor/golang.org/x/sys/unix/syscall_unix.go | 11 + .../x/sys/unix/syscall_zos_s390x.go | 15 - vendor/golang.org/x/sys/unix/zerrors_linux.go | 26 + .../x/sys/unix/zerrors_linux_386.go | 11 + .../x/sys/unix/zerrors_linux_amd64.go | 11 + .../x/sys/unix/zerrors_linux_arm.go | 11 + .../x/sys/unix/zerrors_linux_arm64.go | 11 + .../x/sys/unix/zerrors_linux_loong64.go | 13 + .../x/sys/unix/zerrors_linux_mips.go | 11 + .../x/sys/unix/zerrors_linux_mips64.go | 11 + .../x/sys/unix/zerrors_linux_mips64le.go | 11 + .../x/sys/unix/zerrors_linux_mipsle.go | 11 + .../x/sys/unix/zerrors_linux_ppc.go | 11 + .../x/sys/unix/zerrors_linux_ppc64.go | 11 + .../x/sys/unix/zerrors_linux_ppc64le.go | 11 + .../x/sys/unix/zerrors_linux_riscv64.go | 11 + .../x/sys/unix/zerrors_linux_s390x.go | 11 + .../x/sys/unix/zerrors_linux_sparc64.go | 11 + .../golang.org/x/sys/unix/zsyscall_aix_ppc.go | 22 - .../x/sys/unix/zsyscall_aix_ppc64.go | 22 - .../x/sys/unix/zsyscall_darwin_amd64.go | 40 +- .../x/sys/unix/zsyscall_darwin_amd64.s | 149 - .../x/sys/unix/zsyscall_darwin_arm64.go | 40 +- .../x/sys/unix/zsyscall_darwin_arm64.s | 149 - .../x/sys/unix/zsyscall_dragonfly_amd64.go | 22 - .../x/sys/unix/zsyscall_freebsd_386.go | 22 - .../x/sys/unix/zsyscall_freebsd_amd64.go | 22 - .../x/sys/unix/zsyscall_freebsd_arm.go | 22 - .../x/sys/unix/zsyscall_freebsd_arm64.go | 22 - .../x/sys/unix/zsyscall_freebsd_riscv64.go | 22 - .../x/sys/unix/zsyscall_illumos_amd64.go | 10 +- .../golang.org/x/sys/unix/zsyscall_linux.go | 44 +- .../x/sys/unix/zsyscall_linux_riscv64.go | 16 + .../x/sys/unix/zsyscall_netbsd_386.go | 29 +- .../x/sys/unix/zsyscall_netbsd_amd64.go | 29 +- .../x/sys/unix/zsyscall_netbsd_arm.go | 29 +- .../x/sys/unix/zsyscall_netbsd_arm64.go | 29 +- .../x/sys/unix/zsyscall_openbsd_386.go | 32 +- .../x/sys/unix/zsyscall_openbsd_amd64.go | 22 - .../x/sys/unix/zsyscall_openbsd_arm.go | 32 +- .../x/sys/unix/zsyscall_openbsd_arm64.go | 32 +- .../x/sys/unix/zsyscall_openbsd_mips64.go | 32 +- .../x/sys/unix/zsyscall_openbsd_ppc64.go | 32 +- .../x/sys/unix/zsyscall_openbsd_riscv64.go | 32 +- .../x/sys/unix/zsyscall_solaris_amd64.go | 256 +- .../x/sys/unix/zsyscall_zos_s390x.go | 11 - .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 3 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + vendor/golang.org/x/sys/unix/ztypes_linux.go | 28 +- .../x/sys/unix/ztypes_linux_riscv64.go | 27 + .../golang.org/x/sys/windows/exec_windows.go | 89 +- .../x/sys/windows/security_windows.go | 21 +- .../x/sys/windows/syscall_windows.go | 57 +- .../golang.org/x/sys/windows/types_windows.go | 7 + .../x/sys/windows/zsyscall_windows.go | 54 +- vendor/golang.org/x/text/unicode/norm/trie.go | 2 +- .../genproto/{ => googleapis/rpc}/LICENSE | 0 vendor/google.golang.org/grpc/README.md | 58 +- .../grpc/attributes/attributes.go | 59 +- .../grpc/balancer/balancer.go | 47 +- .../grpc/balancer/base/balancer.go | 22 +- .../grpc/balancer_conn_wrappers.go | 75 +- .../grpc_binarylog_v1/binarylog.pb.go | 2 +- vendor/google.golang.org/grpc/call.go | 11 +- vendor/google.golang.org/grpc/clientconn.go | 236 +- vendor/google.golang.org/grpc/codec.go | 8 +- vendor/google.golang.org/grpc/dialoptions.go | 37 + .../grpc/encoding/encoding.go | 4 +- .../grpc/encoding/proto/proto.go | 4 +- .../grpc/grpclog/component.go | 40 +- .../google.golang.org/grpc/grpclog/grpclog.go | 30 +- .../google.golang.org/grpc/grpclog/logger.go | 30 +- .../grpc/grpclog/loggerv2.go | 56 +- vendor/google.golang.org/grpc/interceptor.go | 12 +- .../balancer/gracefulswitch/gracefulswitch.go | 59 +- .../grpc/internal/balancerload/load.go | 4 +- .../grpc/internal/binarylog/method_logger.go | 4 +- .../grpc/internal/buffer/unbounded.go | 18 +- .../grpc/internal/channelz/funcs.go | 69 +- .../grpc/internal/channelz/logging.go | 12 +- .../grpc/internal/channelz/types.go | 5 + .../grpc/internal/channelz/util_linux.go | 2 +- .../grpc/internal/channelz/util_nonlinux.go | 2 +- .../grpc/internal/credentials/credentials.go | 8 +- .../grpc/internal/envconfig/envconfig.go | 12 +- .../grpc/internal/grpclog/grpclog.go | 40 +- .../grpc/internal/grpclog/prefixLogger.go | 8 +- .../grpc/internal/grpcrand/grpcrand.go | 7 + .../internal/grpcsync/callback_serializer.go | 54 +- .../grpc/internal/grpcsync/pubsub.go | 121 + .../grpc/{ => internal/idle}/idle.go | 188 +- .../grpc/internal/internal.go | 45 +- .../grpc/internal/metadata/metadata.go | 2 +- .../grpc/internal/pretty/pretty.go | 2 +- .../grpc/internal/resolver/config_selector.go | 4 +- .../internal/resolver/dns/dns_resolver.go | 74 +- .../grpc/internal/status/status.go | 8 +- .../grpc/internal/transport/controlbuf.go | 16 +- .../grpc/internal/transport/http2_client.go | 45 +- .../grpc/internal/transport/http2_server.go | 19 +- .../grpc/internal/transport/http_util.go | 59 +- .../grpc/internal/transport/transport.go | 17 +- .../google.golang.org/grpc/picker_wrapper.go | 34 +- vendor/google.golang.org/grpc/pickfirst.go | 88 +- vendor/google.golang.org/grpc/preloader.go | 2 +- vendor/google.golang.org/grpc/resolver/map.go | 10 +- .../grpc/resolver/resolver.go | 84 +- .../grpc/resolver_conn_wrapper.go | 10 +- vendor/google.golang.org/grpc/rpc_util.go | 44 +- vendor/google.golang.org/grpc/server.go | 164 +- .../grpc/shared_buffer_pool.go | 154 + vendor/google.golang.org/grpc/stats/stats.go | 14 +- .../google.golang.org/grpc/status/status.go | 39 +- vendor/google.golang.org/grpc/stream.go | 130 +- vendor/google.golang.org/grpc/trace.go | 6 +- vendor/google.golang.org/grpc/version.go | 2 +- vendor/google.golang.org/grpc/vet.sh | 7 +- vendor/modules.txt | 120 +- 611 files changed, 15468 insertions(+), 82312 deletions(-) delete mode 100644 ui/web/template/channelconn.html create mode 100644 ui/web/template/channelgroups.html create mode 100644 ui/web/template/channelthings.html create mode 100644 ui/web/template/channelusers.html create mode 100644 ui/web/template/groupchannels.html delete mode 100644 ui/web/template/groupconn.html create mode 100644 ui/web/template/groupusers.html create mode 100644 ui/web/template/thingchannels.html delete mode 100644 ui/web/template/thingconn.html delete mode 100644 ui/web/template/thingspolicies.html create mode 100644 ui/web/template/thingusers.html create mode 100644 ui/web/template/userchannels.html create mode 100644 ui/web/template/usergroups.html delete mode 100644 ui/web/template/userspolicies.html create mode 100644 ui/web/template/userthings.html delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/LICENSE delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go delete mode 100644 vendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go create mode 100644 vendor/github.com/eclipse/paho.mqtt.golang/backoff.go delete mode 100644 vendor/github.com/fxamacker/cbor/v2/CBOR_BENCHMARKS.md delete mode 100644 vendor/github.com/fxamacker/cbor/v2/CBOR_GOLANG.md create mode 100644 vendor/github.com/fxamacker/cbor/v2/bytestring.go create mode 100644 vendor/github.com/fxamacker/cbor/v2/diagnose.go create mode 100644 vendor/github.com/fxamacker/cbor/v2/simplevalue.go create mode 100644 vendor/github.com/go-kit/kit/transport/http/intercepting_writer.go delete mode 100644 vendor/github.com/goccy/go-json/.codecov.yml delete mode 100644 vendor/github.com/goccy/go-json/.gitignore delete mode 100644 vendor/github.com/goccy/go-json/.golangci.yml delete mode 100644 vendor/github.com/goccy/go-json/CHANGELOG.md delete mode 100644 vendor/github.com/goccy/go-json/LICENSE delete mode 100644 vendor/github.com/goccy/go-json/Makefile delete mode 100644 vendor/github.com/goccy/go-json/README.md delete mode 100644 vendor/github.com/goccy/go-json/color.go delete mode 100644 vendor/github.com/goccy/go-json/decode.go delete mode 100644 vendor/github.com/goccy/go-json/docker-compose.yml delete mode 100644 vendor/github.com/goccy/go-json/encode.go delete mode 100644 vendor/github.com/goccy/go-json/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/array.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/assign.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bool.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bytes.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/float.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/func.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/interface.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/invalid.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/map.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/number.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/path.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/ptr.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/slice.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/stream.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/struct.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/type.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/uint.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/code.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compact.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/decode_rune.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/encoder.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/indent.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map112.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map113.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/opcode.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/optype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/query.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/string_table.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/errors/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/rtype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/struct_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/type.go delete mode 100644 vendor/github.com/goccy/go-json/json.go delete mode 100644 vendor/github.com/goccy/go-json/option.go delete mode 100644 vendor/github.com/goccy/go-json/path.go delete mode 100644 vendor/github.com/goccy/go-json/query.go delete mode 100644 vendor/github.com/google/uuid/.travis.yml create mode 100644 vendor/github.com/google/uuid/CHANGELOG.md create mode 100644 vendor/github.com/klauspost/compress/flate/matchlen_amd64.go create mode 100644 vendor/github.com/klauspost/compress/flate/matchlen_amd64.s create mode 100644 vendor/github.com/klauspost/compress/flate/matchlen_generic.go delete mode 100644 vendor/github.com/lestrrat-go/blackmagic/.gitignore delete mode 100644 vendor/github.com/lestrrat-go/blackmagic/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/blackmagic/README.md delete mode 100644 vendor/github.com/lestrrat-go/blackmagic/blackmagic.go delete mode 100644 vendor/github.com/lestrrat-go/httpcc/.gitignore delete mode 100644 vendor/github.com/lestrrat-go/httpcc/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/httpcc/README.md delete mode 100644 vendor/github.com/lestrrat-go/httpcc/directives.go delete mode 100644 vendor/github.com/lestrrat-go/httpcc/httpcc.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/.gitignore delete mode 100644 vendor/github.com/lestrrat-go/httprc/.golangci.yml delete mode 100644 vendor/github.com/lestrrat-go/httprc/Changes delete mode 100644 vendor/github.com/lestrrat-go/httprc/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/httprc/README.md delete mode 100644 vendor/github.com/lestrrat-go/httprc/cache.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/fetcher.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/httprc.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/options.yaml delete mode 100644 vendor/github.com/lestrrat-go/httprc/options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/queue.go delete mode 100644 vendor/github.com/lestrrat-go/httprc/whitelist.go delete mode 100644 vendor/github.com/lestrrat-go/iter/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/iter/arrayiter/arrayiter.go delete mode 100644 vendor/github.com/lestrrat-go/iter/mapiter/mapiter.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/.bazelignore delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/.bazelrc delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/.bazelversion delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/.gitignore delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/.golangci.yml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/BUILD delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/Changes delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/Changes-v2.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/Makefile delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/WORKSPACE delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/cert/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/cert/cert.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/cert/chain.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/codecov.yml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/deps.bzl delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/format.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/formatkind_string_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/base64/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/base64/asmbase64.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/base64/base64.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/ecutil/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/ecutil/ecutil.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/iter/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/iter/mapiter.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/json/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/json/goccy.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/json/json.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/json/registry.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/json/stdlib.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/keyconv/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/keyconv/keyconv.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/pool/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/internal/pool/pool.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/compression_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/content_encryption_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/elliptic_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/jwa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/key_encryption_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/key_type_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/secp2561k.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwa/signature_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/compress.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/decrypt.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/headers.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/headers_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/aescbc/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/aescbc/aescbc.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/cipher/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/cipher/cipher.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/cipher/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/concatkdf/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/concatkdf/concatkdf.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/content_crypt/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/content_crypt/content_crypt.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/content_crypt/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keyenc/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keyenc/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keyenc/keyenc.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keygen/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keygen/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/internal/keygen/keygen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/io.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/jwe.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/key_provider.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/message.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/options.yaml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwe/options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/cache.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/ecdsa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/ecdsa_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/es256k.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/fetch.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/interface_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/io.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/jwk.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/key_ops.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/okp.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/okp_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/options.yaml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/rsa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/rsa_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/set.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/symmetric.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/symmetric_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/usage.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwk/whitelist.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/ecdsa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/eddsa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/es256k.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/headers.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/headers_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/hmac.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/io.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/jws.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/key_provider.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/message.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/options.yaml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/rsa.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/signer.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jws/verifier.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/README.md delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/builder_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/http.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/interface.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/internal/types/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/internal/types/date.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/internal/types/string.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/io.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/jwt.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/options.yaml delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/serialize.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/token_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/token_options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/token_options_gen.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwt/validate.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/jwx.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/options.go delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/x25519/BUILD.bazel delete mode 100644 vendor/github.com/lestrrat-go/jwx/v2/x25519/x25519.go delete mode 100644 vendor/github.com/lestrrat-go/option/.gitignore delete mode 100644 vendor/github.com/lestrrat-go/option/LICENSE delete mode 100644 vendor/github.com/lestrrat-go/option/README.md delete mode 100644 vendor/github.com/lestrrat-go/option/option.go create mode 100644 vendor/github.com/mainflux/mainflux/auth.pb.go create mode 100644 vendor/github.com/mainflux/mainflux/auth.proto create mode 100644 vendor/github.com/mainflux/mainflux/auth_grpc.pb.go delete mode 100644 vendor/github.com/mainflux/mainflux/env.go delete mode 100644 vendor/github.com/mainflux/mainflux/pkg/sdk/go/policies.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/jwt/doc.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/jwt/jwt.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/jwt/tokens.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/auth.pb.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/auth.proto delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/auth_grpc.pb.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/doc.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/page.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/policies.go delete mode 100644 vendor/github.com/mainflux/mainflux/users/policies/service.go create mode 100644 vendor/github.com/nats-io/nats.go/legacy_jetstream.md delete mode 100644 vendor/github.com/segmentio/asm/LICENSE delete mode 100644 vendor/github.com/segmentio/asm/base64/base64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/base64_amd64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/base64_arm64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/base64_asm.go delete mode 100644 vendor/github.com/segmentio/asm/base64/base64_default.go delete mode 100644 vendor/github.com/segmentio/asm/base64/decode_amd64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/decode_amd64.s delete mode 100644 vendor/github.com/segmentio/asm/base64/decode_arm64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/decode_arm64.s delete mode 100644 vendor/github.com/segmentio/asm/base64/encode_amd64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/encode_amd64.s delete mode 100644 vendor/github.com/segmentio/asm/base64/encode_arm64.go delete mode 100644 vendor/github.com/segmentio/asm/base64/encode_arm64.s delete mode 100644 vendor/github.com/segmentio/asm/cpu/arm/arm.go delete mode 100644 vendor/github.com/segmentio/asm/cpu/arm64/arm64.go delete mode 100644 vendor/github.com/segmentio/asm/cpu/cpu.go delete mode 100644 vendor/github.com/segmentio/asm/cpu/cpuid/cpuid.go delete mode 100644 vendor/github.com/segmentio/asm/cpu/x86/x86.go delete mode 100644 vendor/github.com/segmentio/asm/internal/unsafebytes/unsafebytes.go delete mode 100644 vendor/github.com/subosito/gotenv/.env delete mode 100644 vendor/github.com/subosito/gotenv/.env.invalid delete mode 100644 vendor/github.com/subosito/gotenv/.gitignore delete mode 100644 vendor/github.com/subosito/gotenv/.golangci.yaml delete mode 100644 vendor/github.com/subosito/gotenv/CHANGELOG.md delete mode 100644 vendor/github.com/subosito/gotenv/LICENSE delete mode 100644 vendor/github.com/subosito/gotenv/README.md delete mode 100644 vendor/github.com/subosito/gotenv/gotenv.go delete mode 100644 vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go create mode 100644 vendor/golang.org/x/exp/slices/cmp.go rename vendor/golang.org/x/exp/slices/{zsortfunc.go => zsortanyfunc.go} (64%) delete mode 100644 vendor/golang.org/x/net/http2/Dockerfile delete mode 100644 vendor/golang.org/x/net/http2/Makefile delete mode 100644 vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go create mode 100644 vendor/golang.org/x/sys/unix/mmap_nomremap.go rename vendor/google.golang.org/genproto/{ => googleapis/rpc}/LICENSE (100%) create mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go rename vendor/google.golang.org/grpc/{ => internal/idle}/idle.go (61%) create mode 100644 vendor/google.golang.org/grpc/shared_buffer_pool.go diff --git a/cmd/ui/main.go b/cmd/ui/main.go index 9344b266..67b270ed 100644 --- a/cmd/ui/main.go +++ b/cmd/ui/main.go @@ -23,13 +23,13 @@ import ( type config struct { LogLevel string `env:"MF_UI_LOG_LEVEL" envDefault:"info"` - Port string `env:"MF_UI_PORT" envDefault:"9090"` + Port string `env:"MF_UI_PORT" envDefault:"9095"` InstanceID string `env:"MF_UI_INSTANCE_ID" envDefault:""` HTTPAdapterURL string `env:"MF_HTTP_ADAPTER_URL" envDefault:"http://localhost:8008"` ReaderURL string `env:"MF_READER_URL" envDefault:""` ThingsURL string `env:"MF_THINGS_URL" envDefault:"http://localhost:9000"` UsersURL string `env:"MF_USERS_URL" envDefault:"http://localhost:9002"` - HostURL string `env:"MF_UI_HOST_URL" envDefault:"http://localhost:9090"` + HostURL string `env:"MF_UI_HOST_URL" envDefault:"http://localhost:9095"` BootstrapURL string `env:"MF_BOOTSTRAP_URL" envDefault:"http://localhost:9013"` MsgContentType sdk.ContentType `env:"MF_CONTENT-TYPE" envDefault:"application/senml+json"` TLSVerification bool `env:"MF_VERIFICATION_TLS" envDefault:"false"` diff --git a/docker/.env b/docker/.env index e81fd982..19f6a377 100644 --- a/docker/.env +++ b/docker/.env @@ -2,7 +2,7 @@ ## UI MF_UI_LOG_LEVEL=debug -MF_UI_PORT=9090 +MF_UI_PORT=9095 MF_HTTP_ADAPTER_URL=http://localhost:8008 MF_READER_URL= MF_THINGS_URL=http://localhost:9000 @@ -10,7 +10,7 @@ MF_USERS_URL=http://localhost:9002 MF_VERIFICATION_TLS=false MF_BOOTSTRAP_URL=http://localhost:9013 MF_UI_INSTANCE_ID= -MF_UI_HOST_URL=http://localhost:9090 +MF_UI_HOST_URL=http://localhost:9095 # Docker image tag MF_RELEASE_TAG=latest diff --git a/go.mod b/go.mod index 9a4962e2..d7b2d751 100644 --- a/go.mod +++ b/go.mod @@ -4,58 +4,48 @@ go 1.21 require ( github.com/caarlos0/env/v9 v9.0.0 - github.com/go-kit/kit v0.12.0 + github.com/go-kit/kit v0.13.0 github.com/go-zoo/bone v1.3.0 github.com/mainflux/agent v0.11.1-0.20230724130550-0cd3f4c8c27c - github.com/mainflux/mainflux v0.0.0-20230825135111-320921a63e54 - github.com/prometheus/client_golang v1.16.0 - golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 - golang.org/x/sync v0.3.0 - google.golang.org/grpc v1.56.1 + github.com/mainflux/mainflux v0.0.0-20231021215047-ab832aff1b52 + github.com/prometheus/client_golang v1.17.0 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d + golang.org/x/sync v0.4.0 + google.golang.org/grpc v1.58.3 ) require ( github.com/creack/pty v1.1.18 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/edgexfoundry/go-mod-core-contracts v0.1.70 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/klauspost/compress v1.16.7 // indirect - github.com/lestrrat-go/blackmagic v1.0.1 // indirect - github.com/lestrrat-go/httpcc v1.0.1 // indirect - github.com/lestrrat-go/httprc v1.0.4 // indirect - github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.11 // indirect - github.com/lestrrat-go/option v1.0.1 // indirect + github.com/klauspost/compress v1.17.0 // indirect github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb // indirect - github.com/nats-io/nats.go v1.27.1 // indirect - github.com/nats-io/nkeys v0.4.4 // indirect + github.com/nats-io/nats.go v1.30.2 // indirect + github.com/nats-io/nkeys v0.4.5 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/segmentio/asm v1.2.0 // indirect - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/eclipse/paho.mqtt.golang v1.4.2 - github.com/fxamacker/cbor/v2 v2.4.0 // indirect + github.com/eclipse/paho.mqtt.golang v1.4.3 + github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/mainflux/senml v1.5.0 github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.0 // indirect - github.com/subosito/gotenv v1.4.2 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/sys v0.10.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + golang.org/x/sys v0.13.0 // indirect google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index 4b89abd1..75b2af3a 100644 --- a/go.sum +++ b/go.sum @@ -13,27 +13,26 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4= -github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik= +github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= github.com/edgexfoundry/go-mod-core-contracts v0.1.70 h1:MYqxk52m5J37IlNRI0NxJGEtIx+1qdPp1pdYcMYIuug= github.com/edgexfoundry/go-mod-core-contracts v0.1.70/go.mod h1:Bt+lYZeV02ndr/Jr6wnA3em2J+VTzZ1c0KVtqkNKdpg= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fxamacker/cbor/v2 v2.2.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88= -github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= +github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= +github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= +github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= +github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs= github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -50,8 +49,6 @@ github.com/go-playground/validator/v10 v10.3.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GO github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-zoo/bone v1.3.0 h1:PY6sHq37FnQhj+4ZyqFIzJQHvrrGx0GEc3vTZZC/OsI= github.com/go-zoo/bone v1.3.0/go.mod h1:HI3Lhb7G3UQcAwEhOJ2WyNcsFtQX1WYHa0Hl4OBbhW8= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -62,9 +59,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= @@ -81,12 +77,12 @@ github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 h1:UpiO20jno/eV1eVZcxqWnU github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= -github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-sockaddr v1.0.5 h1:dvk7TIXCZpmfOlM+9mlcrWmWjw/wlKT+VDq2wMvfPJU= +github.com/hashicorp/go-sockaddr v1.0.5/go.mod h1:uoUUmtwU7n9Dv3O4SNLeFvg0SxQ3lyjsj6+CCykpaxI= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/vault/api v1.9.2 h1:YjkZLJ7K3inKgMZ0wzCU9OHqc+UqMQyXsPXnf3Cl2as= -github.com/hashicorp/vault/api v1.9.2/go.mod h1:jo5Y/ET+hNyz+JnKDt8XLAdKs+AM0G5W0Vp1IrFI8N8= +github.com/hashicorp/vault/api v1.10.0 h1:/US7sIjWN6Imp4o/Rj1Ce2Nr5bki/AXi9vAW3p2tOJQ= +github.com/hashicorp/vault/api v1.10.0/go.mod h1:jo5Y/ET+hNyz+JnKDt8XLAdKs+AM0G5W0Vp1IrFI8N8= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= @@ -95,33 +91,20 @@ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v5 v5.4.1 h1:oKfB/FhuVtit1bBM3zNRRsZ925ZkMN3HXL+LgLUM9lE= -github.com/jackc/pgx/v5 v5.4.1/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY= +github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY= +github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= -github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= -github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= -github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= -github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= -github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= -github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= -github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= -github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.0.11 h1:ViHMnaMeaO0qV16RZWBHM7GTrAnX2aFLVKofc7FuKLQ= -github.com/lestrrat-go/jwx/v2 v2.0.11/go.mod h1:ZtPtMFlrfDrH2Y0iwfa3dRFn8VzwBrB+cyrm3IBWdDg= -github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= -github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= -github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/mainflux/agent v0.11.1-0.20230724130550-0cd3f4c8c27c h1:qDlZcB6dQjRk/vrTD3TOWoMIGQGA8BskCvuYp1yVMu8= github.com/mainflux/agent v0.11.1-0.20230724130550-0cd3f4c8c27c/go.mod h1:P3Vcibeywrzbu4B72ZRX2AdZDUW1oJF2ll3qwr8hW+c= github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb h1:+Zz1+/lX3bmt2AWyJHG2yVsJ7vqa0Q2XIYagG1dHj5c= github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb/go.mod h1:speJE1lnq2emg5o4DqEoOe6nOgFRd0AEYSBBV2bCGKg= -github.com/mainflux/mainflux v0.0.0-20230825135111-320921a63e54 h1:xMHDO//keCNeierCOJu1aH8p3cw7ic9JiWtnchHc9qs= -github.com/mainflux/mainflux v0.0.0-20230825135111-320921a63e54/go.mod h1:cHi+VUm+VST3OaROF0W34pqtr7DHOhrjJ3PDNBTI5W4= +github.com/mainflux/mainflux v0.0.0-20231021215047-ab832aff1b52 h1:FtOhk1e6z/r9moTL5Yai0SSlMGshto0jJiSePhG1NhA= +github.com/mainflux/mainflux v0.0.0-20231021215047-ab832aff1b52/go.mod h1:CUh9lZeBhrEvxmUoXb3flcdh8Zj3l/24SsKS5afUIN4= github.com/mainflux/senml v1.5.0 h1:GAd1y1eMohfa6sVYcr2iQfVfkkh9l/q7B1TWF5L68xs= github.com/mainflux/senml v1.5.0/go.mod h1:SMX76mM5yenjLVjZOM27+njCGkP+AA64O46nRQiBRlE= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -132,119 +115,74 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/nats-io/jwt/v2 v2.0.3 h1:i/O6cmIsjpcQyWDYNcq2JyZ3/VTF8SJ4JWluI5OhpvI= -github.com/nats-io/jwt/v2 v2.0.3/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= -github.com/nats-io/nats-server/v2 v2.5.0 h1:wsnVaaXH9VRSg+A2MVg5Q727/CqxnmPLGFQ3YZYKTQg= -github.com/nats-io/nats-server/v2 v2.5.0/go.mod h1:Kj86UtrXAL6LwYRA6H4RqzkHhK0Vcv2ZnKD5WbQ1t3g= -github.com/nats-io/nats.go v1.27.1 h1:OuYnal9aKVSnOzLQIzf7554OXMCG7KbaTkCSBHRcSoo= -github.com/nats-io/nats.go v1.27.1/go.mod h1:XpbWUlOElGwTYbMR7imivs7jJj9GtK7ypv321Wp6pjc= -github.com/nats-io/nkeys v0.4.4 h1:xvBJ8d69TznjcQl9t6//Q5xXuVhyYiSos6RPtvQNTwA= -github.com/nats-io/nkeys v0.4.4/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64= +github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a h1:lem6QCvxR0Y28gth9P+wV2K/zYUUAkJ+55U8cpS0p5I= +github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k= +github.com/nats-io/nats-server/v2 v2.8.4 h1:0jQzze1T9mECg8YZEl8+WYUXb9JKluJfCBriPUtluB4= +github.com/nats-io/nats-server/v2 v2.8.4/go.mod h1:8zZa+Al3WsESfmgSs98Fi06dRWLH5Bnq90m5bKD/eT4= +github.com/nats-io/nats.go v1.30.2 h1:aloM0TGpPorZKQhbAkdCzYDj+ZmsJDyeo3Gkbr72NuY= +github.com/nats-io/nats.go v1.30.2/go.mod h1:dcfhUgmQNN4GJEfIb2f9R7Fow+gzBF4emzDHrVBd5qM= +github.com/nats-io/nkeys v0.4.5 h1:Zdz2BUlFm4fJlierwvGK+yl20IAKUm7eV6AAZXEhkPk= +github.com/nats-io/nkeys v0.4.5/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= -github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA= -github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc= -github.com/rubenv/sql-migrate v1.5.1 h1:WsZo4jPQfjmddDTh/suANP2aKPA7/ekN0LzuuajgQEo= -github.com/rubenv/sql-migrate v1.5.1/go.mod h1:H38GW8Vqf8F0Su5XignRyaRcbXbJunSWxs+kmzlg0Is= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo= +github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc= +github.com/rubenv/sql-migrate v1.5.2 h1:bMDqOnrJVV/6JQgQ/MxOpU+AdO8uzYYA/TxFUBzFtS0= +github.com/rubenv/sql-migrate v1.5.2/go.mod h1:H38GW8Vqf8F0Su5XignRyaRcbXbJunSWxs+kmzlg0Is= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= -github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= +github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= -github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 h1:pginetY7+onl4qN1vl0xW/V/v6OBZ0vVdH+esuJgvmM= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0/go.mod h1:XiYsayHc36K3EByOO6nbAXnAWbrUxdjUROCEeeROOH8= -go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= -go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= -go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= -go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= -go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= -go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= +go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= +go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= +go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= +go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= -google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a h1:a2MQQVoTo96JC9PMGtGBymLp7+/RzpFc2yX/9WfFg1c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= @@ -252,6 +190,5 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/ui/api/endpoint.go b/ui/api/endpoint.go index ac5f6e9b..1ffcc5db 100644 --- a/ui/api/endpoint.go +++ b/ui/api/endpoint.go @@ -55,6 +55,86 @@ func loginEndpoint(svc ui.Service) endpoint.Endpoint { } } +func logoutEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, _ interface{}) (interface{}, error) { + if err := svc.Logout(); err != nil { + return nil, err + } + + cookies := []*http.Cookie{ + { + Name: "token", + Value: "", + Path: "/", + MaxAge: -1, + HttpOnly: true, + }, + { + Name: "refresh_token", + Value: "", + Path: "/", + MaxAge: -1, + HttpOnly: true, + }, + } + return uiRes{ + code: http.StatusFound, + cookies: cookies, + headers: map[string]string{"Location": "/login"}, + }, nil + } +} + +func passwordResetRequestEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(passwordResetRequestReq) + if err := req.validate(); err != nil { + return nil, err + } + + if err := svc.PasswordResetRequest(req.Email); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": "/login"}, + }, nil + } +} + +func passwordResetEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(passwordResetReq) + if err := req.validate(); err != nil { + return nil, err + } + + if err := svc.PasswordReset(req.token, req.Password, req.ConfirmPassword); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": "/login"}, + }, nil + } +} + +func showPasswordResetEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, _ interface{}) (interface{}, error) { + res, err := svc.ShowPasswordReset() + if err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusOK, + html: res, + }, nil + } +} + func showUpdatePasswordEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(showUpdatePasswordReq) @@ -192,86 +272,6 @@ func refreshTokenEndpoint(svc ui.Service) endpoint.Endpoint { } } -func logoutEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, _ interface{}) (interface{}, error) { - if err := svc.Logout(); err != nil { - return nil, err - } - - cookies := []*http.Cookie{ - { - Name: "token", - Value: "", - Path: "/", - MaxAge: -1, - HttpOnly: true, - }, - { - Name: "refresh_token", - Value: "", - Path: "/", - MaxAge: -1, - HttpOnly: true, - }, - } - return uiRes{ - code: http.StatusFound, - cookies: cookies, - headers: map[string]string{"Location": "/login"}, - }, nil - } -} - -func passwordResetRequestEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(passwordResetRequestReq) - if err := req.validate(); err != nil { - return nil, err - } - - if err := svc.PasswordResetRequest(req.Email); err != nil { - return nil, err - } - - return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": "/login"}, - }, nil - } -} - -func passwordResetEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(passwordResetReq) - if err := req.validate(); err != nil { - return nil, err - } - - if err := svc.PasswordReset(req.token, req.Password, req.ConfirmPassword); err != nil { - return nil, err - } - - return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": "/login"}, - }, nil - } -} - -func showPasswordResetEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, _ interface{}) (interface{}, error) { - res, err := svc.ShowPasswordReset() - if err != nil { - return nil, err - } - - return uiRes{ - code: http.StatusOK, - html: res, - }, nil - } -} - func createUserEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(createUserReq) @@ -465,6 +465,146 @@ func disableUserEndpoint(svc ui.Service) endpoint.Endpoint { } } +func listUserGroupsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) + + res, err := svc.ListUserGroups(req.token, req.id, req.page, req.limit) + if err != nil { + return nil, err + } + + return uiRes{ + html: res, + code: http.StatusOK, + }, nil + } +} + +func listUserThingsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) + + res, err := svc.ListUserThings(req.token, req.id, req.page, req.limit) + if err != nil { + return nil, err + } + + return uiRes{ + html: res, + code: http.StatusOK, + }, nil + } +} + +func listUserChannelsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) + + res, err := svc.ListUserChannels(req.token, req.id, req.page, req.limit) + if err != nil { + return nil, err + } + + return uiRes{ + html: res, + code: http.StatusOK, + }, nil + } +} + +func AddChannelToUserEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserToChannelReq) + if err := req.validate(); err != nil { + return nil, err + } + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.AddUserToChannel(req.token, req.ChannelID, userRelation); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": usersEndpoint + "/" + req.UserID + channelsEndpoint}, + }, nil + } +} + +func RemoveChannelFromUserEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserToChannelReq) + if err := req.validate(); err != nil { + return nil, err + } + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.RemoveUserFromChannel(req.token, req.ChannelID, userRelation); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": usersEndpoint + "/" + req.UserID + channelsEndpoint}, + }, nil + } +} + +func assignGroupEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(assignReq) + if err := req.validate(); err != nil { + return nil, err + } + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.Assign(req.token, req.GroupID, userRelation); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": usersEndpoint + "/" + req.UserID + groupsEndpoint}, + }, nil + } +} + +func unassignGroupEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(assignReq) + if err := req.validate(); err != nil { + return nil, err + } + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.Unassign(req.token, req.GroupID, userRelation); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": usersEndpoint + "/" + req.UserID + groupsEndpoint}, + }, nil + } +} + func createThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(createThingReq) @@ -472,7 +612,7 @@ func createThingEndpoint(svc ui.Service) endpoint.Endpoint { return nil, err } - if err := svc.CreateThings(req.token, req.Thing); err != nil { + if err := svc.CreateThing(req.Thing, req.token); err != nil { return nil, err } @@ -610,6 +750,28 @@ func updateThingSecretEndpoint(svc ui.Service) endpoint.Endpoint { } } +func updateThingOwnerEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(updateThingOwnerReq) + if err := req.validate(); err != nil { + return nil, err + } + + thing := sdk.Thing{ + ID: req.id, + Owner: req.Owner, + } + if err := svc.UpdateThingOwner(req.token, thing); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": thingsEndpoint + "/" + req.id}, + }, nil + } +} + func enableThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(updateThingStatusReq) @@ -646,79 +808,76 @@ func disableThingEndpoint(svc ui.Service) endpoint.Endpoint { } } -func updateThingOwnerEndpoint(svc ui.Service) endpoint.Endpoint { +func shareThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updateThingOwnerReq) + req := request.(shareThingReq) if err := req.validate(); err != nil { return nil, err } - thing := sdk.Thing{ - ID: req.id, - Owner: req.Owner, + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, } - if err := svc.UpdateThingOwner(req.token, thing); err != nil { + + if err := svc.ShareThing(req.token, req.ThingID, userRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": thingsEndpoint + "/" + req.id}, + headers: map[string]string{"Location": thingsEndpoint + "/" + req.ThingID + usersEndpoint}, }, nil } } -func createChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func unshareThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(createChannelReq) + req := request.(shareThingReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.CreateChannels(req.token, req.Channel); err != nil { + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.UnshareThing(req.token, req.ThingID, userRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint}, + headers: map[string]string{"Location": thingsEndpoint + "/" + req.ThingID + usersEndpoint}, }, nil } } -func createChannelsEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(createChannelsReq) - if err := req.validate(); err != nil { - return nil, err - } +func listThingUsersEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) - channels := []sdk.Channel{} - for i := range req.Names { - ch := sdk.Channel{ - Name: req.Names[i], - } - channels = append(channels, ch) - } - if err := svc.CreateChannels(req.token, channels...); err != nil { + res, err := svc.ListThingUsers(req.token, req.id, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint}, + html: res, + code: http.StatusOK, }, nil } } -func viewChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func listChannelsByThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(viewResourceReq) + req := request.(listEntityByIDReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ViewChannel(req.token, req.id) + res, err := svc.ListChannelsByThing(req.token, req.id, req.page, req.limit) if err != nil { return nil, err } @@ -730,318 +889,356 @@ func viewChannelEndpoint(svc ui.Service) endpoint.Endpoint { } } -func updateChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func connectChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updateChannelReq) + req := request.(connectThingReq) if err := req.validate(); err != nil { return nil, err } - uch := sdk.Channel{ - ID: req.id, - Name: req.Name, - Metadata: req.Metadata, - Description: req.Description, - } - - if err := svc.UpdateChannel(req.token, req.id, uch); err != nil { + if err := svc.ConnectThing(req.ThingID, req.ChanID, req.token); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + req.id}, + headers: map[string]string{"Location": thingsEndpoint + "/" + req.ThingID + channelsEndpoint}, }, nil } } -func listChannelsEndpoint(svc ui.Service) endpoint.Endpoint { +func disconnectChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityReq) - if err := req.validate(); err != nil { + dcr := request.(connectThingReq) + if err := dcr.validate(); err != nil { return nil, err } - res, err := svc.ListChannels(req.token, req.page, req.limit) - if err != nil { + if err := svc.DisconnectThing(dcr.ThingID, dcr.ChanID, dcr.token); err != nil { return nil, err } return uiRes{ - code: http.StatusOK, - html: res, + code: http.StatusFound, + headers: map[string]string{"Location": thingsEndpoint + "/" + dcr.ThingID + channelsEndpoint}, }, nil } } -func connectEndpoint(svc ui.Service) endpoint.Endpoint { +func createChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - cr := request.(connectReq) - if err := cr.validate(); err != nil { + req := request.(createChannelReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.Connect(cr.token, cr.ConnIDs); err != nil { + if err := svc.CreateChannel(req.Channel, req.token); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + cr.ConnIDs.ChannelIDs[0] + thingsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint}, }, nil } } -func disconnectEndpoint(svc ui.Service) endpoint.Endpoint { +func createChannelsEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - dcr := request.(disconnectReq) - if err := dcr.validate(); err != nil { + req := request.(createChannelsReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.Disconnect(dcr.token, dcr.ConnIDs); err != nil { + channels := []sdk.Channel{} + for i := range req.Names { + ch := sdk.Channel{ + Name: req.Names[i], + } + channels = append(channels, ch) + } + if err := svc.CreateChannels(req.token, channels...); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + dcr.ConnIDs.ChannelIDs[0] + thingsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint}, }, nil } } -func connectThingEndpoint(svc ui.Service) endpoint.Endpoint { +func listChannelsEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - cr := request.(connectThingReq) - if err := cr.validate(); err != nil { + req := request.(listEntityReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.ConnectThing(cr.token, cr.ConnIDs); err != nil { + res, err := svc.ListChannels(req.token, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + cr.ConnIDs.ChannelIDs[0] + thingsEndpoint}, + code: http.StatusOK, + html: res, }, nil } } -func shareThingEndpoint(svc ui.Service) endpoint.Endpoint { +func viewChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - sr := request.(shareThingReq) - if err := sr.validate(); err != nil { + req := request.(viewResourceReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.ShareThing(sr.token, sr.ChanID, sr.UserID, sr.Actions); err != nil { + res, err := svc.ViewChannel(req.token, req.id) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + sr.ChanID + thingsEndpoint}, + code: http.StatusOK, + html: res, }, nil } } -func connectChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func updateChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - cr := request.(connectChannelReq) - if err := cr.validate(); err != nil { + req := request.(updateChannelReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.ConnectChannel(cr.token, cr.ConnIDs); err != nil { + uch := sdk.Channel{ + ID: req.id, + Name: req.Name, + Metadata: req.Metadata, + Description: req.Description, + } + + if err := svc.UpdateChannel(req.token, req.id, uch); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": thingsEndpoint + "/" + cr.ConnIDs.ThingIDs[0] + channelsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint + "/" + req.id}, }, nil } } -func disconnectThingEndpoint(svc ui.Service) endpoint.Endpoint { +func listThingsByChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - dcr := request.(disconnectThingReq) - if err := dcr.validate(); err != nil { + req := request.(listEntityByIDReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.DisconnectThing(dcr.ThingID, dcr.ChanID, dcr.token); err != nil { + res, err := svc.ListThingsByChannel(req.token, req.id, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint + "/" + dcr.ChanID + thingsEndpoint}, + code: http.StatusOK, + html: res, }, nil } } -func disconnectChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func enableChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - dcr := request.(disconnectChannelReq) - if err := dcr.validate(); err != nil { + req := request.(updateChannelStatusReq) + if err := req.validate(); err != nil { return nil, err } - if err := svc.DisconnectChannel(dcr.ThingID, dcr.ChanID, dcr.token); err != nil { + if err := svc.EnableChannel(req.token, req.ChannelID); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": thingsEndpoint + "/" + dcr.ThingID + channelsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint}, }, nil } } -func listThingsByChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func disableChannelEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityByIDReq) + req := request.(updateChannelStatusReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ListThingsByChannel(req.token, req.id, req.page, req.limit) - if err != nil { + if err := svc.DisableChannel(req.token, req.ChannelID); err != nil { return nil, err } return uiRes{ - code: http.StatusOK, - html: res, + code: http.StatusFound, + headers: map[string]string{"Location": channelsEndpoint}, }, nil } } -func listChannelsByThingEndpoint(svc ui.Service) endpoint.Endpoint { +func connectThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityByIDReq) - if err := req.validate(); err != nil { + cr := request.(connectThingReq) + if err := cr.validate(); err != nil { return nil, err } - res, err := svc.ListChannelsByThing(req.token, req.id, req.page, req.limit) - if err != nil { + if err := svc.ConnectThing(cr.ThingID, cr.ChanID, cr.token); err != nil { return nil, err } return uiRes{ - code: http.StatusOK, - html: res, + code: http.StatusFound, + headers: map[string]string{"Location": channelsEndpoint + "/" + cr.ChanID + thingsEndpoint}, }, nil } } -func enableChannelEndpoint(svc ui.Service) endpoint.Endpoint { +func disconnectThingEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updateChannelStatusReq) - if err := req.validate(); err != nil { + dcr := request.(connectThingReq) + if err := dcr.validate(); err != nil { return nil, err } - if err := svc.EnableChannel(req.token, req.ChannelID); err != nil { + if err := svc.DisconnectThing(dcr.ThingID, dcr.ChanID, dcr.token); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint + "/" + dcr.ChanID + thingsEndpoint}, }, nil } } -func disableChannelEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updateChannelStatusReq) +func AddUserToChannelEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserToChannelReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.DisableChannel(req.token, req.ChannelID); err != nil { + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.AddUserToChannel(req.token, req.ChannelID, userRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": channelsEndpoint}, + headers: map[string]string{"Location": channelsEndpoint + "/" + req.ChannelID + usersEndpoint}, }, nil } } -func listThingsPoliciesEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityReq) +func RemoveUserFromChannelEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserToChannelReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ListThingsPolicies(req.token, req.page, req.limit) - if err != nil { + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.RemoveUserFromChannel(req.token, req.ChannelID, userRelation); err != nil { return nil, err } return uiRes{ code: http.StatusOK, + }, nil + } +} + +func ListChannelUsersEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) + + res, err := svc.ListChannelUsers(req.token, req.id, req.page, req.limit) + if err != nil { + return nil, err + } + + return uiRes{ html: res, + code: http.StatusOK, }, nil } } -func addThingsPolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(addThingsPolicyReq) +func addUserGroupToChannelEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserGroupToChannelReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.AddThingsPolicy(req.token, req.Policy); err != nil { + groupRelation := sdk.UserGroupsRequest{ + UserGroupIDs: []string{req.GroupID}, + } + + if err := svc.AddUserGroupToChannel(req.token, req.ChannelID, groupRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": "/things/policies"}, + headers: map[string]string{"Location": channelsEndpoint + "/" + req.ChannelID + groupsEndpoint}, }, nil } } -func updateThingsPolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updatePolicyReq) +func removeUserGroupFromChannelEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserGroupToChannelReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.UpdateThingsPolicy(req.token, req.Policy); err != nil { + groupRelation := sdk.UserGroupsRequest{ + UserGroupIDs: []string{req.GroupID}, + } + + if err := svc.RemoveUserGroupFromChannel(req.token, req.ChannelID, groupRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": "/things/policies"}, + headers: map[string]string{"Location": channelsEndpoint + "/" + req.ChannelID + groupsEndpoint}, }, nil } } -func deleteThingsPolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(deleteThingsPolicyReq) - if err := req.validate(); err != nil { - return nil, err - } +func ListChannelUserGroupsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) - if err := svc.DeleteThingsPolicy(req.token, req.Policy); err != nil { + res, err := svc.ListChannelUserGroups(req.token, req.id, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": "/things/policies"}, + html: res, + code: http.StatusOK, }, nil } } @@ -1089,17 +1286,18 @@ func createGroupsEndpoint(svc ui.Service) endpoint.Endpoint { } } -func listGroupsEndpoint(svc ui.Service) endpoint.Endpoint { +func listGroupUsersEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityReq) + req := request.(listEntityByIDReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ListGroups(req.token, req.page, req.limit) + res, err := svc.ListGroupUsers(req.token, req.id, req.page, req.limit) if err != nil { return nil, err } + return uiRes{ code: http.StatusOK, html: res, @@ -1107,21 +1305,48 @@ func listGroupsEndpoint(svc ui.Service) endpoint.Endpoint { } } -func listGroupMembersEndpoint(svc ui.Service) endpoint.Endpoint { +func assignEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityByIDReq) + req := request.(assignReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ListGroupMembers(req.token, req.id, req.page, req.limit) - if err != nil { + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.Assign(req.token, req.GroupID, userRelation); err != nil { return nil, err } return uiRes{ - code: http.StatusOK, - html: res, + code: http.StatusFound, + headers: map[string]string{"Location": groupsEndpoint + "/" + req.GroupID + usersEndpoint}, + }, nil + } +} + +func unassignEndpoint(svc ui.Service) endpoint.Endpoint { + return func(_ context.Context, request interface{}) (interface{}, error) { + req := request.(assignReq) + if err := req.validate(); err != nil { + return nil, err + } + + userRelation := sdk.UsersRelationRequest{ + Relation: req.Relation, + UserIDs: []string{req.UserID}, + } + + if err := svc.Unassign(req.token, req.GroupID, userRelation); err != nil { + return nil, err + } + + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": groupsEndpoint + "/" + req.GroupID + usersEndpoint}, }, nil } } @@ -1170,50 +1395,50 @@ func updateGroupEndpoint(svc ui.Service) endpoint.Endpoint { } } -func assignEndpoint(svc ui.Service) endpoint.Endpoint { +func listGroupsEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(assignReq) + req := request.(listEntityReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.Assign(req.token, req.groupID, req.MemberID, req.Type); err != nil { + res, err := svc.ListGroups(req.token, req.page, req.limit) + if err != nil { return nil, err } - return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": groupsEndpoint + "/" + req.groupID + "/members"}, + code: http.StatusOK, + html: res, }, nil } } -func unassignEndpoint(svc ui.Service) endpoint.Endpoint { +func enableGroupEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(unassignReq) + req := request.(updateGroupStatusReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.Unassign(req.token, req.groupID, req.MemberID); err != nil { + if err := svc.EnableGroup(req.token, req.GroupID); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": groupsEndpoint + "/" + req.groupID + "/members"}, + headers: map[string]string{"Location": groupsEndpoint}, }, nil } } -func enableGroupEndpoint(svc ui.Service) endpoint.Endpoint { +func disableGroupEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(updateGroupStatusReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.EnableGroup(req.token, req.GroupID); err != nil { + if err := svc.DisableGroup(req.token, req.GroupID); err != nil { return nil, err } @@ -1224,93 +1449,94 @@ func enableGroupEndpoint(svc ui.Service) endpoint.Endpoint { } } -func disableGroupEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updateGroupStatusReq) - if err := req.validate(); err != nil { - return nil, err - } +func listParentsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) - if err := svc.DisableGroup(req.token, req.GroupID); err != nil { + res, err := svc.ListParents(req.token, req.id, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": groupsEndpoint}, + html: res, + code: http.StatusOK, }, nil } } -func listPoliciesEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(listEntityReq) - if err := req.validate(); err != nil { - return nil, err - } +func listChildrenEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) - res, err := svc.ListPolicies(req.token, req.page, req.limit) + res, err := svc.ListChildren(req.token, req.id, req.page, req.limit) if err != nil { return nil, err } return uiRes{ - code: http.StatusOK, html: res, + code: http.StatusOK, }, nil } } -func addPolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(addPolicyReq) - if err := req.validate(); err != nil { - return nil, err - } +func listUserGroupChannelsEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(listEntityByIDReq) - if err := svc.AddPolicy(req.token, req.Policy); err != nil { + res, err := svc.ListUserGroupChannels(req.token, req.id, req.page, req.limit) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": "/users/policies"}, + html: res, + code: http.StatusOK, }, nil } } -func updatePolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(updatePolicyReq) +func addChannelToUserGroupEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserGroupToChannelReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.UpdatePolicy(req.token, req.Policy); err != nil { + groupRelation := sdk.UserGroupsRequest{ + UserGroupIDs: []string{req.GroupID}, + } + + if err := svc.AddUserGroupToChannel(req.token, req.ChannelID, groupRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": "/users/policies"}, + headers: map[string]string{"Location": groupsEndpoint + "/" + req.GroupID + channelsEndpoint}, }, nil } } -func deletePolicyEndpoint(svc ui.Service) endpoint.Endpoint { - return func(_ context.Context, request interface{}) (interface{}, error) { - req := request.(deletePolicyReq) +func removeChannelFromUserGroupEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(addUserGroupToChannelReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.DeletePolicy(req.token, req.Policy); err != nil { + groupRelation := sdk.UserGroupsRequest{ + UserGroupIDs: []string{req.GroupID}, + } + + if err := svc.RemoveUserGroupFromChannel(req.token, req.ChannelID, groupRelation); err != nil { return nil, err } return uiRes{ code: http.StatusFound, - headers: map[string]string{"Location": "/users/policies"}, + headers: map[string]string{"Location": groupsEndpoint + "/" + req.GroupID + channelsEndpoint}, }, nil } } @@ -1370,61 +1596,43 @@ func wsConnectionEndpoint(svc ui.Service) endpoint.Endpoint { } } -func getTerminalEndpoint(svc ui.Service) endpoint.Endpoint { +func createBootstrap(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(viewResourceReq) + req := request.(createBootstrapReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.GetRemoteTerminal(req.id, req.token) - if err != nil { - return nil, err - } - return uiRes{ - html: res, - }, nil - } -} -func handleTerminalInputEndpoint(svc ui.Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(bootstrapCommandReq) - if err := req.validate(); err != nil { - return nil, err + cfg := sdk.BootstrapConfig{ + ThingID: req.ThingID, + Channels: req.Channels, + ExternalID: req.ExternalID, + ExternalKey: req.ExternalKey, + Name: req.Name, + ClientCert: req.ClientCert, + ClientKey: req.ClientKey, + CACert: req.CACert, + Content: req.Content, } - - // Create a channel to receive the command result - ch := make(chan string) - - g, ctx := errgroup.WithContext(ctx) - - // Start a goroutine to process the command asynchronously - g.Go(func() error { - return svc.ProcessTerminalCommand(ctx, req.id, req.token, req.command, ch) - }) - - if err := g.Wait(); err != nil { + if err := svc.CreateBootstrap(req.token, cfg); err != nil { return nil, err } - // Receive the command result from the channel - result := <-ch - - return terminalResponse{ - Command: req.command, - Result: result, + return uiRes{ + code: http.StatusFound, + headers: map[string]string{"Location": bootstrapEndpoint}, }, nil } } -func viewBootstrap(svc ui.Service) endpoint.Endpoint { +func listBootstrap(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(viewResourceReq) + req := request.(listEntityReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ViewBootstrap(req.token, req.id) + res, err := svc.ListBootstrap(req.token, req.page, req.limit) if err != nil { return nil, err } @@ -1436,38 +1644,41 @@ func viewBootstrap(svc ui.Service) endpoint.Endpoint { } } -func listBootstrap(svc ui.Service) endpoint.Endpoint { +func updateBootstrap(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(listEntityReq) + req := request.(updateBootstrapReq) if err := req.validate(); err != nil { return nil, err } - res, err := svc.ListBootstrap(req.token, req.page, req.limit) - if err != nil { + cfg := sdk.BootstrapConfig{ + ThingID: req.id, + Name: req.Name, + Content: req.Content, + } + if err := svc.UpdateBootstrap(req.token, cfg); err != nil { return nil, err } return uiRes{ - code: http.StatusOK, - html: res, + code: http.StatusFound, + headers: map[string]string{"Location": bootstrapEndpoint + "/" + req.id}, }, nil } } -func updateBootstrap(svc ui.Service) endpoint.Endpoint { +func updateBootstrapConnections(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(updateBootstrapReq) + req := request.(updateBootstrapConnReq) if err := req.validate(); err != nil { return nil, err } cfg := sdk.BootstrapConfig{ - ThingID: req.id, - Name: req.Name, - Content: req.Content, + ThingID: req.id, + Channels: req.Channels, } - if err := svc.UpdateBootstrap(req.token, cfg); err != nil { + if err := svc.UpdateBootstrapConnections(req.token, cfg); err != nil { return nil, err } @@ -1502,53 +1713,68 @@ func updateBootstrapCerts(svc ui.Service) endpoint.Endpoint { } } -func updateBootstrapConnections(svc ui.Service) endpoint.Endpoint { +func viewBootstrap(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(updateBootstrapConnReq) + req := request.(viewResourceReq) if err := req.validate(); err != nil { return nil, err } - cfg := sdk.BootstrapConfig{ - ThingID: req.id, - Channels: req.Channels, - } - if err := svc.UpdateBootstrapConnections(req.token, cfg); err != nil { + res, err := svc.ViewBootstrap(req.token, req.id) + if err != nil { return nil, err } return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": bootstrapEndpoint + "/" + req.id}, + code: http.StatusOK, + html: res, }, nil } } -func createBootstrap(svc ui.Service) endpoint.Endpoint { +func getTerminalEndpoint(svc ui.Service) endpoint.Endpoint { return func(_ context.Context, request interface{}) (response interface{}, err error) { - req := request.(createBootstrapReq) + req := request.(viewResourceReq) if err := req.validate(); err != nil { return nil, err } + res, err := svc.GetRemoteTerminal(req.id, req.token) + if err != nil { + return nil, err + } + return uiRes{ + html: res, + }, nil + } +} - cfg := sdk.BootstrapConfig{ - ThingID: req.ThingID, - Channels: req.Channels, - ExternalID: req.ExternalID, - ExternalKey: req.ExternalKey, - Name: req.Name, - ClientCert: req.ClientCert, - ClientKey: req.ClientKey, - CACert: req.CACert, - Content: req.Content, +func handleTerminalInputEndpoint(svc ui.Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + req := request.(bootstrapCommandReq) + if err := req.validate(); err != nil { + return nil, err } - if err := svc.CreateBootstrap(req.token, cfg); err != nil { + + // Create a channel to receive the command result + ch := make(chan string) + + g, ctx := errgroup.WithContext(ctx) + + // Start a goroutine to process the command asynchronously + g.Go(func() error { + return svc.ProcessTerminalCommand(ctx, req.id, req.token, req.command, ch) + }) + + if err := g.Wait(); err != nil { return nil, err } - return uiRes{ - code: http.StatusFound, - headers: map[string]string{"Location": "/bootstraps"}, + // Receive the command result from the channel + result := <-ch + + return terminalResponse{ + Command: req.command, + Result: result, }, nil } } @@ -1583,10 +1809,9 @@ func errorPageEndpoint(svc ui.Service) endpoint.Endpoint { if err != nil { return nil, err } - return uiRes{ - code: http.StatusOK, html: res, + code: http.StatusOK, }, nil } } diff --git a/ui/api/logging.go b/ui/api/logging.go index 80d6a0a3..38d14942 100644 --- a/ui/api/logging.go +++ b/ui/api/logging.go @@ -9,7 +9,6 @@ package api import ( "context" "fmt" - "strings" "time" "github.com/ultravioletrs/mainflux-ui/ui" @@ -59,6 +58,20 @@ func (lm *loggingMiddleware) Login() (b []byte, err error) { return lm.svc.Login() } +// Logout adds logging middleware to logout method. +func (lm *loggingMiddleware) Logout() (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method logout took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.Logout() +} + // PasswordResetRequest adds logging middleware to password reset request method. func (lm *loggingMiddleware) PasswordResetRequest(email string) (err error) { defer func(begin time.Time) { @@ -112,24 +125,10 @@ func (lm *loggingMiddleware) PasswordUpdate(token string) (b []byte, err error) return lm.svc.PasswordUpdate(token) } -// Toke adds logging middleware to token method. -func (lm *loggingMiddleware) Token(user sdk.User) (token sdk.Token, err error) { - defer func(begin time.Time) { - message := fmt.Sprintf("Method token took %s to complete", time.Since(begin)) - if err != nil { - lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) - return - } - lm.logger.Info(fmt.Sprintf("%s without errors.", message)) - }(time.Now()) - - return lm.svc.Token(user) -} - -// RefreshToken adds logging middleware to refresh token method. -func (lm *loggingMiddleware) RefreshToken(refreshToken string) (token sdk.Token, err error) { +// UpdatePassword adds logging middleware to update password method. +func (lm *loggingMiddleware) UpdatePassword(token, oldPass, newPass string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method refresh_token took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method update_password took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -137,13 +136,13 @@ func (lm *loggingMiddleware) RefreshToken(refreshToken string) (token sdk.Token, lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.RefreshToken(refreshToken) + return lm.svc.UpdatePassword(token, oldPass, newPass) } -// Logout adds logging middleware to logout method. -func (lm *loggingMiddleware) Logout() (err error) { +// Toke adds logging middleware to token method. +func (lm *loggingMiddleware) Token(user sdk.User) (token sdk.Token, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method logout took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method token took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -151,13 +150,13 @@ func (lm *loggingMiddleware) Logout() (err error) { lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.Logout() + return lm.svc.Token(user) } -// UpdatePassword adds logging middleware to update password method. -func (lm *loggingMiddleware) UpdatePassword(token, oldPass, newPass string) (err error) { +// RefreshToken adds logging middleware to refresh token method. +func (lm *loggingMiddleware) RefreshToken(refreshToken string) (token sdk.Token, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_password took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method refresh_token took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -165,7 +164,7 @@ func (lm *loggingMiddleware) UpdatePassword(token, oldPass, newPass string) (err lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdatePassword(token, oldPass, newPass) + return lm.svc.RefreshToken(refreshToken) } // CreateUsers adds logging middleware to create users method. @@ -294,6 +293,62 @@ func (lm *loggingMiddleware) DisableUser(token, id string) (err error) { return lm.svc.DisableUser(token, id) } +// ListUserGroups adds logging middleware to list user groups method. +func (lm *loggingMiddleware) ListUserGroups(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method list_user_groups took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.ListUserGroups(token, userID, page, limit) +} + +// ListUserThings adds logging middleware to list user things method. +func (lm *loggingMiddleware) ListUserThings(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method list_user_things took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.ListUserThings(token, userID, page, limit) +} + +// ListUserChannels adds logging middleware to list user channels method. +func (lm *loggingMiddleware) ListUserChannels(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method list_user_channels took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.ListUserChannels(token, userID, page, limit) +} + +// CreateThing adds logging middleware to create thing method. +func (lm *loggingMiddleware) CreateThing(thing sdk.Thing, token string) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method create_thing took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.CreateThing(thing, token) +} + // CreateThings adds logging middleware to create things method. func (lm *loggingMiddleware) CreateThings(token string, things ...sdk.Thing) (err error) { defer func(begin time.Time) { @@ -378,6 +433,20 @@ func (lm *loggingMiddleware) UpdateThingSecret(token, id, secret string) (err er return lm.svc.UpdateThingSecret(token, id, secret) } +// UpdateThingOwner adds logging middleware to update thing owner method. +func (lm *loggingMiddleware) UpdateThingOwner(token string, thing sdk.Thing) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method update_thing_owner for thing %s took %s to complete", thing.ID, time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.UpdateThingOwner(token, thing) +} + // EnableThing adds logging middleware to enable thing method. func (lm *loggingMiddleware) EnableThing(token, id string) (err error) { defer func(begin time.Time) { @@ -406,10 +475,10 @@ func (lm *loggingMiddleware) DisableThing(token, id string) (err error) { return lm.svc.DisableThing(token, id) } -// UpdateThingOwner adds logging middleware to update thing owner method. -func (lm *loggingMiddleware) UpdateThingOwner(token string, thing sdk.Thing) (err error) { +// ShareThing adds logging middleware to share thing method. +func (lm *loggingMiddleware) ShareThing(token, thingID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_thing_owner for thing %s took %s to complete", thing.ID, time.Since(begin)) + message := fmt.Sprintf("Method share_thing for thing %s took %s to complete", thingID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -417,13 +486,13 @@ func (lm *loggingMiddleware) UpdateThingOwner(token string, thing sdk.Thing) (er lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateThingOwner(token, thing) + return lm.svc.ShareThing(token, thingID, req) } -// CreateChannels adds logging middleware to create channels method. -func (lm *loggingMiddleware) CreateChannels(token string, channels ...sdk.Channel) (err error) { +// UnshareThing adds logging middleware to unshare thing method. +func (lm *loggingMiddleware) UnshareThing(token, thingID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method create_channels took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method unshare_thing for thing %s took %s to complete", thingID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -431,13 +500,13 @@ func (lm *loggingMiddleware) CreateChannels(token string, channels ...sdk.Channe lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.CreateChannels(token, channels...) + return lm.svc.UnshareThing(token, thingID, req) } -// ViewChannel adds logging middleware to view channel method. -func (lm *loggingMiddleware) ViewChannel(token, id string) (b []byte, err error) { +// ListThingUsers adds logging middleware to list thing users method. +func (lm *loggingMiddleware) ListThingUsers(token, thingID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method view_channel for channel %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method list_thing_users took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -445,13 +514,13 @@ func (lm *loggingMiddleware) ViewChannel(token, id string) (b []byte, err error) lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ViewChannel(token, id) + return lm.svc.ListThingUsers(token, thingID, page, limit) } -// UpdateChannel adds logging middleware to update channel method. -func (lm *loggingMiddleware) UpdateChannel(token, id string, channel sdk.Channel) (err error) { +// ListChannelsByThing adds logging middleware to list channels by thing method. +func (lm *loggingMiddleware) ListChannelsByThing(token, thingID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_channel for channel %s took %s to complete", channel.ID, time.Since(begin)) + message := fmt.Sprintf("Method list_channels_by_thing for thing %s took %s to complete", thingID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -459,7 +528,35 @@ func (lm *loggingMiddleware) UpdateChannel(token, id string, channel sdk.Channel lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateChannel(token, id, channel) + return lm.svc.ListChannelsByThing(token, thingID, page, limit) +} + +// CreateChannel adds logging middleware to create channel method. +func (lm *loggingMiddleware) CreateChannel(channel sdk.Channel, token string) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method create_channel took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.CreateChannel(channel, token) +} + +// CreateChannels adds logging middleware to create channels method. +func (lm *loggingMiddleware) CreateChannels(token string, channels ...sdk.Channel) (err error) { + defer func(begin time.Time) { + message := fmt.Sprintf("Method create_channels took %s to complete", time.Since(begin)) + if err != nil { + lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return + } + lm.logger.Info(fmt.Sprintf("%s without errors.", message)) + }(time.Now()) + + return lm.svc.CreateChannels(token, channels...) } // ListChannels adds logging middleware to list channels method. @@ -476,10 +573,10 @@ func (lm *loggingMiddleware) ListChannels(token string, page, limit uint64) (b [ return lm.svc.ListChannels(token, page, limit) } -// EnableChannel adds logging middleware to enable channel method. -func (lm *loggingMiddleware) EnableChannel(token, id string) (err error) { +// ViewChannel adds logging middleware to view channel method. +func (lm *loggingMiddleware) ViewChannel(token, id string) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method enable_channel for channel %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method view_channel for channel %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -487,13 +584,13 @@ func (lm *loggingMiddleware) EnableChannel(token, id string) (err error) { lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.EnableChannel(token, id) + return lm.svc.ViewChannel(token, id) } -// DisableChannel adds logging middleware to disable channel method. -func (lm *loggingMiddleware) DisableChannel(token, id string) (err error) { +// UpdateChannel adds logging middleware to update channel method. +func (lm *loggingMiddleware) UpdateChannel(token, id string, channel sdk.Channel) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method disable_channel for channel %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method update_channel for channel %s took %s to complete", channel.ID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -501,13 +598,13 @@ func (lm *loggingMiddleware) DisableChannel(token, id string) (err error) { lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.DisableChannel(token, id) + return lm.svc.UpdateChannel(token, id, channel) } -// Connect adds logging middleware to connect method. -func (lm *loggingMiddleware) Connect(token string, connIDs sdk.ConnectionIDs) (err error) { +// ListThingsByChannel adds logging middleware to list things by channel method. +func (lm *loggingMiddleware) ListThingsByChannel(token, channeID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method connect for things %s to channels %s took %s to complete", strings.Join(connIDs.ThingIDs, ","), strings.Join(connIDs.ChannelIDs, ","), time.Since(begin)) + message := fmt.Sprintf("Method list_things_by_channel for channel %s took %s to complete", channeID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -515,13 +612,13 @@ func (lm *loggingMiddleware) Connect(token string, connIDs sdk.ConnectionIDs) (e lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.Connect(token, connIDs) + return lm.svc.ListThingsByChannel(token, channeID, page, limit) } -// Disconnect adds logging middleware to disconnect method. -func (lm *loggingMiddleware) Disconnect(token string, connIDs sdk.ConnectionIDs) (err error) { +// EnableChannel adds logging middleware to enable channel method. +func (lm *loggingMiddleware) EnableChannel(token, id string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method disconnect for things %s to channels %s took %s to complete", strings.Join(connIDs.ThingIDs, ","), strings.Join(connIDs.ChannelIDs, ","), time.Since(begin)) + message := fmt.Sprintf("Method enable_channel for channel %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -529,13 +626,13 @@ func (lm *loggingMiddleware) Disconnect(token string, connIDs sdk.ConnectionIDs) lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.Disconnect(token, connIDs) + return lm.svc.EnableChannel(token, id) } -// ListThingsByChannel adds logging middleware to list things by channel method. -func (lm *loggingMiddleware) ListThingsByChannel(token, id string, page, limit uint64) (b []byte, err error) { +// DisableChannel adds logging middleware to disable channel method. +func (lm *loggingMiddleware) DisableChannel(token, id string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_things_by_channel for channel %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method disable_channel for channel %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -543,13 +640,13 @@ func (lm *loggingMiddleware) ListThingsByChannel(token, id string, page, limit u lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListThingsByChannel(token, id, page, limit) + return lm.svc.DisableChannel(token, id) } -// ListChannelsByThing adds logging middleware to list channels by thing method. -func (lm *loggingMiddleware) ListChannelsByThing(token, id string, page, limit uint64) (b []byte, err error) { +// Connect adds logging middleware to connect method. +func (lm *loggingMiddleware) Connect(token string, connIDs sdk.Connection) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_channels_by_thing for thing %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method connect for thing %s to channel %s took %s to complete", connIDs.ThingID, connIDs.ChannelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -557,13 +654,13 @@ func (lm *loggingMiddleware) ListChannelsByThing(token, id string, page, limit u lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListChannelsByThing(token, id, page, limit) + return lm.svc.Connect(token, connIDs) } -// ConnectThing adds logging middleware to connect thing method. -func (lm *loggingMiddleware) ConnectThing(token string, connIDs sdk.ConnectionIDs) (err error) { +// Disconnect adds logging middleware to disconnect method. +func (lm *loggingMiddleware) Disconnect(token string, connIDs sdk.Connection) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method connect_thing for things %s to channels %s took %s to complete", strings.Join(connIDs.ThingIDs, ","), strings.Join(connIDs.ChannelIDs, ","), time.Since(begin)) + message := fmt.Sprintf("Method disconnect for thing %s to channel %s took %s to complete", connIDs.ThingID, connIDs.ChannelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -571,13 +668,13 @@ func (lm *loggingMiddleware) ConnectThing(token string, connIDs sdk.ConnectionID lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ConnectThing(token, connIDs) + return lm.svc.Disconnect(token, connIDs) } -// ShareThing adds logging middleware to share thing method. -func (lm *loggingMiddleware) ShareThing(token, chanID, userID string, actions []string) (err error) { +// ConnectThing adds logging middleware to connect thing method. +func (lm *loggingMiddleware) ConnectThing(thingID, chanID, token string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method share_thing for channel %s to user %s took %s to complete", chanID, userID, time.Since(begin)) + message := fmt.Sprintf("Method connect_thing for thing %s to channel %s took %s to complete", thingID, chanID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -585,7 +682,7 @@ func (lm *loggingMiddleware) ShareThing(token, chanID, userID string, actions [] lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ShareThing(token, chanID, userID, actions) + return lm.svc.ConnectThing(thingID, chanID, token) } // DisconnectThing adds logging middleware to disconnect thing method. @@ -602,10 +699,10 @@ func (lm *loggingMiddleware) DisconnectThing(thID, chID, token string) (err erro return lm.svc.DisconnectThing(thID, chID, token) } -// ConnectChannel adds logging middleware to connect channel method. -func (lm *loggingMiddleware) ConnectChannel(token string, connIDs sdk.ConnectionIDs) (err error) { +// AddUserToChannel adds logging middleware to add user to channel method. +func (lm *loggingMiddleware) AddUserToChannel(token, channelID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method connect_channel for channels %s to things %s took %s to complete", strings.Join(connIDs.ChannelIDs, ","), strings.Join(connIDs.ThingIDs, ","), time.Since(begin)) + message := fmt.Sprintf("Method add_user_to_channel for channel %s took %s to complete", channelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -613,13 +710,13 @@ func (lm *loggingMiddleware) ConnectChannel(token string, connIDs sdk.Connection lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ConnectChannel(token, connIDs) + return lm.svc.AddUserToChannel(token, channelID, req) } -// DisconnectChannel adds logging middleware to disconnect channel method. -func (lm *loggingMiddleware) DisconnectChannel(thID, chID, token string) (err error) { +// RemoveUserFromChannel adds logging middleware to remove user from channel method. +func (lm *loggingMiddleware) RemoveUserFromChannel(token, channelID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method disconnect_channel for channel %s to thing %s took %s to complete", chID, thID, time.Since(begin)) + message := fmt.Sprintf("Method remove_user_from_channel for channel %s took %s to complete", channelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -627,13 +724,13 @@ func (lm *loggingMiddleware) DisconnectChannel(thID, chID, token string) (err er lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.DisconnectChannel(thID, chID, token) + return lm.svc.RemoveUserFromChannel(token, channelID, req) } -// ListThingsPolicies adds logging middleware to list things polices method. -func (lm *loggingMiddleware) ListThingsPolicies(token string, page, limit uint64) (b []byte, err error) { +// ListChannelUsers adds logging middleware to list channel users method. +func (lm *loggingMiddleware) ListChannelUsers(token, channelID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_things_policies took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method list_channel_users took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -641,13 +738,13 @@ func (lm *loggingMiddleware) ListThingsPolicies(token string, page, limit uint64 lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListThingsPolicies(token, page, limit) + return lm.svc.ListChannelUsers(token, channelID, page, limit) } -// AddThingsPolicy adds logging middleware to add things policy method. -func (lm *loggingMiddleware) AddThingsPolicy(token string, policy sdk.Policy) (err error) { +// AddUserGroupToChannel adds logging middleware to add usergroup to channel method. +func (lm *loggingMiddleware) AddUserGroupToChannel(token, channelID string, req sdk.UserGroupsRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method add_things_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) + message := fmt.Sprintf("Method add_usergroup_to_channel for channel %s took %s to complete", channelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -655,13 +752,13 @@ func (lm *loggingMiddleware) AddThingsPolicy(token string, policy sdk.Policy) (e lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.AddThingsPolicy(token, policy) + return lm.svc.AddUserGroupToChannel(token, channelID, req) } -// DeleteThingsPolicy adds logging middleware to delete things policy method. -func (lm *loggingMiddleware) DeleteThingsPolicy(token string, policy sdk.Policy) (err error) { +// RemoveUserGroupFromChannel adds logging middleware to remove usergroup from channel method. +func (lm *loggingMiddleware) RemoveUserGroupFromChannel(token, channelID string, req sdk.UserGroupsRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method delete_things_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) + message := fmt.Sprintf("Method remove_usergroup_from_channel for channel %s took %s to complete", channelID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -669,13 +766,13 @@ func (lm *loggingMiddleware) DeleteThingsPolicy(token string, policy sdk.Policy) lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.DeleteThingsPolicy(token, policy) + return lm.svc.RemoveUserGroupFromChannel(token, channelID, req) } -// UpdateThingsPolicy adds logging middleware to update things policy method. -func (lm *loggingMiddleware) UpdateThingsPolicy(token string, policy sdk.Policy) (err error) { +// ListChannelUserGroups adds logging middleware to list channel user groups method. +func (lm *loggingMiddleware) ListChannelUserGroups(token, channelID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_things_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) + message := fmt.Sprintf("Method list_channel_usergroups took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -683,7 +780,7 @@ func (lm *loggingMiddleware) UpdateThingsPolicy(token string, policy sdk.Policy) lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateThingsPolicy(token, policy) + return lm.svc.ListChannelUserGroups(token, channelID, page, limit) } // CreateGroups adds logging middleware to create groups method. @@ -700,10 +797,10 @@ func (lm *loggingMiddleware) CreateGroups(token string, groups ...sdk.Group) (er return lm.svc.CreateGroups(token, groups...) } -// ListGroups adds logging middleware to list groups method. -func (lm *loggingMiddleware) ListGroups(token string, page, limit uint64) (b []byte, err error) { +// ListGroupUsers adds logging middleware to list group users method. +func (lm *loggingMiddleware) ListGroupUsers(token, id string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_groups took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method list_group_users for group %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -711,13 +808,13 @@ func (lm *loggingMiddleware) ListGroups(token string, page, limit uint64) (b []b lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListGroups(token, page, limit) + return lm.svc.ListGroupUsers(token, id, page, limit) } -// ViewGroup adds logging middleware to view group method. -func (lm *loggingMiddleware) ViewGroup(token, id string) (b []byte, err error) { +// Assign adds logging middleware to assign method. +func (lm *loggingMiddleware) Assign(token, groupID string, userRelation sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method view_group for group %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method assign for user %s to group %s took %s to complete", userRelation.UserIDs[0], groupID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -725,13 +822,13 @@ func (lm *loggingMiddleware) ViewGroup(token, id string) (b []byte, err error) { lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ViewGroup(token, id) + return lm.svc.Assign(token, groupID, userRelation) } -// Assign adds logging middleware to assign method. -func (lm *loggingMiddleware) Assign(token, groupID, memberID string, memberType []string) (err error) { +// Unassign adds logging middleware to unassign method. +func (lm *loggingMiddleware) Unassign(token, groupID string, userRelation sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method assign for user %s to group %s took %s to complete", memberID, groupID, time.Since(begin)) + message := fmt.Sprintf("Method unassign for user %s to group %s took %s to complete", userRelation.UserIDs[0], groupID, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -739,13 +836,13 @@ func (lm *loggingMiddleware) Assign(token, groupID, memberID string, memberType lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.Assign(token, groupID, memberID, memberType) + return lm.svc.Unassign(token, groupID, userRelation) } -// Unassign adds logging middleware to unassign method. -func (lm *loggingMiddleware) Unassign(token, groupID, memberID string) (err error) { +// ViewGroup adds logging middleware to view group method. +func (lm *loggingMiddleware) ViewGroup(token, id string) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method unassign for user %s to group %s took %s to complete", memberID, groupID, time.Since(begin)) + message := fmt.Sprintf("Method view_group for group %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -753,7 +850,7 @@ func (lm *loggingMiddleware) Unassign(token, groupID, memberID string) (err erro lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.Unassign(token, groupID, memberID) + return lm.svc.ViewGroup(token, id) } // UpdateGroup adds logging middleware to update group method. @@ -770,10 +867,10 @@ func (lm *loggingMiddleware) UpdateGroup(token, id string, group sdk.Group) (err return lm.svc.UpdateGroup(token, id, group) } -// ListGroupMembers adds logging middleware to list group members method. -func (lm *loggingMiddleware) ListGroupMembers(token, id string, page, limit uint64) (b []byte, err error) { +// ListGroups adds logging middleware to list groups method. +func (lm *loggingMiddleware) ListGroups(token string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_group_members for group %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method list_groups took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -781,7 +878,7 @@ func (lm *loggingMiddleware) ListGroupMembers(token, id string, page, limit uint lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListGroupMembers(token, id, page, limit) + return lm.svc.ListGroups(token, page, limit) } // EnableGroup adds logging middleware to enable group method. @@ -812,24 +909,10 @@ func (lm *loggingMiddleware) DisableGroup(token, id string) (err error) { return lm.svc.DisableGroup(token, id) } -// AddPolicy adds logging middleware to add policy method. -func (lm *loggingMiddleware) AddPolicy(token string, policy sdk.Policy) (err error) { - defer func(begin time.Time) { - message := fmt.Sprintf("Method add_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) - if err != nil { - lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) - return - } - lm.logger.Info(fmt.Sprintf("%s without errors.", message)) - }(time.Now()) - - return lm.svc.AddPolicy(token, policy) -} - -// ListPolicies adds logging middleware to list policies method. -func (lm *loggingMiddleware) ListPolicies(token string, page, limit uint64) (b []byte, err error) { +// ListParents adds logging middleware to list parents method. +func (lm *loggingMiddleware) ListParents(token, groupID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_policies took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method list_parents took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -837,13 +920,13 @@ func (lm *loggingMiddleware) ListPolicies(token string, page, limit uint64) (b [ lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListPolicies(token, page, limit) + return lm.svc.ListParents(token, groupID, page, limit) } -// UpdatePolicy adds logging middleware to update policy method. -func (lm *loggingMiddleware) UpdatePolicy(token string, policy sdk.Policy) (err error) { +// ListChildren adds logging middleware to list children method. +func (lm *loggingMiddleware) ListChildren(token, groupID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) + message := fmt.Sprintf("Method list_children took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -851,13 +934,13 @@ func (lm *loggingMiddleware) UpdatePolicy(token string, policy sdk.Policy) (err lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdatePolicy(token, policy) + return lm.svc.ListChildren(token, groupID, page, limit) } -// DeletePolicy adds logging middleware to delete policy method. -func (lm *loggingMiddleware) DeletePolicy(token string, policy sdk.Policy) (err error) { +// ListUserGroupChannels adds logging middleware to list usergroup channels method. +func (lm *loggingMiddleware) ListUserGroupChannels(token, groupID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method delete_policy for subject %s and object %s took %s to complete", policy.Subject, policy.Object, time.Since(begin)) + message := fmt.Sprintf("Method list_usergroup_channels took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -865,7 +948,7 @@ func (lm *loggingMiddleware) DeletePolicy(token string, policy sdk.Policy) (err lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.DeletePolicy(token, policy) + return lm.svc.ListUserGroupChannels(token, groupID, page, limit) } // Publish adds logging middleware to publish method. @@ -914,10 +997,10 @@ func (lm *loggingMiddleware) WsConnection(token, chID, thKey string) (b []byte, return lm.svc.WsConnection(token, chID, thKey) } -// GetRemoteTerminal adds logging middleware to remote terminal. -func (lm *loggingMiddleware) GetRemoteTerminal(id, token string) (res []byte, err error) { +// CreateBootstrap adds logging middleware to create bootstrap method. +func (lm *loggingMiddleware) CreateBootstrap(token string, config ...sdk.BootstrapConfig) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method remote_terminal with id %s took %s to complete", id, time.Since(begin)) + message := fmt.Sprintf("Method create_bootstrap took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -925,26 +1008,27 @@ func (lm *loggingMiddleware) GetRemoteTerminal(id, token string) (res []byte, er lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.GetRemoteTerminal(id, token) + return lm.svc.CreateBootstrap(token, config...) } -// ProcessTerminalCommand adds logging middleware to async function ProcessTerminalCommand. -func (lm *loggingMiddleware) ProcessTerminalCommand(ctx context.Context, id, token, command string, res chan string) (err error) { +// ListBootstrap adds logging middleware to list bootstrap method. +func (lm *loggingMiddleware) ListBootstrap(token string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method remote_terminal took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method list_bootstrap took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) + return } lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ProcessTerminalCommand(ctx, id, token, command, res) + return lm.svc.ListBootstrap(token, page, limit) } -// CreateBootstrap adds logging middleware to create bootstrap method. -func (lm *loggingMiddleware) CreateBootstrap(token string, config ...sdk.BootstrapConfig) (err error) { +// UpdateBootstrap adds logging middleware to update bootstrap method. +func (lm *loggingMiddleware) UpdateBootstrap(token string, config sdk.BootstrapConfig) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method create_bootstrap took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method update_bootstrap took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -952,13 +1036,13 @@ func (lm *loggingMiddleware) CreateBootstrap(token string, config ...sdk.Bootstr lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.CreateBootstrap(token, config...) + return lm.svc.UpdateBootstrap(token, config) } -// DeleteBootstrap adds logging middleware to delete bootstrap method. -func (lm *loggingMiddleware) DeleteBootstrap(token string, id string) (err error) { +// UpdateBootstrapConnections adds logging middleware to update bootstrap connections method. +func (lm *loggingMiddleware) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method delete_bootstrap took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method update_bootstrap_connections took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -966,13 +1050,13 @@ func (lm *loggingMiddleware) DeleteBootstrap(token string, id string) (err error lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.DeleteBootstrap(token, id) + return lm.svc.UpdateBootstrapConnections(token, config) } -// ListBootstrap adds logging middleware to list bootstrap method. -func (lm *loggingMiddleware) ListBootstrap(token string, page, limit uint64) (b []byte, err error) { +// UpdateBootstrapCerts adds logging middleware to update bootstrap certs method. +func (lm *loggingMiddleware) UpdateBootstrapCerts(token string, config sdk.BootstrapConfig) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method list_bootstrap took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method update_bootstrap_certs took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -980,13 +1064,13 @@ func (lm *loggingMiddleware) ListBootstrap(token string, page, limit uint64) (b lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ListBootstrap(token, page, limit) + return lm.svc.UpdateBootstrapCerts(token, config) } -// UpdateBootstrap adds logging middleware to update bootstrap method. -func (lm *loggingMiddleware) UpdateBootstrap(token string, config sdk.BootstrapConfig) (err error) { +// DeleteBootstrap adds logging middleware to delete bootstrap method. +func (lm *loggingMiddleware) DeleteBootstrap(token string, id string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_bootstrap took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method delete_bootstrap took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -994,13 +1078,13 @@ func (lm *loggingMiddleware) UpdateBootstrap(token string, config sdk.BootstrapC lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateBootstrap(token, config) + return lm.svc.DeleteBootstrap(token, id) } -// UpdateBootstrapCerts adds logging middleware to update bootstrap certs method. -func (lm *loggingMiddleware) UpdateBootstrapCerts(token string, config sdk.BootstrapConfig) (err error) { +// ViewBootstrap adds logging middleware to view bootstrap method. +func (lm *loggingMiddleware) ViewBootstrap(token string, id string) (b []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_bootstrap_certs took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method view_bootstrap took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -1008,13 +1092,13 @@ func (lm *loggingMiddleware) UpdateBootstrapCerts(token string, config sdk.Boots lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateBootstrapCerts(token, config) + return lm.svc.ViewBootstrap(token, id) } -// UpdateBootstrapConnections adds logging middleware to update bootstrap connections method. -func (lm *loggingMiddleware) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) (err error) { +// GetRemoteTerminal adds logging middleware to remote terminal. +func (lm *loggingMiddleware) GetRemoteTerminal(id, token string) (res []byte, err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_bootstrap_connections took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method remote_terminal with id %s took %s to complete", id, time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return @@ -1022,23 +1106,23 @@ func (lm *loggingMiddleware) UpdateBootstrapConnections(token string, config sdk lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.UpdateBootstrapConnections(token, config) + return lm.svc.GetRemoteTerminal(id, token) } -// ViewBootstrap adds logging middleware to view bootstrap method. -func (lm *loggingMiddleware) ViewBootstrap(token string, id string) (b []byte, err error) { +// ProcessTerminalCommand adds logging middleware to async function ProcessTerminalCommand. +func (lm *loggingMiddleware) ProcessTerminalCommand(ctx context.Context, id, token, command string, res chan string) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method view_bootstrap took %s to complete", time.Since(begin)) + message := fmt.Sprintf("Method remote_terminal took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) - return } lm.logger.Info(fmt.Sprintf("%s without errors.", message)) }(time.Now()) - return lm.svc.ViewBootstrap(token, id) + return lm.svc.ProcessTerminalCommand(ctx, id, token, command, res) } +// GetEntities adds logging middleware to get entities method. func (lm *loggingMiddleware) GetEntities(token, item, name string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { message := fmt.Sprintf("Method get_entities took %s to complete", time.Since(begin)) @@ -1052,6 +1136,7 @@ func (lm *loggingMiddleware) GetEntities(token, item, name string, page, limit u return lm.svc.GetEntities(token, item, name, page, limit) } +// ErrorPage adds logging middleware to error page method. func (lm *loggingMiddleware) ErrorPage(errMsg string) (b []byte, err error) { defer func(begin time.Time) { message := fmt.Sprintf("Method ErrorPage took %s to complete", time.Since(begin)) diff --git a/ui/api/metrics.go b/ui/api/metrics.go index 30bbf079..dd6ea109 100644 --- a/ui/api/metrics.go +++ b/ui/api/metrics.go @@ -54,6 +54,16 @@ func (mm *metricsMiddleware) Login() (b []byte, err error) { return mm.svc.Login() } +// Logout adds metrics middleware to logout method. +func (mm *metricsMiddleware) Logout() (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "logout").Add(1) + mm.latency.With("method", "logout").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.Logout() +} + // PasswordResetRequest adds metrics middleware to password reset request method. func (mm *metricsMiddleware) PasswordResetRequest(email string) (err error) { defer func(begin time.Time) { @@ -94,6 +104,16 @@ func (mm *metricsMiddleware) PasswordUpdate(token string) (b []byte, err error) return mm.svc.PasswordUpdate(token) } +// UpdatePassword adds metrics middleware to update password method. +func (mm *metricsMiddleware) UpdatePassword(token, oldPass, newPass string) (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "update_user_password").Add(1) + mm.latency.With("method", "update_user_password").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.UpdatePassword(token, oldPass, newPass) +} + // Token adds metrics middleware to token method. func (mm *metricsMiddleware) Token(user sdk.User) (sdk.Token, error) { defer func(begin time.Time) { @@ -114,26 +134,6 @@ func (mm *metricsMiddleware) RefreshToken(refreshToken string) (sdk.Token, error return mm.svc.RefreshToken(refreshToken) } -// Logout adds metrics middleware to logout method. -func (mm *metricsMiddleware) Logout() (err error) { - defer func(begin time.Time) { - mm.counter.With("method", "logout").Add(1) - mm.latency.With("method", "logout").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.Logout() -} - -// UpdatePassword adds metrics middleware to update password method. -func (mm *metricsMiddleware) UpdatePassword(token, oldPass, newPass string) (err error) { - defer func(begin time.Time) { - mm.counter.With("method", "update_user_password").Add(1) - mm.latency.With("method", "update_user_password").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.UpdatePassword(token, oldPass, newPass) -} - // CreateUsers adds metrics middleware to create users method. func (mm *metricsMiddleware) CreateUsers(token string, users ...sdk.User) (err error) { defer func(begin time.Time) { @@ -224,6 +224,46 @@ func (mm *metricsMiddleware) DisableUser(token, id string) (err error) { return mm.svc.DisableUser(token, id) } +// ListUserGroups adds metrics middleware to list user groups method. +func (mm *metricsMiddleware) ListUserGroups(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_user_groups").Add(1) + mm.latency.With("method", "list_user_groups").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListUserGroups(token, userID, page, limit) +} + +// ListUserThings adds metrics middleware to list user things method. +func (mm *metricsMiddleware) ListUserThings(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_user_things").Add(1) + mm.latency.With("method", "list_user_things").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListUserThings(token, userID, page, limit) +} + +// ListUserChannels adds metrics middleware to list user channels method. +func (mm *metricsMiddleware) ListUserChannels(token, userID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_user_channels").Add(1) + mm.latency.With("method", "list_user_channels").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListUserChannels(token, userID, page, limit) +} + +// CreateThing adds metrics middleware to create things method. +func (mm *metricsMiddleware) CreateThing(thing sdk.Thing, token string) (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "create_thing").Add(1) + mm.latency.With("method", "create_thing").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.CreateThing(thing, token) +} + // CreateThings adds metrics middleware to create things method. func (mm *metricsMiddleware) CreateThings(token string, things ...sdk.Thing) (err error) { defer func(begin time.Time) { @@ -284,6 +324,16 @@ func (mm *metricsMiddleware) UpdateThingSecret(token, id, secret string) (err er return mm.svc.UpdateThingSecret(token, id, secret) } +// UpdateThingOwner adds metrics middleware to update thing owner method. +func (mm *metricsMiddleware) UpdateThingOwner(token string, thing sdk.Thing) (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "update_thing_owner").Add(1) + mm.latency.With("method", "update_thing_owner").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.UpdateThingOwner(token, thing) +} + // EnableThing adds metrics middleware to enable thing method. func (mm *metricsMiddleware) EnableThing(token, id string) (err error) { defer func(begin time.Time) { @@ -304,14 +354,54 @@ func (mm *metricsMiddleware) DisableThing(token, id string) (err error) { return mm.svc.DisableThing(token, id) } -// UpdateThingOwner adds metrics middleware to update thing owner method. -func (mm *metricsMiddleware) UpdateThingOwner(token string, thing sdk.Thing) (err error) { +// ShareThing adds metrics middleware to share thing method. +func (mm *metricsMiddleware) ShareThing(token, thingID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "update_thing_owner").Add(1) - mm.latency.With("method", "update_thing_owner").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "share_thing").Add(1) + mm.latency.With("method", "share_thing").Observe(float64(time.Since(begin).Seconds())) }(time.Now()) - return mm.svc.UpdateThingOwner(token, thing) + return mm.svc.ShareThing(token, thingID, req) +} + +// UnshareThing adds metrics middleware to unshare thing method. +func (mm *metricsMiddleware) UnshareThing(token, thingID string, req sdk.UsersRelationRequest) (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "unshare_thing").Add(1) + mm.latency.With("method", "unshare_thing").Observe(float64(time.Since(begin).Seconds())) + }(time.Now()) + + return mm.svc.UnshareThing(token, thingID, req) +} + +// ListThingUsers adds metrics middleware to list thing users method. +func (mm *metricsMiddleware) ListThingUsers(token, thingID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_thing_users").Add(1) + mm.latency.With("method", "list_thing_users").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListThingUsers(token, thingID, page, limit) +} + +// ListChannelsByThing adds metrics middleware to list channels by thing method. +func (mm *metricsMiddleware) ListChannelsByThing(token, thingID string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_channels_by_thing").Add(1) + mm.latency.With("method", "list_channels_by_thing").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListChannelsByThing(token, thingID, page, limit) +} + +// CreateChannel adds metrics middleware to create channel method. +func (mm *metricsMiddleware) CreateChannel(channel sdk.Channel, token string) (err error) { + defer func(begin time.Time) { + mm.counter.With("method", "create_channel").Add(1) + mm.latency.With("method", "create_channel").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.CreateChannel(channel, token) } // CreateChannels adds metrics middleware to create channels method. @@ -324,6 +414,16 @@ func (mm *metricsMiddleware) CreateChannels(token string, channels ...sdk.Channe return mm.svc.CreateChannels(token, channels...) } +// ListChannels adds metrics middleware to list channels method. +func (mm *metricsMiddleware) ListChannels(token string, page, limit uint64) (b []byte, err error) { + defer func(begin time.Time) { + mm.counter.With("method", "list_channels").Add(1) + mm.latency.With("method", "list_channels").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ListChannels(token, page, limit) +} + // ViewChannel adds metrics middleware to view channels method. func (mm *metricsMiddleware) ViewChannel(token, id string) (b []byte, err error) { defer func(begin time.Time) { @@ -344,14 +444,14 @@ func (mm *metricsMiddleware) UpdateChannel(token, id string, channel sdk.Channel return mm.svc.UpdateChannel(token, id, channel) } -// ListChannels adds metrics middleware to list channels method. -func (mm *metricsMiddleware) ListChannels(token string, page, limit uint64) (b []byte, err error) { +// ListThingsByChannel adds metrics middleware to list things by channel method. +func (mm *metricsMiddleware) ListThingsByChannel(token, channelID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "list_channels").Add(1) - mm.latency.With("method", "list_channels").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_things_by_channel").Add(1) + mm.latency.With("method", "list_things_by_channel").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ListChannels(token, page, limit) + return mm.svc.ListThingsByChannel(token, channelID, page, limit) } // EnableChannel adds metrics middleware to enable channel method. @@ -375,7 +475,7 @@ func (mm *metricsMiddleware) DisableChannel(token, id string) (err error) { } // Connect adds metrics middleware to connect method. -func (mm *metricsMiddleware) Connect(token string, connIDs sdk.ConnectionIDs) (err error) { +func (mm *metricsMiddleware) Connect(token string, connIDs sdk.Connection) (err error) { defer func(begin time.Time) { mm.counter.With("method", "connect").Add(1) mm.latency.With("method", "connect").Observe(time.Since(begin).Seconds()) @@ -385,7 +485,7 @@ func (mm *metricsMiddleware) Connect(token string, connIDs sdk.ConnectionIDs) (e } // Disconnect adds metrics middleware to disconnect method. -func (mm *metricsMiddleware) Disconnect(token string, connIDs sdk.ConnectionIDs) (err error) { +func (mm *metricsMiddleware) Disconnect(token string, connIDs sdk.Connection) (err error) { defer func(begin time.Time) { mm.counter.With("method", "disconnect").Add(1) mm.latency.With("method", "disconnect").Observe(time.Since(begin).Seconds()) @@ -394,44 +494,14 @@ func (mm *metricsMiddleware) Disconnect(token string, connIDs sdk.ConnectionIDs) return mm.svc.Disconnect(token, connIDs) } -// ListThingsByChannel adds metrics middleware to list things by channel method. -func (mm *metricsMiddleware) ListThingsByChannel(token, id string, page, limit uint64) (b []byte, err error) { - defer func(begin time.Time) { - mm.counter.With("method", "list_things_by_channel").Add(1) - mm.latency.With("method", "list_things_by_channel").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.ListThingsByChannel(token, id, page, limit) -} - -// ListChannelsByThing adds metrics middleware to list channels by thing method. -func (mm *metricsMiddleware) ListChannelsByThing(token, id string, page, limit uint64) (b []byte, err error) { - defer func(begin time.Time) { - mm.counter.With("method", "list_channels_by_thing").Add(1) - mm.latency.With("method", "list_channels_by_thing").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.ListChannelsByThing(token, id, page, limit) -} - // ConnectThing adds metrics middleware to connect thing method. -func (mm *metricsMiddleware) ConnectThing(token string, connIDs sdk.ConnectionIDs) (err error) { +func (mm *metricsMiddleware) ConnectThing(thingID, chanID, token string) (err error) { defer func(begin time.Time) { mm.counter.With("method", "connect_thing").Add(1) mm.latency.With("method", "connect_thing").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ConnectThing(token, connIDs) -} - -// ShareThing adds metrics middleware to share thing method. -func (mm *metricsMiddleware) ShareThing(token, chanID, userID string, actions []string) (err error) { - defer func(begin time.Time) { - mm.counter.With("method", "share_thing").Add(1) - mm.latency.With("method", "share_thing").Observe(float64(time.Since(begin).Seconds())) - }(time.Now()) - - return mm.svc.ShareThing(token, chanID, userID, actions) + return mm.svc.ConnectThing(thingID, chanID, token) } // DisconnectThing adds metrics middleware to disconnect thing method. @@ -444,64 +514,64 @@ func (mm *metricsMiddleware) DisconnectThing(thID, chID, token string) (err erro return mm.svc.DisconnectThing(thID, chID, token) } -// ConnectChannel adds metrics middleware to connect channel method. -func (mm *metricsMiddleware) ConnectChannel(token string, connIDs sdk.ConnectionIDs) (err error) { +// AddUserToChannel adds metrics middleware to add user to channel method. +func (mm *metricsMiddleware) AddUserToChannel(token, channelID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "connect_channel").Add(1) - mm.latency.With("method", "connect_channel").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "add_user_to_channel").Add(1) + mm.latency.With("method", "add_user_to_channel").Observe(float64(time.Since(begin).Seconds())) }(time.Now()) - return mm.svc.ConnectChannel(token, connIDs) + return mm.svc.AddUserToChannel(token, channelID, req) } -// DisconnectChannel adds metrics middleware to disconnect channel method. -func (mm *metricsMiddleware) DisconnectChannel(thID, chID, token string) (err error) { +// RemoveUserFromChannel adds metrics middleware to remove user from channel method. +func (mm *metricsMiddleware) RemoveUserFromChannel(token, channelID string, req sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "disconnect_channel").Add(1) - mm.latency.With("method", "disconnect_channel").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "remove_user_from_channel").Add(1) + mm.latency.With("method", "remove_user_from_channel").Observe(float64(time.Since(begin).Seconds())) }(time.Now()) - return mm.svc.DisconnectChannel(thID, chID, token) + return mm.svc.RemoveUserFromChannel(token, channelID, req) } -// ListThingsPolicies adds metrics middleware to list things policies method. -func (mm *metricsMiddleware) ListThingsPolicies(token string, page, limit uint64) (b []byte, err error) { +// ListChannelUsers adds metrics middleware to list channel users method. +func (mm *metricsMiddleware) ListChannelUsers(token, channelID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "list_things_policies").Add(1) - mm.latency.With("method", "list_things_policies").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_channel_users").Add(1) + mm.latency.With("method", "list_channel_users").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ListThingsPolicies(token, page, limit) + return mm.svc.ListChannelUsers(token, channelID, page, limit) } -// AddThingsPolicy adds metrics middleware to add things policy method. -func (mm *metricsMiddleware) AddThingsPolicy(token string, policy sdk.Policy) (err error) { +// AddUserGroupToChannel adds metrics middleware to add usergroup to channel method. +func (mm *metricsMiddleware) AddUserGroupToChannel(token, channelID string, req sdk.UserGroupsRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "add_things_policy").Add(1) - mm.latency.With("method", "add_things_policy").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "add_usergroup_to_channel").Add(1) + mm.latency.With("method", "add_usergroup_to_channel").Observe(float64(time.Since(begin).Seconds())) }(time.Now()) - return mm.svc.AddThingsPolicy(token, policy) + return mm.svc.AddUserGroupToChannel(token, channelID, req) } -// DeleteThingsPolicy adds metrics middleware to delete things policy method. -func (mm *metricsMiddleware) DeleteThingsPolicy(token string, policy sdk.Policy) (err error) { +// RemoveUserGroupFromChannel adds metrics middleware to remove usergroup from channel method. +func (mm *metricsMiddleware) RemoveUserGroupFromChannel(token, channelID string, req sdk.UserGroupsRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "delete_things_policy").Add(1) - mm.latency.With("method", "delete_things_policy").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "remove_usergroup_from_channel").Add(1) + mm.latency.With("method", "remove_usergroup_from_channel").Observe(float64(time.Since(begin).Seconds())) }(time.Now()) - return mm.svc.DeleteThingsPolicy(token, policy) + return mm.svc.RemoveUserGroupFromChannel(token, channelID, req) } -// UpdateThingsPolicy adds metrics middleware to update things policy method. -func (mm *metricsMiddleware) UpdateThingsPolicy(token string, policy sdk.Policy) (err error) { +// ListChannelUserGroups adds metrics middleware to list channel usergroups method. +func (mm *metricsMiddleware) ListChannelUserGroups(token, channelID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "update_things_policy").Add(1) - mm.latency.With("method", "update_things_policy").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_channel_usergroups").Add(1) + mm.latency.With("method", "list_channel_usergroups").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.UpdateThingsPolicy(token, policy) + return mm.svc.ListChannelUserGroups(token, channelID, page, limit) } // CreateGroups adds metrics middleware to create groups method. @@ -514,64 +584,64 @@ func (mm *metricsMiddleware) CreateGroups(token string, groups ...sdk.Group) (er return mm.svc.CreateGroups(token, groups...) } -// ListGroups adds metrics middleware to list groups method. -func (mm *metricsMiddleware) ListGroups(token string, page, limit uint64) (b []byte, err error) { +// ListGroupUsers adds metrics middleware to list group users method. +func (mm *metricsMiddleware) ListGroupUsers(token, id string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "list_groups").Add(1) - mm.latency.With("method", "list_groups").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_group_users").Add(1) + mm.latency.With("method", "list_group_users").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ListGroups(token, page, limit) + return mm.svc.ListGroupUsers(token, id, page, limit) } -// ViewGroup adds metrics middleware to view group method. -func (mm *metricsMiddleware) ViewGroup(token, id string) (b []byte, err error) { +// Assign adds metrics middleware to assign method. +func (mm *metricsMiddleware) Assign(token, groupID string, userRelation sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "view_group").Add(1) - mm.latency.With("method", "view_group").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "assign").Add(1) + mm.latency.With("method", "assign").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ViewGroup(token, id) + return mm.svc.Assign(token, groupID, userRelation) } -// ListGroupMembers adds metrics middleware to list group members method. -func (mm *metricsMiddleware) ListGroupMembers(token, id string, page, limit uint64) (b []byte, err error) { +// Unassign adds metrics middleware to unassign method. +func (mm *metricsMiddleware) Unassign(token, groupID string, userRelation sdk.UsersRelationRequest) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "list_group_members").Add(1) - mm.latency.With("method", "list_group_members").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "unassign").Add(1) + mm.latency.With("method", "unassign").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ListGroupMembers(token, id, page, limit) + return mm.svc.Unassign(token, groupID, userRelation) } -// UpdateGroup adds metrics middleware to update group method. -func (mm *metricsMiddleware) UpdateGroup(token, id string, group sdk.Group) (err error) { +// ViewGroup adds metrics middleware to view group method. +func (mm *metricsMiddleware) ViewGroup(token, id string) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "update_group").Add(1) - mm.latency.With("method", "update_group").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "view_group").Add(1) + mm.latency.With("method", "view_group").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.UpdateGroup(token, id, group) + return mm.svc.ViewGroup(token, id) } -// Assign adds metrics middleware to assign method. -func (mm *metricsMiddleware) Assign(token, groupID, memberID string, memberType []string) (err error) { +// UpdateGroup adds metrics middleware to update group method. +func (mm *metricsMiddleware) UpdateGroup(token, id string, group sdk.Group) (err error) { defer func(begin time.Time) { - mm.counter.With("method", "assign").Add(1) - mm.latency.With("method", "assign").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "update_group").Add(1) + mm.latency.With("method", "update_group").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.Assign(token, groupID, memberID, memberType) + return mm.svc.UpdateGroup(token, id, group) } -// Unassign adds metrics middleware to unassign method. -func (mm *metricsMiddleware) Unassign(token, groupID, memberID string) (err error) { +// ListGroups adds metrics middleware to list groups method. +func (mm *metricsMiddleware) ListGroups(token string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "unassign").Add(1) - mm.latency.With("method", "unassign").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_groups").Add(1) + mm.latency.With("method", "list_groups").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.Unassign(token, groupID, memberID) + return mm.svc.ListGroups(token, page, limit) } // Enable group adds metrics middleware to enable group method. @@ -594,44 +664,34 @@ func (mm *metricsMiddleware) DisableGroup(token, id string) (err error) { return mm.svc.DisableGroup(token, id) } -// AddPolicy adds metrics middleware to add policy method. -func (mm *metricsMiddleware) AddPolicy(token string, policy sdk.Policy) (err error) { - defer func(begin time.Time) { - mm.counter.With("method", "add_policy").Add(1) - mm.latency.With("method", "add_policy").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.AddPolicy(token, policy) -} - -// ListPolicies adds metrics middleware to list policies method. -func (mm *metricsMiddleware) ListPolicies(token string, page, limit uint64) (b []byte, err error) { +// ListParents adds metrics middleware to list parents method. +func (mm *metricsMiddleware) ListParents(token, groupID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "list_policies").Add(1) - mm.latency.With("method", "list_policies").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_parents").Add(1) + mm.latency.With("method", "list_parents").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.ListPolicies(token, page, limit) + return mm.svc.ListParents(token, groupID, page, limit) } -// UpdatePolicy adds metrics middleware to update policy method. -func (mm *metricsMiddleware) UpdatePolicy(token string, policy sdk.Policy) (err error) { +// ListChildren adds metrics middleware to list children method. +func (mm *metricsMiddleware) ListChildren(token, groupID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "update_policy").Add(1) - mm.latency.With("method", "update_policy").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_children").Add(1) + mm.latency.With("method", "list_children").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.UpdatePolicy(token, policy) + return mm.svc.ListChildren(token, groupID, page, limit) } -// DeletePolicy adds metrics middleware to delete policy method. -func (mm *metricsMiddleware) DeletePolicy(token string, policy sdk.Policy) (err error) { +// ListUSerGroupChannels adds metrics middleware to list usergroup channels method. +func (mm *metricsMiddleware) ListUserGroupChannels(token, userID string, page, limit uint64) (b []byte, err error) { defer func(begin time.Time) { - mm.counter.With("method", "delete_policy").Add(1) - mm.latency.With("method", "delete_policy").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "list_usergroup_channels").Add(1) + mm.latency.With("method", "list_usergroup_channels").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.DeletePolicy(token, policy) + return mm.svc.ListUserGroupChannels(token, userID, page, limit) } // Publish adds metrics middleware to publish method. @@ -664,26 +724,6 @@ func (mm *metricsMiddleware) WsConnection(token, chID, thKey string) (b []byte, return mm.svc.WsConnection(token, chID, thKey) } -// GetRemoteTerminal adds metrics middleware to get remote terminal method. -func (mm *metricsMiddleware) GetRemoteTerminal(id, token string) ([]byte, error) { - defer func(begin time.Time) { - mm.counter.With("method", "remote_terminal").Add(1) - mm.latency.With("method", "remote_terminal").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.GetRemoteTerminal(id, token) -} - -// ProcessTerminalCommand adds metrics middleware to process terminal command method. -func (mm *metricsMiddleware) ProcessTerminalCommand(ctx context.Context, id, token, command string, res chan string) error { - defer func(begin time.Time) { - mm.counter.With("method", "remote_terminal").Add(1) - mm.latency.With("method", "remote_terminal").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.ProcessTerminalCommand(ctx, id, token, command, res) -} - // CreateBootstrap adds metrics middleware to create bootstrap method. func (mm *metricsMiddleware) CreateBootstrap(token string, config ...sdk.BootstrapConfig) error { defer func(begin time.Time) { @@ -694,16 +734,6 @@ func (mm *metricsMiddleware) CreateBootstrap(token string, config ...sdk.Bootstr return mm.svc.CreateBootstrap(token, config...) } -// DeleteBootstrap adds metrics middleware to delete bootstrap method. -func (mm *metricsMiddleware) DeleteBootstrap(token string, id string) error { - defer func(begin time.Time) { - mm.counter.With("method", "delete_bootstrap").Add(1) - mm.latency.With("method", "delete_bootstrap").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return mm.svc.DeleteBootstrap(token, id) -} - // ListBootstrap adds metrics middleware to list bootstrap method. func (mm *metricsMiddleware) ListBootstrap(token string, page, limit uint64) ([]byte, error) { defer func(begin time.Time) { @@ -724,6 +754,16 @@ func (mm *metricsMiddleware) UpdateBootstrap(token string, config sdk.BootstrapC return mm.svc.UpdateBootstrap(token, config) } +// UpdateBootstrapConnections adds metrics middleware to update bootstrap connections method. +func (mm *metricsMiddleware) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) error { + defer func(begin time.Time) { + mm.counter.With("method", "update_bootstrap_connections").Add(1) + mm.latency.With("method", "update_bootstrap_connections").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.UpdateBootstrapConnections(token, config) +} + // UpdateBootstrapCerts adds metrics middleware to update bootstrap certs method. func (mm *metricsMiddleware) UpdateBootstrapCerts(token string, config sdk.BootstrapConfig) error { defer func(begin time.Time) { @@ -734,14 +774,14 @@ func (mm *metricsMiddleware) UpdateBootstrapCerts(token string, config sdk.Boots return mm.svc.UpdateBootstrapCerts(token, config) } -// UpdateBootstrapConnections adds metrics middleware to update bootstrap connections method. -func (mm *metricsMiddleware) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) error { +// DeleteBootstrap adds metrics middleware to delete bootstrap method. +func (mm *metricsMiddleware) DeleteBootstrap(token string, id string) error { defer func(begin time.Time) { - mm.counter.With("method", "update_bootstrap_connections").Add(1) - mm.latency.With("method", "update_bootstrap_connections").Observe(time.Since(begin).Seconds()) + mm.counter.With("method", "delete_bootstrap").Add(1) + mm.latency.With("method", "delete_bootstrap").Observe(time.Since(begin).Seconds()) }(time.Now()) - return mm.svc.UpdateBootstrapConnections(token, config) + return mm.svc.DeleteBootstrap(token, id) } // ViewBootstrap adds metrics middleware to view bootstrap method. @@ -754,6 +794,27 @@ func (mm *metricsMiddleware) ViewBootstrap(token string, id string) ([]byte, err return mm.svc.ViewBootstrap(token, id) } +// GetRemoteTerminal adds metrics middleware to get remote terminal method. +func (mm *metricsMiddleware) GetRemoteTerminal(id, token string) ([]byte, error) { + defer func(begin time.Time) { + mm.counter.With("method", "remote_terminal").Add(1) + mm.latency.With("method", "remote_terminal").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.GetRemoteTerminal(id, token) +} + +// ProcessTerminalCommand adds metrics middleware to process terminal command method. +func (mm *metricsMiddleware) ProcessTerminalCommand(ctx context.Context, id, token, command string, res chan string) error { + defer func(begin time.Time) { + mm.counter.With("method", "remote_terminal").Add(1) + mm.latency.With("method", "remote_terminal").Observe(time.Since(begin).Seconds()) + }(time.Now()) + + return mm.svc.ProcessTerminalCommand(ctx, id, token, command, res) +} + +// GetEntities adds metrics middleware to get entities method. func (mm *metricsMiddleware) GetEntities(token, item, name string, page, limit uint64) ([]byte, error) { defer func(begin time.Time) { mm.counter.With("method", "get_entities").Add(1) @@ -763,6 +824,7 @@ func (mm *metricsMiddleware) GetEntities(token, item, name string, page, limit u return mm.svc.GetEntities(token, item, name, page, limit) } +// ErrorPage adds metrics middleware to error page method. func (mm *metricsMiddleware) ErrorPage(errMsg string) ([]byte, error) { defer func(begin time.Time) { mm.counter.With("method", "errorpage").Add(1) diff --git a/ui/api/requests.go b/ui/api/requests.go index 1643757c..a0bbd324 100644 --- a/ui/api/requests.go +++ b/ui/api/requests.go @@ -460,30 +460,28 @@ func (req updateChannelReq) validate() error { type connectThingReq struct { token string - ConnIDs sdk.ConnectionIDs + ThingID string `json:"thingID,omitempty"` + ChanID string `json:"chanID,omitempty"` } func (req connectThingReq) validate() error { if req.token == "" { return errAuthorization } - if len(req.ConnIDs.ChannelIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.ThingIDs) == 0 { + if req.ChanID == "" { return errMalformedEntity } - if len(req.ConnIDs.Actions) == 0 { + if req.ThingID == "" { return errMalformedEntity } return nil } type shareThingReq struct { - token string - UserID string `json:"user_id"` - ChanID string `json:"channel_id"` - Actions []string `json:"actions"` + token string + ThingID string `json:"thingID,omitempty"` + UserID string `json:"userID,omitempty"` + Relation string `json:"relation,omitempty"` } func (req shareThingReq) validate() error { @@ -493,120 +491,12 @@ func (req shareThingReq) validate() error { if req.UserID == "" { return errMalformedEntity } - if req.ChanID == "" { - return errMalformedEntity - } - if len(req.Actions) == 0 { - return errMalformedEntity - } - return nil -} - -type connectChannelReq struct { - token string - ConnIDs sdk.ConnectionIDs `json:"connection_ids"` -} - -func (req connectChannelReq) validate() error { - if req.token == "" { - return errAuthorization - } - if len(req.ConnIDs.ChannelIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.ThingIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - -type connectReq struct { - token string - ConnIDs sdk.ConnectionIDs `json:"connection_ids"` -} - -func (req connectReq) validate() error { - if req.token == "" { - return errAuthorization - } - if len(req.ConnIDs.ChannelIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.ThingIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - -type disconnectThingReq struct { - token string - ChanID string `json:"chan_id,omitempty"` - ThingID string `json:"thing_id,omitempty"` -} - -func (req disconnectThingReq) validate() error { - if req.token == "" { - return errAuthorization - } - - if req.ChanID == "" { - return errMalformedEntity - } if req.ThingID == "" { return errMalformedEntity } - - return nil -} - -type disconnectChannelReq struct { - token string - ChanID string `json:"chan_id,omitempty"` - ThingID string `json:"thing_id,omitempty"` -} - -func (req disconnectChannelReq) validate() error { - if req.token == "" { - return errAuthorization - } - - if req.ChanID == "" { - return errMalformedEntity - } - if req.ThingID == "" { - return errMalformedEntity - } - - return nil -} - -type disconnectReq struct { - token string - ConnIDs sdk.ConnectionIDs `json:"connection_ids"` -} - -func (req disconnectReq) validate() error { - if req.token == "" { - return errAuthorization - } - if len(req.ConnIDs.ChannelIDs) == 0 { - return errMalformedEntity - } - if len(req.ConnIDs.ThingIDs) == 0 { + if req.Relation == "" { return errMalformedEntity } - if len(req.ConnIDs.Actions) == 0 { - return errMalformedEntity - } - return nil } @@ -626,50 +516,6 @@ func (req updateChannelStatusReq) validate() error { return nil } -type addThingsPolicyReq struct { - token string - Policy sdk.Policy `json:"policy,omitempty"` -} - -func (req addThingsPolicyReq) validate() error { - if req.token == "" { - return errAuthorization - } - if req.Policy.Subject == "" { - return errMalformedEntity - } - if req.Policy.Object == "" { - return errMalformedEntity - } - if len(req.Policy.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - -type deleteThingsPolicyReq struct { - token string - Policy sdk.Policy `json:"policy,omitempty"` -} - -func (req deleteThingsPolicyReq) validate() error { - if req.token == "" { - return errAuthorization - } - if req.Policy.Subject == "" { - return errMalformedEntity - } - if req.Policy.Object == "" { - return errMalformedEntity - } - if len(req.Policy.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - type createGroupReq struct { token string Group sdk.Group @@ -729,9 +575,9 @@ func (req updateGroupReq) validate() error { type assignReq struct { token string - groupID string - Type []string `json:"Type,omitempty"` - MemberID string `json:"memberID,omitempty"` + GroupID string `json:"groupID"` + UserID string `json:"userID"` + Relation string `json:"relation"` } func (req assignReq) validate() error { @@ -739,34 +585,13 @@ func (req assignReq) validate() error { return errAuthorization } - if req.groupID == "" { - return errMalformedEntity - } - if req.MemberID == "" { - return errMalformedEntity - } - if len(req.Type) == 0 { + if req.GroupID == "" { return errMalformedEntity } - - return nil -} - -type unassignReq struct { - token string - groupID string - MemberID string `json:"memberId,omitempty"` -} - -func (req unassignReq) validate() error { - if req.token == "" { - return errAuthorization - } - - if req.groupID == "" { + if req.UserID == "" { return errMalformedEntity } - if req.MemberID == "" { + if req.Relation == "" { return errMalformedEntity } @@ -775,7 +600,7 @@ func (req unassignReq) validate() error { type updateGroupStatusReq struct { token string - GroupID string `json:"groupId,omitempty"` + GroupID string `json:"groupId"` } func (req updateGroupStatusReq) validate() error { @@ -789,71 +614,6 @@ func (req updateGroupStatusReq) validate() error { return nil } -type addPolicyReq struct { - token string - Policy sdk.Policy `json:"policy,omitempty"` -} - -func (req addPolicyReq) validate() error { - if req.token == "" { - return errAuthorization - } - if req.Policy.Subject == "" { - return errMalformedEntity - } - if req.Policy.Object == "" { - return errMalformedEntity - } - if len(req.Policy.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - -type updatePolicyReq struct { - token string - Policy sdk.Policy `json:"policy,omitempty"` -} - -func (req updatePolicyReq) validate() error { - if req.token == "" { - return errAuthorization - } - if req.Policy.Subject == "" { - return errMalformedEntity - } - if req.Policy.Object == "" { - return errMalformedEntity - } - if len(req.Policy.Actions) == 0 { - return errMalformedEntity - } - return nil -} - -type deletePolicyReq struct { - token string - Policy sdk.Policy `json:"policy,omitempty"` -} - -func (req deletePolicyReq) validate() error { - if req.token == "" { - return errAuthorization - } - if req.Policy.Subject == "" { - return errMalformedEntity - } - if req.Policy.Object == "" { - return errMalformedEntity - } - if len(req.Policy.Actions) == 0 { - return errMalformedEntity - } - - return nil -} - type publishReq struct { thingKey string token string @@ -1016,10 +776,10 @@ func (req createBootstrapReq) validate() error { type getEntitiesReq struct { token string - Page uint64 - Limit uint64 - Item string - Name string + Page uint64 `json:"page"` + Limit uint64 `json:"limit"` + Item string `json:"item"` + Name string `json:"name"` } func (req getEntitiesReq) validate() error { @@ -1050,3 +810,45 @@ func (req errorReq) validate() error { } return nil } + +type addUserToChannelReq struct { + token string + ChannelID string `json:"channelID"` + UserID string `json:"userID"` + Relation string `json:"relation"` +} + +func (req addUserToChannelReq) validate() error { + if req.token == "" { + return errAuthorization + } + if req.ChannelID == "" { + return errMalformedEntity + } + if req.UserID == "" { + return errMalformedEntity + } + if req.Relation == "" { + return errMalformedEntity + } + return nil +} + +type addUserGroupToChannelReq struct { + token string + GroupID string `json:"groupID"` + ChannelID string `json:"channelID"` +} + +func (req addUserGroupToChannelReq) validate() error { + if req.token == "" { + return errAuthorization + } + if req.ChannelID == "" { + return errMalformedEntity + } + if req.GroupID == "" { + return errMalformedEntity + } + return nil +} diff --git a/ui/api/transport.go b/ui/api/transport.go index e40f38bd..f14e39e9 100644 --- a/ui/api/transport.go +++ b/ui/api/transport.go @@ -167,58 +167,79 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { opts..., )) - r.Get("/users/policies", kithttp.NewServer( - listPoliciesEndpoint(svc), - decodeListPoliciesRequest, + r.Get("/users/:id", kithttp.NewServer( + viewUserEndpoint(svc), + decodeView, encodeResponse, opts..., )) - r.Post("/users/policies", kithttp.NewServer( - addPolicyEndpoint(svc), - decodeAddPolicyRequest, + r.Post("/users/:id", kithttp.NewServer( + updateUserEndpoint(svc), + decodeUserUpdate, encodeResponse, opts..., )) - r.Post("/users/policies/update", kithttp.NewServer( - updatePolicyEndpoint(svc), - decodeUpdatePolicyRequest, + r.Post("/users/:id/tags", kithttp.NewServer( + updateUserTagsEndpoint(svc), + decodeUserTagsUpdate, encodeResponse, opts..., )) - r.Post("/users/policies/delete", kithttp.NewServer( - deletePolicyEndpoint(svc), - decodeDeletePolicyRequest, + r.Post("/users/:id/identity", kithttp.NewServer( + updateUserIdentityEndpoint(svc), + decodeUserIdentityUpdate, encodeResponse, opts..., )) - r.Get("/users/:id", kithttp.NewServer( - viewUserEndpoint(svc), - decodeView, + r.Get("/users/:id/groups", kithttp.NewServer( + listUserGroupsEndpoint(svc), + decodeListUserGroupsRequest, encodeResponse, opts..., )) - r.Post("/users/:id", kithttp.NewServer( - updateUserEndpoint(svc), - decodeUserUpdate, + r.Post("/users/:id/groups/assign", kithttp.NewServer( + assignGroupEndpoint(svc), + decodeAssignGroupRequest, encodeResponse, opts..., )) - r.Post("/users/:id/tags", kithttp.NewServer( - updateUserTagsEndpoint(svc), - decodeUserTagsUpdate, + r.Post("/users/:id/groups/unassign", kithttp.NewServer( + unassignGroupEndpoint(svc), + decodeUnassignGroupRequest, encodeResponse, opts..., )) - r.Post("/users/:id/identity", kithttp.NewServer( - updateUserIdentityEndpoint(svc), - decodeUserIdentityUpdate, + r.Get("/users/:id/channels", kithttp.NewServer( + listUserChannelsEndpoint(svc), + decodeListUserChannelsRequest, + encodeResponse, + opts..., + )) + + r.Post("/users/:id/channels/assign", kithttp.NewServer( + AddChannelToUserEndpoint(svc), + decodeAddChannelToUserRequest, + encodeResponse, + opts..., + )) + + r.Post("/users/:id/channels/unassign", kithttp.NewServer( + RemoveChannelFromUserEndpoint(svc), + decodeRemoveChannelFromUserRequest, + encodeResponse, + opts..., + )) + + r.Get("/users/:id/things", kithttp.NewServer( + listUserThingsEndpoint(svc), + decodeListUserThingsRequest, encodeResponse, opts..., )) @@ -258,34 +279,6 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { opts..., )) - r.Get("/things/policies", kithttp.NewServer( - listThingsPoliciesEndpoint(svc), - decodeListPoliciesRequest, - encodeResponse, - opts..., - )) - - r.Post("/things/policies", kithttp.NewServer( - addThingsPolicyEndpoint(svc), - decodeAddThingsPolicyRequest, - encodeResponse, - opts..., - )) - - r.Post("/things/policies/update", kithttp.NewServer( - updateThingsPolicyEndpoint(svc), - decodeUpdatePolicyRequest, - encodeResponse, - opts..., - )) - - r.Post("/things/policies/delete", kithttp.NewServer( - deleteThingsPolicyEndpoint(svc), - decodeDeleteThingsPolicyRequest, - encodeResponse, - opts..., - )) - r.Get("/things/:id", kithttp.NewServer( viewThingEndpoint(svc), decodeView, @@ -328,20 +321,41 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { opts..., )) - r.Post("/things/:id/connect", kithttp.NewServer( + r.Post("/things/:id/channels/connect", kithttp.NewServer( connectChannelEndpoint(svc), decodeConnectChannel, encodeResponse, opts..., )) - r.Post("/disconnectChannel", kithttp.NewServer( + r.Post("/things/:id/channels/disconnect", kithttp.NewServer( disconnectChannelEndpoint(svc), decodeDisconnectChannel, encodeResponse, opts..., )) + r.Post("/things/:id/share", kithttp.NewServer( + shareThingEndpoint(svc), + decodeShareThingRequest, + encodeResponse, + opts..., + )) + + r.Post("/things/:id/unshare", kithttp.NewServer( + unshareThingEndpoint(svc), + decodeShareThingRequest, + encodeResponse, + opts..., + )) + + r.Get("/things/:id/users", kithttp.NewServer( + listThingUsersEndpoint(svc), + decodeListThingUsersRequest, + encodeResponse, + opts..., + )) + r.Post("/channels", kithttp.NewServer( createChannelEndpoint(svc), decodeChannelCreation, @@ -390,43 +404,64 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { encodeResponse, opts..., )) - r.Post("/channels/:id/connectThing", kithttp.NewServer( + r.Post("/channels/:id/things/connect", kithttp.NewServer( connectThingEndpoint(svc), decodeConnectThing, encodeResponse, opts..., )) - r.Post("/channels/:id/shareThing", kithttp.NewServer( - shareThingEndpoint(svc), - decodeShareThingRequest, + + r.Post("/channels/:id/things/disconnect", kithttp.NewServer( + disconnectThingEndpoint(svc), + decodeDisconnectThing, encodeResponse, opts..., )) - r.Post("/disconnectThing", kithttp.NewServer( - disconnectThingEndpoint(svc), - decodeDisconnectThing, + r.Get("/channels/:id/things", kithttp.NewServer( + listThingsByChannelEndpoint(svc), + decodeListEntityByIDRequest, encodeResponse, opts..., )) - r.Post("/connect", kithttp.NewServer( - connectEndpoint(svc), - decodeConnect, + r.Post("/channels/:id/users/assign", kithttp.NewServer( + AddUserToChannelEndpoint(svc), + decodeAddUserToChannelRequest, + encodeResponse, + opts..., + )) + r.Post("/channels/:id/users/unassign", kithttp.NewServer( + RemoveUserFromChannelEndpoint(svc), + decodeRemoveUserFromChannelRequest, encodeResponse, opts..., )) - r.Post("/disconnect", kithttp.NewServer( - disconnectEndpoint(svc), - decodeDisconnect, + r.Get("/channels/:id/users", kithttp.NewServer( + ListChannelUsersEndpoint(svc), + decodeListChannelUsersRequest, encodeResponse, opts..., )) - r.Get("/channels/:id/things", kithttp.NewServer( - listThingsByChannelEndpoint(svc), - decodeListEntityByIDRequest, + r.Post("/channels/:id/groups/assign", kithttp.NewServer( + addUserGroupToChannelEndpoint(svc), + decodeAddUserGroupToChannelRequest, + encodeResponse, + opts..., + )) + + r.Post("/channels/:id/groups/unassign", kithttp.NewServer( + removeUserGroupFromChannelEndpoint(svc), + decodeRemoveUserGroupFromChannelRequest, + encodeResponse, + opts..., + )) + + r.Get("/channels/:id/groups", kithttp.NewServer( + ListChannelUserGroupsEndpoint(svc), + decodeListChannelUserGroupsRequest, encodeResponse, opts..., )) @@ -473,8 +508,8 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { opts..., )) - r.Get("/groups/:id/members", kithttp.NewServer( - listGroupMembersEndpoint(svc), + r.Get("/groups/:id/users", kithttp.NewServer( + listGroupUsersEndpoint(svc), decodeListEntityByIDRequest, encodeResponse, opts..., @@ -487,20 +522,53 @@ func MakeHandler(svc ui.Service, instanceID string) http.Handler { opts..., )) - r.Post("/groups/:id/members", kithttp.NewServer( + r.Post("/groups/:id/users/assign", kithttp.NewServer( assignEndpoint(svc), decodeAssignRequest, encodeResponse, opts..., )) - r.Post("/groups/:id/unassign", kithttp.NewServer( + r.Post("/groups/:id/users/unassign", kithttp.NewServer( unassignEndpoint(svc), decodeUnassignRequest, encodeResponse, opts..., )) + r.Get("/groups/:id/parents", kithttp.NewServer( + listParentsEndpoint(svc), + decodeListParentsRequest, + encodeResponse, + opts..., + )) + r.Get("/groups/:id/children", kithttp.NewServer( + listChildrenEndpoint(svc), + decodeListChildrenRequest, + encodeResponse, + opts..., + )) + + r.Post("/groups/:id/channels/assign", kithttp.NewServer( + addChannelToUserGroupEndpoint(svc), + decodeAddChannelToUserGroupRequest, + encodeResponse, + opts..., + )) + r.Post("/groups/:id/channels/unassign", kithttp.NewServer( + removeChannelFromUserGroupEndpoint(svc), + decodeRemoveChannelFromUserGroupRequest, + encodeResponse, + opts..., + )) + + r.Get("/groups/:id/channels", kithttp.NewServer( + listUserGroupChannelsEndpoint(svc), + decodeListUserGroupChannelsRequest, + encodeResponse, + opts..., + )) + r.Post("/messages", kithttp.NewServer( publishMessageEndpoint(svc), decodePublishRequest, @@ -892,6 +960,156 @@ func decodeUserStatusUpdate(_ context.Context, r *http.Request) (interface{}, er return req, nil } +func decodeListUserGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err + } + + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, + } + return req, nil +} + +func decodeAssignGroupRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + + if err := r.ParseForm(); err != nil { + return nil, err + } + + req := assignReq{ + token: token, + UserID: bone.GetValue(r, "id"), + GroupID: r.Form.Get("groupID"), + Relation: r.Form.Get("relation"), + } + + return req, nil +} + +func decodeUnassignGroupRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + + if err := r.ParseForm(); err != nil { + return nil, err + } + + req := assignReq{ + token: token, + UserID: bone.GetValue(r, "id"), + GroupID: r.Form.Get("groupID"), + Relation: r.Form.Get("relation"), + } + + return req, nil +} + +func decodeListUserThingsRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err + } + + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, + } + return req, nil +} + +func decodeAddChannelToUserRequest(_ context.Context, r *http.Request) (interface{}, error) { + if err := r.ParseForm(); err != nil { + return nil, err + } + + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + + req := addUserToChannelReq{ + token: token, + UserID: bone.GetValue(r, "id"), + Relation: r.Form.Get("relation"), + ChannelID: r.Form.Get("channelID"), + } + + return req, nil +} + +func decodeRemoveChannelFromUserRequest(_ context.Context, r *http.Request) (interface{}, error) { + if err := r.ParseForm(); err != nil { + return nil, err + } + + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + + req := addUserToChannelReq{ + token: token, + UserID: bone.GetValue(r, "id"), + Relation: r.Form.Get("relation"), + ChannelID: r.Form.Get("channelID"), + } + + return req, nil + +} + +func decodeListUserChannelsRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err + } + + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, + } + return req, nil +} + func decodeThingCreation(_ context.Context, r *http.Request) (interface{}, error) { var meta map[string]interface{} if err := json.Unmarshal([]byte(r.PostFormValue("metadata")), &meta); err != nil { @@ -1105,6 +1323,49 @@ func decodeThingsCreation(_ context.Context, r *http.Request) (interface{}, erro } } +func decodeShareThingRequest(_ context.Context, r *http.Request) (interface{}, error) { + if err := r.ParseForm(); err != nil { + return nil, err + } + + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + + req := shareThingReq{ + token: token, + ThingID: bone.GetValue(r, "id"), + UserID: r.Form.Get("userID"), + Relation: r.Form.Get("relation"), + } + + return req, nil +} + +func decodeListThingUsersRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err + } + + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, + } + return req, nil +} + func decodeChannelCreation(_ context.Context, r *http.Request) (interface{}, error) { var meta map[string]interface{} if err := json.Unmarshal([]byte(r.PostFormValue("metadata")), &meta); err != nil { @@ -1212,244 +1473,213 @@ func decodeListChannelsRequest(_ context.Context, r *http.Request) (interface{}, } func decodeConnectThing(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } if err := r.ParseForm(); err != nil { return nil, err } - chanID := bone.GetValue(r, "id") - thingID := r.Form.Get("thingID") + + req := connectThingReq{ + token: token, + ChanID: bone.GetValue(r, "id"), + ThingID: r.Form.Get("thingID"), + } + + return req, nil +} + +func decodeConnectChannel(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - connIDs := sdk.ConnectionIDs{ - ChannelIDs: []string{chanID}, - ThingIDs: []string{thingID}, - Actions: r.PostForm["actions"], + + if err := r.ParseForm(); err != nil { + return nil, err } req := connectThingReq{ token: token, - ConnIDs: connIDs, + ChanID: r.Form.Get("channelID"), + ThingID: bone.GetValue(r, "id"), } return req, nil } -func decodeShareThingRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeDisconnectThing(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } - chanID := bone.GetValue(r, "id") - userID := r.Form.Get("userID") - actions := r.PostForm["actions"] token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - req := shareThingReq{ + req := connectThingReq{ token: token, - ChanID: chanID, - UserID: userID, - Actions: actions, + ThingID: r.Form.Get("thingID"), + ChanID: bone.GetValue(r, "id"), } + return req, nil } -func decodeConnectChannel(_ context.Context, r *http.Request) (interface{}, error) { +func decodeDisconnectChannel(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } - chanID := r.Form.Get("channelID") - thingID := bone.GetValue(r, "id") token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - connIDs := sdk.ConnectionIDs{ - ChannelIDs: []string{chanID}, - ThingIDs: []string{thingID}, - Actions: r.PostForm["actions"], - } - req := connectChannelReq{ + req := connectThingReq{ token: token, - ConnIDs: connIDs, + ChanID: r.Form.Get("channelID"), + ThingID: bone.GetValue(r, "id"), } return req, nil } -func decodeConnect(_ context.Context, r *http.Request) (interface{}, error) { +func decodeChannelStatusUpdate(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - file, handler, err := r.FormFile("thingsFile") - if err != nil { - return nil, err - } - defer file.Close() - if !strings.HasSuffix(handler.Filename, ".csv") { - return nil, errors.New("unsupported file type") - } - csvr := csv.NewReader(file) - - chanID := r.Form.Get("chanID") - - chanIDs := []string{} - thingIDs := []string{} - for { - row, err := csvr.Read() - if err != nil { - if err == io.EOF { - connIDs := sdk.ConnectionIDs{ - ChannelIDs: chanIDs, - ThingIDs: thingIDs, - } - req := connectReq{ - token: token, - ConnIDs: connIDs, - } - - return req, nil - } - return nil, err - } - thingIDs = append(thingIDs, string(row[0])) - chanIDs = append(chanIDs, chanID) + req := updateChannelStatusReq{ + token: token, + ChannelID: r.PostFormValue("channelID"), } + + return req, nil } -func decodeDisconnectThing(_ context.Context, r *http.Request) (interface{}, error) { +func decodeAddUserToChannelRequest(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } - chanID := r.Form.Get("channelID") - thingID := r.Form.Get("thingID") + token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - req := disconnectThingReq{ - token: token, - ChanID: chanID, - ThingID: thingID, + + req := addUserToChannelReq{ + token: token, + ChannelID: bone.GetValue(r, "id"), + Relation: r.Form.Get("relation"), + UserID: r.Form.Get("userID"), } return req, nil + } -func decodeDisconnectChannel(_ context.Context, r *http.Request) (interface{}, error) { +func decodeRemoveUserFromChannelRequest(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } - chanID := r.Form.Get("channelID") - thingID := r.Form.Get("thingID") + token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - req := disconnectChannelReq{ - token: token, - ChanID: chanID, - ThingID: thingID, + + req := addUserToChannelReq{ + token: token, + ChannelID: bone.GetValue(r, "id"), + Relation: r.Form.Get("relation"), + UserID: r.Form.Get("userID"), } return req, nil + } -func decodeDisconnect(_ context.Context, r *http.Request) (interface{}, error) { +func decodeListChannelUsersRequest(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - file, handler, err := r.FormFile("thingsFile") + page, err := readNumQuery[uint64](r, pageKey, defPage) if err != nil { return nil, err } - defer file.Close() - if !strings.HasSuffix(handler.Filename, ".csv") { - return nil, errors.New("unsupported file type") - } - csvr := csv.NewReader(file) - - chanID := r.Form.Get("chanID") - chanIDs := []string{} - thingIDs := []string{} - for { - row, err := csvr.Read() - if err != nil { - if err == io.EOF { - connIDs := sdk.ConnectionIDs{ - ChannelIDs: chanIDs, - ThingIDs: thingIDs, - } - req := disconnectReq{ - token: token, - ConnIDs: connIDs, - } - - return req, nil - } - - return nil, err - } - thingIDs = append(thingIDs, string(row[0])) - chanIDs = append(chanIDs, chanID) + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, } + return req, nil } -func decodeChannelStatusUpdate(_ context.Context, r *http.Request) (interface{}, error) { +func decodeAddUserGroupToChannelRequest(_ context.Context, r *http.Request) (interface{}, error) { + if err := r.ParseForm(); err != nil { + return nil, err + } + token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - req := updateChannelStatusReq{ + req := addUserGroupToChannelReq{ token: token, - ChannelID: r.PostFormValue("channelID"), + ChannelID: bone.GetValue(r, "id"), + GroupID: r.Form.Get("groupID"), } return req, nil + } -func decodeAddThingsPolicyRequest(_ context.Context, r *http.Request) (interface{}, error) { - token, err := tokenFromCookie(r, "token") - if err != nil { +func decodeRemoveUserGroupFromChannelRequest(_ context.Context, r *http.Request) (interface{}, error) { + if err := r.ParseForm(); err != nil { return nil, err } - policy := sdk.Policy{ - Subject: r.PostFormValue("subject"), - Object: r.PostFormValue("object"), - Actions: r.PostForm["actions"], + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err } - req := addThingsPolicyReq{ - token: token, - Policy: policy, + req := addUserGroupToChannelReq{ + token: token, + ChannelID: bone.GetValue(r, "id"), + GroupID: r.Form.Get("groupID"), } return req, nil } -func decodeDeleteThingsPolicyRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeListChannelUserGroupsRequest(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - - policy := sdk.Policy{ - Subject: r.PostFormValue("subject"), - Object: r.PostFormValue("object"), - Actions: r.PostForm["actions"], + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err } - req := deleteThingsPolicyReq{ - token: token, - Policy: policy, + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, } - return req, nil } @@ -1561,14 +1791,15 @@ func decodeAssignRequest(_ context.Context, r *http.Request) (interface{}, error return nil, err } - memberid := r.PostFormValue("memberID") - memberType := r.PostForm["Type"] + if err := r.ParseForm(); err != nil { + return nil, err + } req := assignReq{ token: token, - groupID: bone.GetValue(r, "id"), - MemberID: memberid, - Type: memberType, + GroupID: bone.GetValue(r, "id"), + UserID: r.Form.Get("userID"), + Relation: r.Form.Get("relation"), } return req, nil @@ -1579,12 +1810,16 @@ func decodeUnassignRequest(_ context.Context, r *http.Request) (interface{}, err if err != nil { return nil, err } - MemberID := r.PostFormValue("memberID") - req := unassignReq{ + if err := r.ParseForm(); err != nil { + return nil, err + } + + req := assignReq{ token: token, - groupID: bone.GetValue(r, "id"), - MemberID: MemberID, + GroupID: bone.GetValue(r, "id"), + UserID: r.Form.Get("userID"), + Relation: r.Form.Get("relation"), } return req, nil @@ -1604,7 +1839,7 @@ func decodeGroupStatusUpdate(_ context.Context, r *http.Request) (interface{}, e return req, nil } -func decodeListPoliciesRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeListParentsRequest(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err @@ -1618,78 +1853,97 @@ func decodeListPoliciesRequest(_ context.Context, r *http.Request) (interface{}, if err != nil { return nil, err } - - req := listEntityReq{ + req := listEntityByIDReq{ token: token, - page: page, + id: bone.GetValue(r, "id"), limit: limit, + page: page, } - return req, nil } -func decodeAddPolicyRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeListChildrenRequest(_ context.Context, r *http.Request) (interface{}, error) { token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - - policy := sdk.Policy{ - Subject: r.PostFormValue("subject"), - Object: r.PostFormValue("object"), - Actions: r.PostForm["actions"], + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err } - req := addPolicyReq{ - token: token, - Policy: policy, + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, } - return req, nil } -func decodeUpdatePolicyRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeAddChannelToUserGroupRequest(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } + token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - policy := sdk.Policy{ - Subject: r.Form.Get("subject"), - Object: r.Form.Get("object"), - Actions: r.PostForm["actions"], - } - - req := updatePolicyReq{ - token: token, - Policy: policy, + req := addUserGroupToChannelReq{ + token: token, + GroupID: bone.GetValue(r, "id"), + ChannelID: r.Form.Get("channelID"), } return req, nil } -func decodeDeletePolicyRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeRemoveChannelFromUserGroupRequest(_ context.Context, r *http.Request) (interface{}, error) { if err := r.ParseForm(); err != nil { return nil, err } + token, err := tokenFromCookie(r, "token") if err != nil { return nil, err } - policy := sdk.Policy{ - Object: r.Form.Get("object"), - Subject: r.Form.Get("subject"), + req := addUserGroupToChannelReq{ + token: token, + GroupID: bone.GetValue(r, "id"), + ChannelID: r.Form.Get("channelID"), } - req := deletePolicyReq{ - token: token, - Policy: policy, + return req, nil + +} + +func decodeListUserGroupChannelsRequest(_ context.Context, r *http.Request) (interface{}, error) { + token, err := tokenFromCookie(r, "token") + if err != nil { + return nil, err + } + page, err := readNumQuery[uint64](r, pageKey, defPage) + if err != nil { + return nil, err } + limit, err := readNumQuery[uint64](r, limitKey, defLimit) + if err != nil { + return nil, err + } + req := listEntityByIDReq{ + token: token, + id: bone.GetValue(r, "id"), + limit: limit, + page: page, + } return req, nil } @@ -2065,7 +2319,9 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { errors.Contains(err, ui.ErrFailedPublish), errors.Contains(err, ui.ErrFailedDelete), errors.Contains(err, ui.ErrExecTemplate), - errors.Contains(err, ui.ErrFailedDelete): + errors.Contains(err, ui.ErrFailedDelete), + errors.Contains(err, ui.ErrFailedShare), + errors.Contains(err, ui.ErrFailedUnshare): w.Header().Set("Location", "/error?error="+url.QueryEscape(displayError.Error())) w.WriteHeader(http.StatusSeeOther) diff --git a/ui/service.go b/ui/service.go index 5518cf6e..30c583b7 100644 --- a/ui/service.go +++ b/ui/service.go @@ -29,20 +29,16 @@ import ( ) const ( - templateDir = "ui/web/template" - enabled = "enabled" - disabled = "disabled" - statusAll = "all" - dashboardActive = "dashboard" - usersActive = "users" - thingsActive = "things" - usersPoliciesActive = "usersPolicies" - groupsActive = "groups" - channelsActive = "channels" - thingsPoliciesActive = "thingsPolicies" - disabledEntitiesActive = "disabled" - readMessagesActive = "readmessages" - bootstrapsActive = "bootstraps" + templateDir = "ui/web/template" + enabled = "enabled" + statusAll = "all" + dashboardActive = "dashboard" + usersActive = "users" + thingsActive = "things" + groupsActive = "groups" + channelsActive = "channels" + readMessagesActive = "readmessages" + bootstrapsActive = "bootstraps" ) type dataSummary struct { @@ -74,12 +70,17 @@ var ( "terminal", "channel", - "channelconn", + "channelthings", "channels", + "channelusers", + "channelgroups", "group", - "groupconn", + "groupusers", "groups", + "groupchannels", + // "parents", + // "children", "index", @@ -90,37 +91,41 @@ var ( "messagesread", "thing", - "thingconn", + "thingchannels", "things", - "thingspolicies", + "thingusers", "user", "users", - "userspolicies", - } - emptyData = struct{}{} - ErrToken = errors.New("failed to create token") - ErrTokenRefresh = errors.New("failed to refresh token") - ErrFailedCreate = errors.New("failed to create entity") - ErrFailedRetreive = errors.New("failed to retrieve entity") - ErrFailedUpdate = errors.New("failed to update entity") - ErrFailedEnable = errors.New("failed to enable entity") - ErrFailedDisable = errors.New("failed to disable entity") - ErrFailedAssign = errors.New("failed to assign entity") - ErrFailedUnassign = errors.New("failed to unassign entity") - ErrFailedConnect = errors.New("failed to connect entity") - ErrFailedDisconnect = errors.New("failed to disconnect entity") - ErrFailedCreatePolicy = errors.New("failed to create policy") - ErrFailedUpdatePolicy = errors.New("failed to update policy") - ErrFailedDeletePolicy = errors.New("failed to delete policy") - ErrExecTemplate = errors.New("failed to execute template") - ErrFailedReset = errors.New("failed to reset password") - ErrFailedResetRequest = errors.New("failed to send reset request email") - ErrFailedPublish = errors.New("failed to publish message") - ErrFailedDelete = errors.New("failed to delete entity") - - userActions = []string{"g_list", "g_update", "g_delete", "g_add", "c_list", "c_update", "c_delete"} - thingActions = []string{"m_read", "m_write"} + "usergroups", + "userchannels", + "userthings", + } + ErrToken = errors.New("failed to create token") + ErrTokenRefresh = errors.New("failed to refresh token") + ErrFailedCreate = errors.New("failed to create entity") + ErrFailedRetreive = errors.New("failed to retrieve entity") + ErrFailedUpdate = errors.New("failed to update entity") + ErrFailedEnable = errors.New("failed to enable entity") + ErrFailedDisable = errors.New("failed to disable entity") + ErrFailedAssign = errors.New("failed to assign entity") + ErrFailedUnassign = errors.New("failed to unassign entity") + ErrFailedConnect = errors.New("failed to connect entity") + ErrFailedDisconnect = errors.New("failed to disconnect entity") + ErrFailedCreatePolicy = errors.New("failed to create policy") + ErrFailedUpdatePolicy = errors.New("failed to update policy") + ErrFailedDeletePolicy = errors.New("failed to delete policy") + ErrExecTemplate = errors.New("failed to execute template") + ErrFailedReset = errors.New("failed to reset password") + ErrFailedUpdatePassword = errors.New("failed to update password") + ErrFailedResetRequest = errors.New("failed to send reset request email") + ErrFailedPublish = errors.New("failed to publish message") + ErrFailedDelete = errors.New("failed to delete entity") + ErrFailedShare = errors.New("failed to share entity") + ErrFailedUnshare = errors.New("failed to unshare entity") + emptyData = struct{}{} + groupRelations = []string{"owner", "admin", "editor", "viewer"} + thingRelations = []string{"owner"} ) // Service specifies service API. @@ -145,6 +150,7 @@ type Service interface { Token(user sdk.User) (sdk.Token, error) // RefreshToken retrieves a new access token and refresh token from the provided refresh token. RefreshToken(refreshToken string) (sdk.Token, error) + // CreateUsers creates new users. CreateUsers(token string, users ...sdk.User) error // ListUsers retrieves users owned/shared by a user. @@ -163,6 +169,15 @@ type Service interface { EnableUser(token, userID string) error // DisableUser updates the status of a user with the given ID to disabled. DisableUser(token, userID string) error + // ListUserGroups retrieves the groups a user belongs to. + ListUserGroups(token, userID string, page, limit uint64) (b []byte, err error) + // ListUserThings retrieves the things shared to a user. + ListUserThings(token, userID string, page, limit uint64) (b []byte, err error) + // ListUserChannels retrievs a list of channels that a user is connected to. + ListUserChannels(token, userID string, page, limit uint64) (b []byte, err error) + + // CreateThing creates a new thing. + CreateThing(thing sdk.Thing, token string) error // CreateThings creates new things. CreateThings(token string, things ...sdk.Thing) error // ListThings retrieves things owned/shared by a user. @@ -175,12 +190,23 @@ type Service interface { UpdateThingTags(token, id string, thing sdk.Thing) error // UpdateThingSecret updates the secret of the thing with the given ID. UpdateThingSecret(token, id, secret string) error - // UpdateThingOwner updates the owner of the thing with the given ID + // UpdateThingOwner updates the owner of the thing with the given ID. UpdateThingOwner(token string, thing sdk.Thing) error // EnableThing updates the status of the thing with the given ID to enabled. EnableThing(token, id string) error - // DisableThing updates the status of the thing with the given ID to disabled + // DisableThing updates the status of the thing with the given ID to disabled. DisableThing(token, id string) error + // ShareThing shares a thing with a user. + ShareThing(token, thingID string, req sdk.UsersRelationRequest) error + // UnshareThing unshares a thing with a user. + UnshareThing(token, thingID string, req sdk.UsersRelationRequest) error + // ListThingUsers retrieves users that share a thing. + ListThingUsers(token, thingID string, page, limit uint64) (b []byte, err error) + // ListChannelsByThing retrieves a list of channels based on the given thing ID. + ListChannelsByThing(token, thingID string, page, limit uint64) ([]byte, error) + + // CreateChannel creates a new channel. + CreateChannel(channel sdk.Channel, token string) error // CreateChannels creates new channels. CreateChannels(token string, channels ...sdk.Channel) error // ListChannels retrieves channels owned/shared by a user. @@ -189,44 +215,41 @@ type Service interface { ViewChannel(token, id string) ([]byte, error) // UpdateChannel updates the channel with the given ID. UpdateChannel(token, id string, channel sdk.Channel) error - // ListChannelsByThing retrieves a list of channels based on the given thing ID. - ListChannelsByThing(token, id string, page, limit uint64) ([]byte, error) // ListThingsByChannel retrieves a list of things based on the given channel ID. - ListThingsByChannel(token, id string, page, limit uint64) ([]byte, error) + ListThingsByChannel(token, channelID string, page, limit uint64) ([]byte, error) // EnableChannel updates the status of the channel with the given ID to enabled. EnableChannel(token, id string) error // DisableChannel updates the status of the channel with the given ID to disabled. DisableChannel(token, id string) error // Connect bulk connects things to channel(s) specified by ID. - Connect(token string, connIDs sdk.ConnectionIDs) error + Connect(token string, connIDs sdk.Connection) error // Disconnect bulk disconnects thinfs to channel(s) specified by ID. - Disconnect(token string, connIDs sdk.ConnectionIDs) error + Disconnect(token string, connIDs sdk.Connection) error // ConnectThing connects a thing to a channel specified by ID. - ConnectThing(token string, connIDs sdk.ConnectionIDs) error - // ShareThing shares things connected to a channel with a user - ShareThing(token, chanID, userID string, actions []string) error + ConnectThing(thingID, chanID, token string) error // DisconnectThing disconnects a thing from a channel specified by ID. DisconnectThing(thID, chID, token string) error - // Connect Channel connects a channel to a thing specified by ID. - ConnectChannel(token string, connIDs sdk.ConnectionIDs) error - // DisconnectChannel disconnects a channel from a thing specified by ID. - DisconnectChannel(thID, chID, token string) error - // AddThingsPolicy adds a thing's policy on a channel. - AddThingsPolicy(token string, Policy sdk.Policy) error - // DeleteThingsPolicy removes a thing's policy on a channel - DeleteThingsPolicy(token string, policy sdk.Policy) error - // ListThingsPolicies retrieves the policies of things. - ListThingsPolicies(token string, page, limit uint64) ([]byte, error) - // UpdateThingsPolicy updates the policy that a thing has over a channel. - UpdateThingsPolicy(token string, policy sdk.Policy) error + // AddUserToChannel adds a user to a channel. + AddUserToChannel(token, channelID string, req sdk.UsersRelationRequest) error + // RemoveUserFromChannel removes a user from a channel. + RemoveUserFromChannel(token, channelID string, req sdk.UsersRelationRequest) error + // ListChannelUsers retrieves a list of users that are connected to a channel. + ListChannelUsers(token, channelID string, page, limit uint64) (b []byte, err error) + // AddUserGroupToChannel adds a userGroup to a channel. + AddUserGroupToChannel(token, channelID string, req sdk.UserGroupsRequest) error + // RemoveUserGroupFromChannel removes a userGroup from a channel. + RemoveUserGroupFromChannel(token, channelID string, req sdk.UserGroupsRequest) error + // ListChannelUserGroups retrieves a list of userGroups connected to a channel. + ListChannelUserGroups(token, channelID string, page, limit uint64) (b []byte, err error) + // CreateGroups creates new groups. CreateGroups(token string, groups ...sdk.Group) error - // ListGroupMembers retrieves the members of a group with a given ID. - ListGroupMembers(token, id string, page, limit uint64) ([]byte, error) + // ListGroupUsers retrieves the members of a group with a given ID. + ListGroupUsers(token, id string, page, limit uint64) ([]byte, error) // Assign adds a user to a group. - Assign(token, groupID, memberID string, memberType []string) error + Assign(token, groupID string, userRelation sdk.UsersRelationRequest) error // Unassign removes a user from a group. - Unassign(token, groupID, memberID string) error + Unassign(token, groupID string, userRelation sdk.UsersRelationRequest) error // ViewGroup retrieves information about a group with a given ID. ViewGroup(token, id string) ([]byte, error) // UpdateGroup updates the group with the given ID. @@ -237,20 +260,20 @@ type Service interface { EnableGroup(token, id string) error // DisableGroup updates the status of the group to disabled. DisableGroup(token, id string) error - // AddPolicy adds a user's policy on a group effectively adding the user to the group. - AddPolicy(token string, policy sdk.Policy) error - // UpdatePolicy updates the policy a user has over a group. - UpdatePolicy(token string, policy sdk.Policy) error - // ListPolicies retrieves the policies of the users. - ListPolicies(token string, page, limit uint64) ([]byte, error) - // DeletePolicy removes a user's policies on a group effectively removing the user from the group. - DeletePolicy(token string, policy sdk.Policy) error + // ListParents retrieves the parents of a group. + ListParents(token, groupID string, page, limit uint64) (b []byte, err error) + // ListChildren retrieves the children of a group. + ListChildren(token, groupID string, page, limit uint64) (b []byte, err error) + // ListUserGroupChannels retrieves a list of channels that a userGroup is connected to. + ListUserGroupChannels(token, groupID string, page, limit uint64) (b []byte, err error) + // Publish facilitates a thing publishin messages to a channel. Publish(token, thKey string, msg *messaging.Message) error // ReadMessage facilitates a thing reading messages published in a channel. ReadMessage(token string) ([]byte, error) // WsConnection creates a web socket connection that allows continuous reading of messages published in a channel. WsConnection(token, chID, thKey string) ([]byte, error) + // CreateBootstrap creates a new bootstrap config. CreateBootstrap(token string, config ...sdk.BootstrapConfig) error // ListBootstrap retrieves all bootstrap configs. @@ -269,6 +292,7 @@ type Service interface { GetRemoteTerminal(id, token string) ([]byte, error) // ProcessTerminalCommand sends mqtt command to agent and retrieves a response asynchronously. ProcessTerminalCommand(ctx context.Context, id, token, command string, res chan string) error + // GetEntities retrieves all entities. GetEntities(token, item, name string, page, limit uint64) ([]byte, error) // ErrorPage displays an error page. @@ -294,105 +318,6 @@ func New(sdk sdk.SDK) (Service, error) { }, nil } -func parseTemplates(mfsdk sdk.SDK, templates []string) (tpl *template.Template, err error) { - tpl = template.New("mainflux") - tpl = tpl.Funcs(template.FuncMap{ - "toJSON": func(data map[string]interface{}) string { - if data == nil { - return "{}" - } - ret, err := json.Marshal(data) - if err != nil { - return "{}" - } - return string(ret) - }, - "toSlice": func(data []string) string { - if len(data) == 0 { - return "[]" - } - ret, err := json.Marshal(data) - if err != nil { - return "[]" - } - return string(ret) - }, - "contains": func(data []string, substring string) bool { - - return slices.Contains(data, substring) - }, - "authorizeUser": func(subject, object, action, entityType string) bool { - aReq := sdk.AccessRequest{ - Subject: subject, - Object: object, - Action: action, - EntityType: entityType, - } - - authorized, _ := mfsdk.AuthorizeUser(aReq, "") - - return authorized - }, - "authorizeThing": func(subject, object, action, entityType string) bool { - var aReq = sdk.AccessRequest{ - Subject: subject, - Object: object, - Action: action, - EntityType: entityType, - } - - authorizeThing, _, _ := mfsdk.AuthorizeThing(aReq, "") - - return authorizeThing - }, - "serviceUnavailable": func(service string) bool { - if _, err := mfsdk.Health(service); err != nil { - return true - } - return false - }, - "hasPrefix": func(s, prefix string) bool { - return strings.HasPrefix(s, prefix) - }, - "sub": func(num1, num2 int) int { - return num1 - num2 - }, - "add": func(num1, num2 int) int { - return num1 + num2 - }, - "max": func(a, b int) int { - if a > b { - return a - } - return b - }, - "min": func(a, b int) int { - if a < b { - return a - } - return b - }, - "fromTo": func(start, end int) []int { - var result []int - for i := start; i <= end; i++ { - result = append(result, i) - } - return result - }, - }) - - var tmplFiles []string - for _, value := range templates { - tmplFiles = append(tmplFiles, templateDir+"/"+value+".html") - } - tpl, err = tpl.ParseFiles(tmplFiles...) - if err != nil { - return nil, err - } - - return tpl, nil -} - func (us *uiService) Index(token string) (b []byte, err error) { pgm := sdk.PageMetadata{ Offset: uint64(0), @@ -493,6 +418,10 @@ func (us *uiService) Login() ([]byte, error) { return btpl.Bytes(), nil } +func (us *uiService) Logout() error { + return nil +} + func (us *uiService) PasswordResetRequest(email string) error { if err := us.sdk.ResetPasswordRequest(email); err != nil { return errors.Wrap(err, ErrFailedResetRequest) @@ -539,6 +468,14 @@ func (us *uiService) PasswordUpdate(token string) ([]byte, error) { return btpl.Bytes(), nil } +func (us *uiService) UpdatePassword(token, oldPass, newPass string) error { + _, err := us.sdk.UpdatePassword(oldPass, newPass, token) + if err != nil { + return errors.Wrap(err, ErrFailedUpdatePassword) + } + return nil +} + func (us *uiService) Token(user sdk.User) (sdk.Token, error) { token, err := us.sdk.CreateToken(user) if err != nil { @@ -556,17 +493,6 @@ func (us *uiService) RefreshToken(refreshToken string) (sdk.Token, error) { return token, nil } -func (us *uiService) Logout() error { - - return nil -} - -func (us *uiService) UpdatePassword(token, oldPass, newPass string) error { - _, err := us.sdk.UpdatePassword(oldPass, newPass, token) - - return err -} - func (us *uiService) CreateUsers(token string, users ...sdk.User) error { for i := range users { _, err := us.sdk.CreateUser(users[i], token) @@ -593,7 +519,7 @@ func (us *uiService) ListUsers(token string, page, limit uint64) ([]byte, error) user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } noOfPages := int(math.Ceil(float64(users.Total) / float64(limit))) @@ -628,19 +554,19 @@ func (us *uiService) ViewUser(token, userID string) (b []byte, err error) { } loggedUser, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } data := struct { NavbarActive string - ID string + UserID string User sdk.User - LoggedUser sdk.User + ViewedUser sdk.User }{ usersActive, userID, - user, loggedUser, + user, } var btpl bytes.Buffer @@ -699,6 +625,152 @@ func (us *uiService) DisableUser(token, userID string) error { return nil } +func (us *uiService) ListUserGroups(token, userID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + Visibility: statusAll, + } + groupsPage, err := us.sdk.ListUserGroups(userID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + noOfPages := int(math.Ceil(float64(groupsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + Groups []sdk.Group + User sdk.User + UserID string + Relations []string + CurrentPage int + Pages int + Limit int + }{ + usersActive, + groupsPage.Groups, + user, + userID, + groupRelations, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "usergroups", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil +} + +func (us *uiService) ListUserThings(token, userID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + } + thingsPage, err := us.sdk.ListUserThings(userID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + noOfPages := int(math.Ceil(float64(thingsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + Things []sdk.Thing + User sdk.User + UserID string + Relations []string + CurrentPage int + Pages int + Limit int + }{ + usersActive, + thingsPage.Things, + user, + userID, + thingRelations, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "userthings", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil + +} + +func (us *uiService) ListUserChannels(token, userID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + } + channelsPage, err := us.sdk.ListUserChannels(userID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + noOfPages := int(math.Ceil(float64(channelsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + Channels []sdk.Channel + User sdk.User + UserID string + Relations []string + CurrentPage int + Pages int + Limit int + }{ + usersActive, + channelsPage.Channels, + user, + userID, + groupRelations, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "userchannels", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil +} + +func (us *uiService) CreateThing(thing sdk.Thing, token string) error { + _, err := us.sdk.CreateThing(thing, token) + if err != nil { + return errors.Wrap(err, ErrFailedCreate) + } + + return nil +} + func (us *uiService) CreateThings(token string, things ...sdk.Thing) error { for _, thing := range things { _, err := us.sdk.CreateThing(thing, token) @@ -725,7 +797,7 @@ func (us *uiService) ListThings(token string, page, limit uint64) ([]byte, error user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } noOfPages := int(math.Ceil(float64(things.Total) / float64(limit))) @@ -759,7 +831,7 @@ func (us *uiService) ViewThing(token, id string) (b []byte, err error) { user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } data := struct { @@ -830,33 +902,147 @@ func (us *uiService) DisableThing(token, id string) error { return nil } -func (us *uiService) CreateChannels(token string, channels ...sdk.Channel) error { - for _, channel := range channels { - _, err := us.sdk.CreateChannel(channel, token) - if err != nil { - return errors.Wrap(err, ErrFailedCreate) - } +func (us *uiService) ShareThing(token, thingID string, req sdk.UsersRelationRequest) error { + if err := us.sdk.ShareThing(thingID, req, token); err != nil { + return errors.Wrap(err, ErrFailedShare) } return nil } -func (us *uiService) ListChannels(token string, page, limit uint64) ([]byte, error) { - offset := (page - 1) * limit +func (us *uiService) UnshareThing(token, thingID string, req sdk.UsersRelationRequest) error { + if err := us.sdk.UnshareThing(thingID, req, token); err != nil { + return errors.Wrap(err, ErrFailedUnshare) + } + + return nil +} +func (us *uiService) ListThingUsers(token, thingID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit pgm := sdk.PageMetadata{ - Offset: offset, - Limit: limit, - Visibility: statusAll, + Offset: offset, + Limit: limit, } - chsPage, err := us.sdk.Channels(pgm, token) + usersPage, err := us.sdk.ListThingUsers(thingID, pgm, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + noOfPages := int(math.Ceil(float64(usersPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + ThingID string + Users []sdk.User + User sdk.User + Relations []string + CurrentPage int + Pages int + Limit int + }{ + thingsActive, + thingID, + usersPage.Users, + user, + thingRelations, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "thingusers", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + return btpl.Bytes(), nil + +} + +func (us *uiService) ListChannelsByThing(token, thingID string, page, limit uint64) ([]byte, error) { + offset := (page - 1) * limit + + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + Visibility: statusAll, + } + + chsPage, err := us.sdk.ChannelsByThing(thingID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + noOfPages := int(math.Ceil(float64(chsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + ThingID string + Channels []sdk.Channel + User sdk.User + CurrentPage int + Pages int + Limit int + }{ + thingsActive, + thingID, + chsPage.Channels, + user, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "thingchannels", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + return btpl.Bytes(), nil +} + +func (us *uiService) CreateChannel(channel sdk.Channel, token string) error { + _, err := us.sdk.CreateChannel(channel, token) + if err != nil { + return errors.Wrap(err, ErrFailedCreate) + } + + return nil +} + +func (us *uiService) CreateChannels(token string, channels ...sdk.Channel) error { + for _, channel := range channels { + _, err := us.sdk.CreateChannel(channel, token) + if err != nil { + return errors.Wrap(err, ErrFailedCreate) + } + } + return nil +} + +func (us *uiService) ListChannels(token string, page, limit uint64) ([]byte, error) { + offset := (page - 1) * limit + + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + Visibility: statusAll, + } + chsPage, err := us.sdk.Channels(pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } noOfPages := int(math.Ceil(float64(chsPage.Total) / float64(limit))) @@ -892,7 +1078,7 @@ func (us *uiService) ViewChannel(token, id string) (b []byte, err error) { user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } data := struct { @@ -922,8 +1108,55 @@ func (us *uiService) UpdateChannel(token, id string, channel sdk.Channel) error return nil } +func (us *uiService) ListThingsByChannel(token, channelID string, page, limit uint64) ([]byte, error) { + offset := (page - 1) * limit + + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + Visibility: statusAll, + } + + thsPage, err := us.sdk.ThingsByChannel(channelID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + noOfPages := int(math.Ceil(float64(thsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + ChannelID string + Things []sdk.Thing + User sdk.User + CurrentPage int + Pages int + Limit int + }{ + channelsActive, + channelID, + thsPage.Things, + user, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "channelthings", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + return btpl.Bytes(), nil +} + func (us *uiService) EnableChannel(token, id string) error { - if _, err := us.sdk.EnableChannel(id, token); err != nil { + _, err := us.sdk.EnableChannel(id, token) + if err != nil { return errors.Wrap(err, ErrFailedEnable) } @@ -931,14 +1164,15 @@ func (us *uiService) EnableChannel(token, id string) error { } func (us *uiService) DisableChannel(token, id string) error { - if _, err := us.sdk.DisableChannel(id, token); err != nil { + _, err := us.sdk.DisableChannel(id, token) + if err != nil { return errors.Wrap(err, ErrFailedDisable) } return nil } -func (us *uiService) ConnectThing(token string, connIDs sdk.ConnectionIDs) error { +func (us *uiService) Connect(token string, connIDs sdk.Connection) error { if err := us.sdk.Connect(connIDs, token); err != nil { return errors.Wrap(err, ErrFailedConnect) } @@ -946,8 +1180,16 @@ func (us *uiService) ConnectThing(token string, connIDs sdk.ConnectionIDs) error return nil } -func (us *uiService) ShareThing(token, chanID, userID string, actions []string) error { - if err := us.sdk.ShareThing(chanID, userID, actions, token); err != nil { +func (us *uiService) Disconnect(token string, connIDs sdk.Connection) error { + if err := us.sdk.Disconnect(connIDs, token); err != nil { + return errors.Wrap(err, ErrFailedDisconnect) + } + + return nil +} + +func (us *uiService) ConnectThing(thingID, chanID, token string) error { + if err := us.sdk.ConnectThing(thingID, chanID, token); err != nil { return errors.Wrap(err, ErrFailedConnect) } @@ -960,144 +1202,147 @@ func (us *uiService) DisconnectThing(thID, chID, token string) error { } return nil + } -func (us *uiService) ConnectChannel(token string, connIDs sdk.ConnectionIDs) error { - if err := us.sdk.Connect(connIDs, token); err != nil { - return errors.Wrap(err, ErrFailedConnect) +func (gs *uiService) AddUserToChannel(token, channelID string, req sdk.UsersRelationRequest) error { + if err := gs.sdk.AddUserToChannel(channelID, req, token); err != nil { + return errors.Wrap(err, ErrFailedAssign) } return nil + } -func (us *uiService) DisconnectChannel(thID, chID, token string) error { - if err := us.sdk.DisconnectThing(thID, chID, token); err != nil { - return errors.Wrap(err, ErrFailedDisconnect) +func (gs *uiService) RemoveUserFromChannel(token, channelID string, req sdk.UsersRelationRequest) error { + if err := gs.sdk.RemoveUserFromChannel(channelID, req, token); err != nil { + return errors.Wrap(err, ErrFailedUnassign) } return nil + } -func (us *uiService) ListChannelsByThing(token, id string, page, limit uint64) ([]byte, error) { - thing, err := us.sdk.Thing(id, token) - if err != nil { - return []byte{}, errors.Wrap(err, ErrFailedRetreive) - } +func (us *uiService) ListChannelUsers(token, channelID string, page, limit uint64) (b []byte, err error) { offset := (page - 1) * limit - pgm := sdk.PageMetadata{ - Offset: offset, - Limit: limit, - Visibility: statusAll, + Offset: offset, + Limit: limit, } - - chsPage, err := us.sdk.ChannelsByThing(id, pgm, token) + usersPage, err := us.sdk.ListChannelUsers(channelID, pgm, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - noOfPages := int(math.Ceil(float64(chsPage.Total) / float64(limit))) + + noOfPages := int(math.Ceil(float64(usersPage.Total) / float64(limit))) data := struct { NavbarActive string - ID string - Thing sdk.Thing - Channels []sdk.Channel + ChannelID string + Users []sdk.User User sdk.User + Relations []string CurrentPage int Pages int Limit int }{ - thingsActive, - id, - thing, - chsPage.Channels, + channelsActive, + channelID, + usersPage.Users, user, + groupRelations, int(page), noOfPages, int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "thingconn", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "channelusers", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } return btpl.Bytes(), nil + } -func (us *uiService) Connect(token string, connIDs sdk.ConnectionIDs) error { - if err := us.sdk.Connect(connIDs, token); err != nil { - return errors.Wrap(err, ErrFailedConnect) +func (gs *uiService) AddUserGroupToChannel(token, channelID string, req sdk.UserGroupsRequest) error { + if err := gs.sdk.AddUserGroupToChannel(channelID, req, token); err != nil { + return errors.Wrap(err, ErrFailedAssign) } return nil } -func (us *uiService) Disconnect(token string, connIDs sdk.ConnectionIDs) error { - if err := us.sdk.Disconnect(connIDs, token); err != nil { - return errors.Wrap(err, ErrFailedDisconnect) +func (gs *uiService) RemoveUserGroupFromChannel(token, channelID string, req sdk.UserGroupsRequest) error { + if err := gs.sdk.RemoveUserGroupFromChannel(channelID, req, token); err != nil { + return errors.Wrap(err, ErrFailedUnassign) } return nil } -func (us *uiService) ListThingsByChannel(token, id string, page, limit uint64) ([]byte, error) { - channel, err := us.sdk.Channel(id, token) - if err != nil { - return []byte{}, errors.Wrap(err, ErrFailedRetreive) - } +func (us *uiService) ListChannelUserGroups(token, channelID string, page, limit uint64) (b []byte, err error) { offset := (page - 1) * limit - pgm := sdk.PageMetadata{ - Offset: offset, - Limit: limit, - Visibility: statusAll, + Offset: offset, + Limit: limit, } - - thsPage, err := us.sdk.ThingsByChannel(id, pgm, token) + groupsPage, err := us.sdk.ListChannelUserGroups(channelID, pgm, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - noOfPages := int(math.Ceil(float64(thsPage.Total) / float64(limit))) + noOfPages := int(math.Ceil(float64(groupsPage.Total) / float64(limit))) data := struct { NavbarActive string - ID string - Channel sdk.Channel - Things []sdk.Thing + Groups []sdk.Group User sdk.User + ChannelID string + Relations []string CurrentPage int Pages int Limit int }{ channelsActive, - id, - channel, - thsPage.Things, + groupsPage.Groups, user, + channelID, + groupRelations, int(page), noOfPages, int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "channelconn", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "channelgroups", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } + return btpl.Bytes(), nil + +} + +func (us *uiService) CreateGroups(token string, groups ...sdk.Group) error { + for _, group := range groups { + _, err := us.sdk.CreateGroup(group, token) + if err != nil { + return errors.Wrap(err, ErrFailedCreate) + } + } + + return nil } -func (us *uiService) ListThingsPolicies(token string, page, limit uint64) ([]byte, error) { +func (us *uiService) ListGroupUsers(token, id string, page, limit uint64) ([]byte, error) { offset := (page - 1) * limit pgm := sdk.PageMetadata{ @@ -1105,128 +1350,96 @@ func (us *uiService) ListThingsPolicies(token string, page, limit uint64) ([]byt Limit: limit, Visibility: statusAll, } - plcPage, err := us.sdk.ListThingPolicies(pgm, token) + + usersPage, err := us.sdk.ListGroupUsers(id, pgm, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - noOfPages := int(math.Ceil(float64(plcPage.Total) / float64(limit))) + noOfPages := int(math.Ceil(float64(usersPage.Total) / float64(limit))) data := struct { NavbarActive string - Policies []sdk.Policy + GroupID string + Users []sdk.User User sdk.User - Actions []string + Relations []string CurrentPage int Pages int Limit int }{ - thingsPoliciesActive, - plcPage.Policies, + groupsActive, + id, + usersPage.Users, user, - thingActions, + groupRelations, int(page), noOfPages, int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "thingsPolicies", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "groupusers", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } - return btpl.Bytes(), nil } -func (us *uiService) AddThingsPolicy(token string, policy sdk.Policy) error { - if err := us.sdk.CreateThingPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedCreatePolicy) - } - - return nil -} - -func (us *uiService) DeleteThingsPolicy(token string, policy sdk.Policy) error { - if err := us.sdk.DeleteThingPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedDeletePolicy) +func (gs *uiService) Assign(token, groupID string, userRelation sdk.UsersRelationRequest) error { + if err := gs.sdk.AddUserToGroup(groupID, userRelation, token); err != nil { + return errors.Wrap(err, ErrFailedAssign) } return nil } -func (us *uiService) UpdateThingsPolicy(token string, policy sdk.Policy) error { - if err := us.sdk.UpdateThingPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedUpdatePolicy) +func (gs *uiService) Unassign(token, groupID string, userRelation sdk.UsersRelationRequest) error { + if err := gs.sdk.RemoveUserFromGroup(groupID, userRelation, token); err != nil { + return errors.Wrap(err, ErrFailedUnassign) } return nil } -func (us *uiService) ListGroupMembers(token, id string, page, limit uint64) ([]byte, error) { +func (us *uiService) ViewGroup(token, id string) (b []byte, err error) { group, err := us.sdk.Group(id, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - offset := (page - 1) * limit - - pgm := sdk.PageMetadata{ - Offset: offset, - Limit: limit, - Visibility: statusAll, - } - - members, err := us.sdk.Members(id, pgm, token) - if err != nil { - return []byte{}, errors.Wrap(err, ErrFailedRetreive) - } user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - noOfPages := int(math.Ceil(float64(members.Total) / float64(limit))) - data := struct { NavbarActive string ID string Group sdk.Group - Members []sdk.User User sdk.User - Actions []string - CurrentPage int - Pages int - Limit int }{ groupsActive, id, group, - members.Members, user, - userActions, - int(page), - noOfPages, - int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "groupconn", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "group", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } return btpl.Bytes(), nil } -func (us *uiService) CreateGroups(token string, groups ...sdk.Group) error { - for _, group := range groups { - _, err := us.sdk.CreateGroup(group, token) - if err != nil { - return errors.Wrap(err, ErrFailedCreate) - } +func (us *uiService) UpdateGroup(token, id string, group sdk.Group) error { + _, err := us.sdk.UpdateGroup(group, token) + if err != nil { + return errors.Wrap(err, ErrFailedUpdate) } return nil @@ -1247,7 +1460,7 @@ func (us *uiService) ListGroups(token string, page, limit uint64) ([]byte, error user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } noOfPages := int(math.Ceil(float64(grpPage.Total) / float64(limit))) @@ -1275,85 +1488,209 @@ func (us *uiService) ListGroups(token string, page, limit uint64) ([]byte, error return btpl.Bytes(), nil } -func (us *uiService) ViewGroup(token, id string) (b []byte, err error) { - group, err := us.sdk.Group(id, token) +func (us *uiService) EnableGroup(token, id string) error { + if _, err := us.sdk.EnableGroup(id, token); err != nil { + return errors.Wrap(err, ErrFailedEnable) + } + + return nil +} + +func (us *uiService) DisableGroup(token, id string) error { + if _, err := us.sdk.DisableGroup(id, token); err != nil { + return errors.Wrap(err, ErrFailedDisable) + } + + return nil +} + +func (us *uiService) ListParents(token, groupID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + } + groupsPage, err := us.sdk.Parents(groupID, pgm, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } + noOfPages := int(math.Ceil(float64(groupsPage.Total) / float64(limit))) + data := struct { NavbarActive string - ID string - Group sdk.Group + Groups []sdk.Group User sdk.User + GroupID string + CurrentPage int + Pages int + Limit int }{ groupsActive, - id, - group, + groupsPage.Groups, user, + groupID, + int(page), + noOfPages, + int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "group", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "parents", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } + return btpl.Bytes(), nil + } -func (us *uiService) Assign(token, groupID, memberID string, memberType []string) error { - if err := us.sdk.Assign(memberType, memberID, groupID, token); err != nil { - return errors.Wrap(err, ErrFailedAssign) +func (us *uiService) ListChildren(token, groupID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + } + groupsPage, err := us.sdk.Children(groupID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - return nil -} + noOfPages := int(math.Ceil(float64(groupsPage.Total) / float64(limit))) -func (us *uiService) Unassign(token, groupID, memberID string) error { - if err := us.sdk.Unassign(memberID, groupID, token); err != nil { - return errors.Wrap(err, ErrFailedUnassign) + data := struct { + NavbarActive string + Groups []sdk.Group + User sdk.User + GroupID string + CurrentPage int + Pages int + Limit int + }{ + groupsActive, + groupsPage.Groups, + user, + groupID, + int(page), + noOfPages, + int(limit), } - return nil + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "children", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil + } -func (us *uiService) UpdateGroup(token, id string, group sdk.Group) error { - if _, err := us.sdk.UpdateGroup(group, token); err != nil { - return errors.Wrap(err, ErrFailedUpdate) +func (us *uiService) ListUserGroupChannels(token, groupID string, page, limit uint64) (b []byte, err error) { + offset := (page - 1) * limit + pgm := sdk.PageMetadata{ + Offset: offset, + Limit: limit, + } + channelsPage, err := us.sdk.ListGroupChannels(groupID, pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - return nil + noOfPages := int(math.Ceil(float64(channelsPage.Total) / float64(limit))) + + data := struct { + NavbarActive string + Channels []sdk.Group + User sdk.User + GroupID string + Relations []string + CurrentPage int + Pages int + Limit int + }{ + groupsActive, + channelsPage.Groups, + user, + groupID, + groupRelations, + int(page), + noOfPages, + int(limit), + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "groupchannels", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil + } -func (us *uiService) EnableGroup(token, id string) error { - if _, err := us.sdk.EnableGroup(id, token); err != nil { - return errors.Wrap(err, ErrFailedEnable) +func (gs *uiService) Publish(token, thKey string, msg *messaging.Message) error { + if err := gs.sdk.SendMessage(msg.Channel, string(msg.Payload), thKey); err != nil { + return errors.Wrap(err, ErrFailedPublish) } return nil } -func (us *uiService) DisableGroup(token, id string) error { - if _, err := us.sdk.DisableGroup(id, token); err != nil { - return errors.Wrap(err, ErrFailedDisable) +func (us *uiService) ReadMessage(_ string) ([]byte, error) { + data := struct { + NavbarActive string + }{ + readMessagesActive, } - return nil + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "messagesread", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) + } + + return btpl.Bytes(), nil } -func (us *uiService) AddPolicy(token string, policy sdk.Policy) error { - if err := us.sdk.CreateUserPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedCreatePolicy) +func (us *uiService) WsConnection(_, chID, thKey string) ([]byte, error) { + data := struct { + NavbarActive string + ChanID string + ThingKey string + }{ + readMessagesActive, + chID, + thKey, + } + + var btpl bytes.Buffer + if err := us.tpls.ExecuteTemplate(&btpl, "messagesread", data); err != nil { + return []byte{}, errors.Wrap(err, ErrExecTemplate) } + return btpl.Bytes(), nil +} + +func (us *uiService) CreateBootstrap(token string, configs ...sdk.BootstrapConfig) error { + for _, cfg := range configs { + _, err := us.sdk.AddBootstrap(cfg, token) + if err != nil { + return errors.Wrap(err, ErrFailedCreate) + } + } return nil } -func (us *uiService) ListPolicies(token string, page, limit uint64) ([]byte, error) { +func (us *uiService) ListBootstrap(token string, page, limit uint64) ([]byte, error) { offset := (page - 1) * limit pgm := sdk.PageMetadata{ @@ -1361,7 +1698,19 @@ func (us *uiService) ListPolicies(token string, page, limit uint64) ([]byte, err Limit: limit, Visibility: statusAll, } - plcPage, err := us.sdk.ListUserPolicies(pgm, token) + + bootstraps, err := us.sdk.Bootstraps(pgm, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) + } + + filter := sdk.PageMetadata{ + Offset: uint64(0), + Total: uint64(100), + Limit: uint64(100), + } + + things, err := us.sdk.Things(filter, token) if err != nil { return []byte{}, errors.Wrap(err, ErrFailedRetreive) } @@ -1371,86 +1720,107 @@ func (us *uiService) ListPolicies(token string, page, limit uint64) ([]byte, err return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - noOfPages := int(math.Ceil(float64(plcPage.Total) / float64(limit))) + noOfPages := int(math.Ceil(float64(bootstraps.Total) / float64(limit))) data := struct { NavbarActive string - Policies []sdk.Policy + Bootstraps []sdk.BootstrapConfig + Things []sdk.Thing User sdk.User - Actions []string CurrentPage int Pages int Limit int }{ - usersPoliciesActive, - plcPage.Policies, + bootstrapsActive, + bootstraps.Configs, + things.Things, user, - userActions, int(page), noOfPages, int(limit), } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "policies", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "bootstraps", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } return btpl.Bytes(), nil } -func (us *uiService) UpdatePolicy(token string, policy sdk.Policy) error { - if err := us.sdk.UpdateUserPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedUpdatePolicy) +func (us *uiService) UpdateBootstrap(token string, config sdk.BootstrapConfig) error { + if err := us.sdk.UpdateBootstrap(config, token); err != nil { + return errors.Wrap(err, ErrFailedUpdate) } return nil } -func (us *uiService) DeletePolicy(token string, policy sdk.Policy) error { - if err := us.sdk.DeleteUserPolicy(policy, token); err != nil { - return errors.Wrap(err, ErrFailedDeletePolicy) +func (us *uiService) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) error { + channels, ok := config.Channels.([]string) + if !ok { + return errors.Wrap(errors.New("invalid channel"), ErrFailedUpdate) + } + return us.sdk.UpdateBootstrapConnection(config.ThingID, channels, token) + +} + +func (us *uiService) UpdateBootstrapCerts(token string, config sdk.BootstrapConfig) error { + _, err := us.sdk.UpdateBootstrapCerts(config.ThingID, config.ClientCert, config.ClientKey, config.CACert, token) + + if err != nil { + return errors.Wrap(err, ErrFailedUpdate) } return nil } -func (us *uiService) Publish(token, thKey string, msg *messaging.Message) error { - if err := us.sdk.SendMessage(msg.Channel, string(msg.Payload), thKey); err != nil { - return errors.Wrap(err, ErrFailedPublish) +func (us *uiService) DeleteBootstrap(token, id string) error { + if err := us.sdk.RemoveBootstrap(id, token); err != nil { + return errors.Wrap(err, ErrFailedDelete) } return nil } -func (us *uiService) ReadMessage(_ string) ([]byte, error) { - data := struct { - NavbarActive string - }{ - readMessagesActive, +func (us *uiService) ViewBootstrap(token, id string) ([]byte, error) { + bootstrap, err := us.sdk.ViewBootstrap(id, token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "messagesread", data); err != nil { - return []byte{}, errors.Wrap(err, ErrExecTemplate) + user, err := us.sdk.UserProfile(token) + if err != nil { + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } - return btpl.Bytes(), nil -} + switch channels := bootstrap.Channels.(type) { + case []sdk.Channel: + var strChannels []string + for _, chann := range channels { + strChannels = append(strChannels, chann.ID) + } + bootstrap.Channels = strChannels + case []string: + bootstrap.Channels = channels + case nil: + bootstrap.Channels = []string{} + default: + return nil, errors.Wrap(errors.New("invalid channels"), ErrFailedRetreive) + } -func (us *uiService) WsConnection(_, chID, thKey string) ([]byte, error) { data := struct { NavbarActive string - ChanID string - ThingKey string + Bootstrap sdk.BootstrapConfig + User sdk.User }{ - readMessagesActive, - chID, - thKey, + bootstrapsActive, + bootstrap, + user, } var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "messagesread", data); err != nil { + if err := us.tpls.ExecuteTemplate(&btpl, "bootstrap", data); err != nil { return []byte{}, errors.Wrap(err, ErrExecTemplate) } @@ -1460,7 +1830,7 @@ func (us *uiService) WsConnection(_, chID, thKey string) ([]byte, error) { func (us *uiService) GetRemoteTerminal(id, token string) ([]byte, error) { user, err := us.sdk.UserProfile(token) if err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrFailedRetreive) } data := struct { @@ -1474,7 +1844,7 @@ func (us *uiService) GetRemoteTerminal(id, token string) ([]byte, error) { } var btpl bytes.Buffer if err := us.tpls.ExecuteTemplate(&btpl, "remoteTerminal", data); err != nil { - return []byte{}, err + return []byte{}, errors.Wrap(err, ErrExecTemplate) } return btpl.Bytes(), nil @@ -1483,7 +1853,7 @@ func (us *uiService) GetRemoteTerminal(id, token string) ([]byte, error) { func (us *uiService) ProcessTerminalCommand(ctx context.Context, id, tkn, command string, res chan string) error { cfg, err := us.sdk.ViewBootstrap(id, tkn) if err != nil { - return err + return errors.Wrap(err, ErrFailedRetreive) } var content bootstrap.ServicesConfig @@ -1562,138 +1932,6 @@ func (us *uiService) ProcessTerminalCommand(ctx context.Context, id, tkn, comman return nil } -func (us *uiService) ListBootstrap(token string, page, limit uint64) ([]byte, error) { - offset := (page - 1) * limit - - pgm := sdk.PageMetadata{ - Offset: offset, - Limit: limit, - Visibility: statusAll, - } - - bootstraps, err := us.sdk.Bootstraps(pgm, token) - if err != nil { - return []byte{}, errors.Wrap(err, ErrFailedRetreive) - } - - user, err := us.sdk.UserProfile(token) - if err != nil { - return []byte{}, err - } - - noOfPages := int(math.Ceil(float64(bootstraps.Total) / float64(limit))) - - data := struct { - NavbarActive string - Bootstraps []sdk.BootstrapConfig - User sdk.User - CurrentPage int - Pages int - Limit int - }{ - bootstrapsActive, - bootstraps.Configs, - user, - int(page), - noOfPages, - int(limit), - } - - var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "bootstraps", data); err != nil { - return []byte{}, errors.Wrap(err, ErrExecTemplate) - } - - return btpl.Bytes(), nil -} -func (us *uiService) ViewBootstrap(token, id string) ([]byte, error) { - bootstrap, err := us.sdk.ViewBootstrap(id, token) - if err != nil { - return []byte{}, errors.Wrap(err, ErrFailedRetreive) - } - - user, err := us.sdk.UserProfile(token) - if err != nil { - return []byte{}, err - } - - switch channels := bootstrap.Channels.(type) { - case []sdk.Channel: - var strChannels []string - for _, chann := range channels { - strChannels = append(strChannels, chann.ID) - } - bootstrap.Channels = strChannels - case []string: - bootstrap.Channels = channels - case nil: - bootstrap.Channels = []string{} - default: - return nil, errors.New("invalid channels") - } - - data := struct { - NavbarActive string - Bootstrap sdk.BootstrapConfig - User sdk.User - }{ - bootstrapsActive, - bootstrap, - user, - } - - var btpl bytes.Buffer - if err := us.tpls.ExecuteTemplate(&btpl, "bootstrap", data); err != nil { - return []byte{}, errors.Wrap(err, ErrExecTemplate) - } - - return btpl.Bytes(), nil -} - -func (us *uiService) CreateBootstrap(token string, configs ...sdk.BootstrapConfig) error { - for _, cfg := range configs { - _, err := us.sdk.AddBootstrap(cfg, token) - if err != nil { - return errors.Wrap(err, ErrFailedCreate) - } - } - - return nil -} - -func (us *uiService) DeleteBootstrap(token, id string) error { - if err := us.sdk.RemoveBootstrap(id, token); err != nil { - return errors.Wrap(err, ErrFailedDelete) - } - - return nil -} - -func (us *uiService) UpdateBootstrap(token string, config sdk.BootstrapConfig) error { - if err := us.sdk.UpdateBootstrap(config, token); err != nil { - return errors.Wrap(err, ErrFailedUpdate) - } - - return nil -} - -func (us *uiService) UpdateBootstrapCerts(token string, config sdk.BootstrapConfig) error { - if _, err := us.sdk.UpdateBootstrapCerts(config.ThingID, config.ClientCert, config.ClientKey, config.CACert, token); err != nil { - return errors.Wrap(err, ErrFailedUpdate) - } - - return nil -} - -func (us *uiService) UpdateBootstrapConnections(token string, config sdk.BootstrapConfig) error { - channels, ok := config.Channels.([]string) - if !ok { - return errors.New("invalid channel") - } - return us.sdk.UpdateBootstrapConnection(config.ThingID, channels, token) - -} - func (us *uiService) GetEntities(token, item, name string, page, limit uint64) ([]byte, error) { offset := (page - 1) * limit pgm := sdk.PageMetadata{ @@ -1751,3 +1989,78 @@ func (us *uiService) ErrorPage(errMsg string) ([]byte, error) { return btpl.Bytes(), nil } + +func parseTemplates(mfsdk sdk.SDK, templates []string) (tpl *template.Template, err error) { + tpl = template.New("mainflux") + tpl = tpl.Funcs(template.FuncMap{ + "toJSON": func(data map[string]interface{}) string { + if data == nil { + return "{}" + } + ret, err := json.Marshal(data) + if err != nil { + return "{}" + } + return string(ret) + }, + "toSlice": func(data []string) string { + if len(data) == 0 { + return "[]" + } + ret, err := json.Marshal(data) + if err != nil { + return "[]" + } + return string(ret) + }, + "contains": func(data []string, substring string) bool { + + return slices.Contains(data, substring) + }, + "serviceUnavailable": func(service string) bool { + if _, err := mfsdk.Health(service); err != nil { + return true + } + return false + }, + "hasPrefix": func(s, prefix string) bool { + return strings.HasPrefix(s, prefix) + }, + "sub": func(num1, num2 int) int { + return num1 - num2 + }, + "add": func(num1, num2 int) int { + return num1 + num2 + }, + "max": func(a, b int) int { + if a > b { + return a + } + return b + }, + "min": func(a, b int) int { + if a < b { + return a + } + return b + }, + "fromTo": func(start, end int) []int { + var result []int + for i := start; i <= end; i++ { + result = append(result, i) + } + return result + }, + }) + + var tmplFiles []string + for _, value := range templates { + tmplFiles = append(tmplFiles, templateDir+"/"+value+".html") + } + tpl, err = tpl.ParseFiles(tmplFiles...) + if err != nil { + return nil, err + } + + return tpl, nil +} diff --git a/ui/web/static/css/styles.css b/ui/web/static/css/styles.css index 6ebce984..1fad514e 100644 --- a/ui/web/static/css/styles.css +++ b/ui/web/static/css/styles.css @@ -183,6 +183,7 @@ body.sidebar-toggled .main-content { font-size: 1rem; padding: 0.5rem 1rem; border: 1px solid var(--main-color); + margin-bottom: 0.5rem; } .main-content .sendMessage-button { diff --git a/ui/web/template/bootstrap.html b/ui/web/template/bootstrap.html index 452aa5fb..3388602d 100644 --- a/ui/web/template/bootstrap.html +++ b/ui/web/template/bootstrap.html @@ -226,7 +226,7 @@ -
+
@@ -326,15 +326,14 @@ errorMessage.textContent = ""; if (url) { - // const data = { [field]: updatedValue }; - - fetch(url, { - method: "POST", - body: JSON.stringify(data), - headers: { - "Content-Type": "application/json", - }, - }) + errorMessage.textContent=""; + fetch(url, { + method: "POST", + body: JSON.stringify(data), + headers: { + "Content-Type": "application/json", + }, + }) .then((response) => { if (response.ok) { // Make the row uneditable diff --git a/ui/web/template/channel.html b/ui/web/template/channel.html index ddc4a944..9c1be7a4 100644 --- a/ui/web/template/channel.html +++ b/ui/web/template/channel.html @@ -10,12 +10,14 @@
@@ -26,12 +28,7 @@ - {{ $disableButton := true }} - {{ if (authorizeThing .User.ID - .Channel.ID "g_update" "group") - }} - {{ $disableButton =false }} - {{ end }} + {{ $disableButton := false }} NAME -
+
@@ -250,13 +247,14 @@ } if (url) { - fetch(url, { - method: "POST", - body: JSON.stringify(data), - headers: { - "Content-Type": "application/json", - }, - }) + errorMessage.textContent=""; + fetch(url, { + method: "POST", + body: JSON.stringify(data), + headers: { + "Content-Type": "application/json", + }, + }) .then((response) => { if (response.ok) { //make the row uneditable diff --git a/ui/web/template/channelconn.html b/ui/web/template/channelconn.html deleted file mode 100644 index ffb8bc35..00000000 --- a/ui/web/template/channelconn.html +++ /dev/null @@ -1,418 +0,0 @@ -{{ define "channelconn" }} - - - {{ template "header" }} - - {{ template "navbar" . }} -
-
-
-
-
-
- - - - - - - -
-
- - - - - - - - - - - - - - - - - -
Channel
Name{{ .Channel.Name }}
ID{{ .Channel.ID }}
-
-
-

- CONNECTED THINGS -

- - {{ template "tableheader" . }} -
- - - - - - - - - - {{ $chanID := .Channel.ID }} - {{ range $i, $t := .Things }} - - - - - - {{ end }} - -
NAMEID
{{ $t.Name }} - - {{ $t.ID }} - - -
- - - -
-
-
- {{ template "tablefooter" . }} -
-
-
-
-
-
- - {{ template "footer" }} - - - -{{ end }} diff --git a/ui/web/template/channelgroups.html b/ui/web/template/channelgroups.html new file mode 100644 index 00000000..786ffd3f --- /dev/null +++ b/ui/web/template/channelgroups.html @@ -0,0 +1,245 @@ +{{define "channelgroups"}} + + +{{template "header"}} + + {{template "navbar" .}} +
+
+
+
+
+ +
+
+

Channel Groups

+ + + +
+ {{template "tableheader" .}} +
+ + + + + + + + + + + + + {{ range $i, $g := .Groups }} + {{ $disableButton := false }} + + + + + + + + + {{ end }} + +
NameIDDescriptionMetadataCreated At
{{ $g.Name }} + + {{ $g.Description }}{{ toJSON $g.Metadata }}{{ $g.CreatedAt }} +
+ + + +
+
+
+ {{ template "tablefooter" . }} +
+
+
+
+
+
+ {{template "footer"}} + + + +{{end}} diff --git a/ui/web/template/channels.html b/ui/web/template/channels.html index 274ff6b1..fcbc6527 100644 --- a/ui/web/template/channels.html +++ b/ui/web/template/channels.html @@ -190,14 +190,8 @@

Mainflux

Groups - -