From 74d62f3609d28a2af5dd3b148a393095bfb9057f Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 11 Jun 2024 12:34:10 +0200 Subject: [PATCH] Remove attachment uploader --- .github/actions/lint-rust/action.yml | 40 - .github/workflows/lint.yml | 10 - tools/upload-polarion-attachment/Cargo.lock | 1264 ----------------- tools/upload-polarion-attachment/Cargo.toml | 12 - tools/upload-polarion-attachment/README.md | 26 - .../src/api_types/get_attachments.rs | 42 - .../src/api_types/mod.rs | 3 - .../src/api_types/patch_attachment.rs | 43 - .../src/api_types/post_attachments.rs | 44 - .../src/documents.rs | 61 - .../src/file_system.rs | 55 - tools/upload-polarion-attachment/src/main.rs | 74 - .../src/networking.rs | 158 --- 13 files changed, 1832 deletions(-) delete mode 100644 .github/actions/lint-rust/action.yml delete mode 100644 tools/upload-polarion-attachment/Cargo.lock delete mode 100644 tools/upload-polarion-attachment/Cargo.toml delete mode 100644 tools/upload-polarion-attachment/README.md delete mode 100644 tools/upload-polarion-attachment/src/api_types/get_attachments.rs delete mode 100644 tools/upload-polarion-attachment/src/api_types/mod.rs delete mode 100644 tools/upload-polarion-attachment/src/api_types/patch_attachment.rs delete mode 100644 tools/upload-polarion-attachment/src/api_types/post_attachments.rs delete mode 100644 tools/upload-polarion-attachment/src/documents.rs delete mode 100644 tools/upload-polarion-attachment/src/file_system.rs delete mode 100644 tools/upload-polarion-attachment/src/main.rs delete mode 100644 tools/upload-polarion-attachment/src/networking.rs diff --git a/.github/actions/lint-rust/action.yml b/.github/actions/lint-rust/action.yml deleted file mode 100644 index 2a68efcf..00000000 --- a/.github/actions/lint-rust/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Lint AsciiDoc - -runs: - using: "composite" - steps: - - name: Verify format of Rust code - shell: bash - run: | - function err { - >&2 echo -e "\033[0;31m$@\033[0m" - } - - rc=0 - - while read -r file; do - echo "Checking $(basename "$file")" - if ! cargo fmt --check --manifest-path "$file"; then - rc=1 - fi - done < <(find . -type f -name "Cargo.toml") - - exit $rc - - - name: Lint Rust code - shell: bash - run: | - function err { - >&2 echo -e "\033[0;31m$@\033[0m" - } - - rc=0 - - while read -r file; do - echo "Checking $(basename "$file")" - if ! cargo clippy --all-targets --all-features --manifest-path "$file"; then - rc=1 - fi - done < <(find . -type f -name "Cargo.toml") - - exit $rc diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c0c9bc58..d10ce08f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -48,13 +48,3 @@ jobs: - name: Lint uses: ./.github/actions/lint-plantuml - - rust: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Lint - uses: ./.github/actions/lint-rust diff --git a/tools/upload-polarion-attachment/Cargo.lock b/tools/upload-polarion-attachment/Cargo.lock deleted file mode 100644 index 572762af..00000000 --- a/tools/upload-polarion-attachment/Cargo.lock +++ /dev/null @@ -1,1264 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "backtrace" -version = "0.3.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cc" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "colored" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" -dependencies = [ - "lazy_static", - "windows-sys 0.48.0", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - -[[package]] -name = "h2" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "hyper" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - -[[package]] -name = "hyper-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "proc-macro2" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "reqwest" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-tls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "mime_guess", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "security-framework" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" -dependencies = [ - "bitflags 2.5.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "serde" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.203" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "socket2" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "syn" -version = "2.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "upload-polarion-attachment" -version = "0.1.0" -dependencies = [ - "anyhow", - "colored", - "percent-encoding", - "reqwest", - "serde", - "serde_json", -] - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.5", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] diff --git a/tools/upload-polarion-attachment/Cargo.toml b/tools/upload-polarion-attachment/Cargo.toml deleted file mode 100644 index 7f0d06d3..00000000 --- a/tools/upload-polarion-attachment/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "upload-polarion-attachment" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1.0.86" -colored = "2.1.0" -percent-encoding = "2.3.1" -reqwest = { version = "0.12.4", features = ["blocking", "json", "multipart"] } -serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.117" diff --git a/tools/upload-polarion-attachment/README.md b/tools/upload-polarion-attachment/README.md deleted file mode 100644 index 9abda744..00000000 --- a/tools/upload-polarion-attachment/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Usage - -From this folder, run - -``` -cargo run ../../images/generated/TI-M_Pro/UC_10059_Seq.png -``` - -and follow the prompts. - -To run from another folder use the `--manifest-path` flag, e.g. - -``` -cargo run --manifest-path tools/upload-polarion-attachment/Cargo.toml images/generated/TI-M_Pro/UC_10059_Seq.png -``` - -Only works while on the VPN and when `POLARION_ACCESS_TOKEN` is available in the environment. - -# Development - -To format and lint locally, run - -``` -cargo fmt -cargo clippy --all-targets --all-features -``` diff --git a/tools/upload-polarion-attachment/src/api_types/get_attachments.rs b/tools/upload-polarion-attachment/src/api_types/get_attachments.rs deleted file mode 100644 index 6a60441b..00000000 --- a/tools/upload-polarion-attachment/src/api_types/get_attachments.rs +++ /dev/null @@ -1,42 +0,0 @@ -use serde::Deserialize; - -/// HTTP 200 response object for -/// -/// GET /projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments -/// -/// See https://pet-gematikde.msappproxy.net/polarion/rest/v1#operations-Document_Attachments-getDocumentAttachments -/// for further details. -#[derive(Deserialize, Debug)] -#[allow(dead_code)] -pub(crate) struct Response { - pub(crate) data: Vec, - pub(crate) links: Option, -} - -#[derive(Debug, Deserialize)] -#[allow(dead_code)] -pub(crate) struct Attachment { - #[serde(rename = "type")] - pub(crate) type_field: String, - pub(crate) id: String, - pub(crate) links: ContentLinks, -} - -#[derive(Debug, Deserialize)] -#[allow(dead_code)] -pub(crate) struct ContentLinks { - #[serde(rename = "self")] - pub(crate) self_field: String, - pub(crate) content: String, -} - -#[derive(Debug, Deserialize)] -#[allow(dead_code)] -pub(crate) struct PaginationLinks { - #[serde(rename = "self")] - pub(crate) self_field: String, - pub(crate) first: String, - pub(crate) prev: Option, - pub(crate) next: Option, - pub(crate) last: String, -} diff --git a/tools/upload-polarion-attachment/src/api_types/mod.rs b/tools/upload-polarion-attachment/src/api_types/mod.rs deleted file mode 100644 index 433053a6..00000000 --- a/tools/upload-polarion-attachment/src/api_types/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub(crate) mod get_attachments; -pub(crate) mod patch_attachment; -pub(crate) mod post_attachments; diff --git a/tools/upload-polarion-attachment/src/api_types/patch_attachment.rs b/tools/upload-polarion-attachment/src/api_types/patch_attachment.rs deleted file mode 100644 index 7884150c..00000000 --- a/tools/upload-polarion-attachment/src/api_types/patch_attachment.rs +++ /dev/null @@ -1,43 +0,0 @@ -use serde::Serialize; - -/// Request object for `resource` part of -/// -/// PATCH /projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId} -/// -/// See https://pet-gematikde.msappproxy.net/polarion/rest/v1#operations-Document_Attachments-patchDocumentAttachment -/// for further details. -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Resource { - pub(crate) data: Item, -} - -impl Resource { - /// Creates a resource object for replacing a single file - pub(crate) fn create(id: &str, name: &str) -> Self { - Self { - data: Item { - type_field: "document_attachments".to_string(), - id: id.to_string(), - attributes: Attributes { - title: name.to_string(), - }, - }, - } - } -} - -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Item { - #[serde(rename = "type")] - pub(crate) type_field: String, - pub(crate) id: String, - pub(crate) attributes: Attributes, -} - -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Attributes { - pub(crate) title: String, -} diff --git a/tools/upload-polarion-attachment/src/api_types/post_attachments.rs b/tools/upload-polarion-attachment/src/api_types/post_attachments.rs deleted file mode 100644 index b53785f3..00000000 --- a/tools/upload-polarion-attachment/src/api_types/post_attachments.rs +++ /dev/null @@ -1,44 +0,0 @@ -use serde::Serialize; - -/// Request object for `resource` part of -/// -/// POST /projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments -/// -/// See https://pet-gematikde.msappproxy.net/polarion/rest/v1#operations-Document_Attachments-postDocumentItemAttachments -/// for further details. -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Resource { - data: Vec, -} - -impl Resource { - /// Creates a resource object for uploading a single file - pub(crate) fn create(name: &str) -> Self { - Self { - data: vec![Item { - type_field: "document_attachments".to_string(), - attributes: Attributes { - file_name: name.to_string(), - title: name.to_string(), - }, - }], - } - } -} - -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Item { - #[serde(rename = "type")] - type_field: String, - attributes: Attributes, -} - -#[derive(Debug, Serialize)] -#[allow(dead_code)] -pub(crate) struct Attributes { - #[serde(rename = "fileName")] - pub(crate) file_name: String, - pub(crate) title: String, -} diff --git a/tools/upload-polarion-attachment/src/documents.rs b/tools/upload-polarion-attachment/src/documents.rs deleted file mode 100644 index 98f2a868..00000000 --- a/tools/upload-polarion-attachment/src/documents.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::path::PathBuf; - -/// Polarion document identifier -pub(crate) enum Document { - Basis, - Epa, - Pro, -} - -impl Document { - /// Gets the document's project ID - pub(crate) fn project(&self) -> &str { - match self { - Document::Basis => "Mainline_OPB1", - Document::Epa => "Mainline_OPB1", - Document::Pro => "Mainline_OPB1", - } - } - - /// Gets the document's space ID - pub(crate) fn space(&self) -> &str { - match self { - Document::Basis => "Spezifikation", - Document::Epa => "Spezifikation", - Document::Pro => "Spezifikation", - } - } - - /// Gets the document's document ID - pub(crate) fn document(&self) -> &str { - match self { - Document::Basis => "gemSpec_TI-M_Basis", - Document::Epa => "gemSpec_TI-M_ePA", - Document::Pro => "gemSpec_TI-M_Pro", - } - } - - /// Builds the document's prefix by slash-separating its project, space and document ID - pub(crate) fn prefix(&self) -> String { - format!("{}/{}/{}", self.project(), self.space(), self.document()) - } - - /// Builds an attachment's ID from its name - pub(crate) fn get_attachment_id(&self, name: &str) -> String { - format!("{}/{}", self.prefix(), name) - } -} - -impl TryFrom<&PathBuf> for Document { - type Error = &'static str; - - fn try_from(value: &PathBuf) -> Result { - let folder = value.file_name().and_then(|n| n.to_str()); - match folder { - Some("TI-M_Basis") => Ok(Document::Basis), - Some("TI-M_ePA") => Ok(Document::Epa), - Some("TI-M_Pro") => Ok(Document::Pro), - _ => Err("Last path component doesn't match a known Polarion document"), - } - } -} diff --git a/tools/upload-polarion-attachment/src/file_system.rs b/tools/upload-polarion-attachment/src/file_system.rs deleted file mode 100644 index 7bc8b41b..00000000 --- a/tools/upload-polarion-attachment/src/file_system.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::documents::Document; -use anyhow::{anyhow, Result}; -use std::path::PathBuf; -use std::process::Command; -use std::str::{self, FromStr}; - -/// Determines the git repository root starting from the current working directory -pub(crate) fn get_root_dir() -> Result { - let output = Command::new("git") - .arg("rev-parse") - .arg("--show-toplevel") - .output()?; - - if output.status.success() { - let stdout = str::from_utf8(&output.stdout)?.trim(); - let path = PathBuf::from_str(stdout)?.canonicalize()?; - return Ok(path); - } - - let stderr = str::from_utf8(&output.stderr)?.to_string(); - Err(anyhow!(stderr)) -} - -/// Tries to determine the corresponding Polarion document and attachment name from a path -pub(crate) fn guess_document_and_name( - path: &PathBuf, - root_dir: &PathBuf, -) -> Result<(Document, String)> { - let total = path.components().count(); - let mut remainder = total - 1; - - while remainder > 0 { - let head = path.components().take(remainder).collect::(); - if &head == root_dir { - break; - } - - if let Ok(document) = Document::try_from(&head) { - let name = path - .components() - .skip(remainder) - .map(|c| c.as_os_str().to_string_lossy().to_string()) - .collect::>() - .join("___"); - return Ok((document, name)); - } - - remainder -= 1; - } - - Err(anyhow!( - "Could not determine Polarion document for {:?}", - path - )) -} diff --git a/tools/upload-polarion-attachment/src/main.rs b/tools/upload-polarion-attachment/src/main.rs deleted file mode 100644 index 7ff898ec..00000000 --- a/tools/upload-polarion-attachment/src/main.rs +++ /dev/null @@ -1,74 +0,0 @@ -use anyhow::Result; -use colored::Colorize; -use documents::Document; -use file_system::{get_root_dir, guess_document_and_name}; -use networking::{create_client, is_attachment_existing, patch_attachment, post_attachment}; -use reqwest::blocking::Client; -use std::env; -use std::io::stdin; -use std::path::PathBuf; -use std::str::{self, FromStr}; - -mod api_types; -mod documents; -mod file_system; -mod networking; - -/// The ... well ... main function -fn main() { - let root_dir = get_root_dir().expect("Should be called from within the git repository"); - - let token = env::var("POLARION_ACCESS_TOKEN") - .expect("Should have a POLARION_ACCESS_TOKEN environment variable"); - let client = create_client(&token).expect("Should be able to create network client"); - - for arg in std::env::args().skip(1) { - println!("Processing {}", arg); - if let Err(error) = process_arg(arg.as_str(), &root_dir, &client) { - let msg = format!("[Error]: {}", error); - eprintln!("{}", msg.red()); - } - } -} - -/// Processes a single command line argument -fn process_arg(arg: &str, root_dir: &PathBuf, client: &Client) -> Result<()> { - let path = PathBuf::from_str(arg)?.canonicalize()?; - let (document, name) = guess_document_and_name(&path, root_dir)?; - let is_existing = is_attachment_existing(&document, &name, client)?; - - confirm_operation(&document, &name, is_existing)?; - - if is_existing { - patch_attachment(&path, &document, &name, client)?; - } else { - post_attachment(&path, &document, &name, client)?; - } - - Ok(()) -} - -/// Asks the user to confirm uploading or replacing the attachment -fn confirm_operation(document: &Document, name: &str, is_existing: bool) -> Result<()> { - let message = if is_existing { - format!( - "Attachment {} already exists in {}. Hit to {} it.", - name.bold(), - document.prefix().bold(), - "overwrite".bold() - ) - } else { - format!( - "Attachment {} doesn't exist in {}. Hit to {} it.", - name.bold(), - document.prefix().bold(), - "upload".bold() - ) - }; - println!("{}", message.cyan()); - - let mut input = String::new(); - stdin().read_line(&mut input)?; - - Ok(()) -} diff --git a/tools/upload-polarion-attachment/src/networking.rs b/tools/upload-polarion-attachment/src/networking.rs deleted file mode 100644 index 114236c4..00000000 --- a/tools/upload-polarion-attachment/src/networking.rs +++ /dev/null @@ -1,158 +0,0 @@ -use crate::api_types::{get_attachments, patch_attachment, post_attachments}; -use crate::documents::Document; -use anyhow::Result; -use colored::Colorize; -use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; -use reqwest::blocking::{Client, Response}; -use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION}; -use serde_json::to_string; -use std::path::PathBuf; - -/// Control characters for path components that require escaping (https://url.spec.whatwg.org/#path-percent-encode-set) -const PATH_COMPONENT: &AsciiSet = &CONTROLS - .add(b' ') - .add(b'"') - .add(b'#') - .add(b'<') - .add(b'>') - .add(b'?') - .add(b'`') - .add(b'{') - .add(b'}') - .add(b'/'); - -/// Creates a new reqwest client with appropriate headers and configuration -pub(crate) fn create_client(token: &str) -> Result { - let mut headers = HeaderMap::new(); - let mut authorization = HeaderValue::from_str(&format!("Bearer {}", token))?; - authorization.set_sensitive(true); - headers.insert(AUTHORIZATION, authorization); - - Ok(reqwest::blocking::ClientBuilder::new() - .danger_accept_invalid_certs(true) - .default_headers(headers) - .build()?) -} - -/// Checks if an attachment already exists in Polarion -pub(crate) fn is_attachment_existing( - document: &Document, - name: &str, - client: &Client, -) -> Result { - let id = document.get_attachment_id(name); - let attachments = get_attachments(document, client)?; - Ok(attachments.iter().any(|a| a.id == id)) -} - -/// Fetches all existing attachments for a given document -pub(crate) fn get_attachments( - document: &Document, - client: &Client, -) -> Result> { - let mut url = Some(format!( - "https://pet.gematik.de/polarion/rest/v1/projects/{}/spaces/{}/documents/{}/attachments", - document.project(), - document.space(), - document.document() - )); - - let mut attachments: Vec = vec![]; - - while url.is_some() { - let unwrapped = url.unwrap(); - - log_request("GET", &unwrapped); - let response = client.get(unwrapped).send()?; - log_response(&response); - - let mut json = response.json::()?; - attachments.append(&mut json.data); - - url = json.links.and_then(|l| l.next); - } - - Ok(attachments) -} - -/// Creates a new attachments by uploading a file -pub(crate) fn post_attachment( - path: &PathBuf, - document: &Document, - name: &str, - client: &Client, -) -> Result<()> { - let url = format!( - "https://pet.gematik.de/polarion/rest/v1/projects/{}/spaces/{}/documents/{}/attachments", - document.project(), - document.space(), - document.document() - ); - - let mut form = reqwest::blocking::multipart::Form::new(); - - let resource = to_string(&post_attachments::Resource::create(name))?; - form = form.text("resource", resource); - - let file = reqwest::blocking::multipart::Part::file(path)?.file_name(name.to_string()); - form = form.part("files", file); - - log_request("POST", &url); - let response = client.post(url).multipart(form).send()?; - log_response(&response); - - response.error_for_status()?; - - Ok(()) -} - -/// Replaces an existing attachment by uploading a file -pub(crate) fn patch_attachment( - path: &PathBuf, - document: &Document, - name: &str, - client: &Client, -) -> Result<()> { - let url = format!( - "https://pet.gematik.de/polarion/rest/v1/projects/{}/spaces/{}/documents/{}/attachments/{}", - document.project(), - document.space(), - document.document(), - utf8_percent_encode(name, PATH_COMPONENT).collect::() - ); - - let mut form = reqwest::blocking::multipart::Form::new(); - - let resource = to_string(&patch_attachment::Resource::create( - &document.get_attachment_id(name), - name, - ))?; - form = form.text("resource", resource); - - let file = reqwest::blocking::multipart::Part::file(path)?.file_name(name.to_string()); - form = form.part("files", file); - - log_request("PATCH", &url); - let response = client.patch(url).multipart(form).send()?; - log_response(&response); - - response.error_for_status()?; - - Ok(()) -} - -fn log_request(operation: &str, url: &str) { - println!( - "{} {}", - operation.truecolor(128, 128, 128), - url.truecolor(128, 128, 128) - ); -} - -fn log_response(response: &Response) { - if response.status().is_success() { - println!("{}", response.status().to_string().green()); - } else { - eprintln!("{}", response.status().to_string().red()); - } -}