diff --git a/.github/workflows/publish-libraries.yml b/.github/workflows/publish-libraries.yml index 1cae425eb..6c23b0b75 100644 --- a/.github/workflows/publish-libraries.yml +++ b/.github/workflows/publish-libraries.yml @@ -40,7 +40,7 @@ jobs: strategy: fail-fast: false matrix: - library: [ dotnet-client, dotnet-subscriber, utils ] + library: [ dotnet-client, dotnet-subscriber, utils, pedm-dotnet-client ] include: - library: dotnet-client libpath: ./devolutions-gateway/openapi/dotnet-client @@ -48,6 +48,8 @@ jobs: libpath: ./devolutions-gateway/openapi/dotnet-subscriber - library: utils libpath: ./utils/dotnet + - library: pedm-dotnet-client + libpath: ./crates/devolutions-pedm/openapi/dotnet-client steps: - name: Check out ${{ github.repository }} @@ -62,8 +64,8 @@ jobs: & "$Path/build.ps1" New-Item -ItemType "directory" -Path . -Name "nuget-packages" - Get-ChildItem -Path $Path -Recurse *.nupkg | ForEach { Copy-Item $_ "./nuget-packages" } - Get-ChildItem -Path $Path -Recurse *.snupkg | ForEach { Copy-Item $_ "./nuget-packages" } + Get-ChildItem -Path $Path -Recurse -Include '*.nupkg' | ForEach { Copy-Item $_ "./nuget-packages" } + Get-ChildItem -Path $Path -Recurse -Include '*.snupkg' | ForEach { Copy-Item $_ "./nuget-packages" } - name: Upload packages uses: actions/upload-artifact@v4 diff --git a/crates/devolutions-pedm-shared/src/build.rs b/crates/devolutions-pedm-shared/src/build.rs index ffa70fcc1..6e875a155 100644 --- a/crates/devolutions-pedm-shared/src/build.rs +++ b/crates/devolutions-pedm-shared/src/build.rs @@ -1,12 +1,18 @@ use std::env; +use std::ffi::OsString; use std::io::{Error, ErrorKind, Result}; use std::path::PathBuf; pub fn target_dir() -> Result { let mut dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let target_dirs = [OsString::from(env::var("TARGET").unwrap()), OsString::from("target")]; + loop { - if dir.file_name().is_some_and(|f| *f == *env::var("PROFILE").unwrap()) { + if dir + .parent() + .is_some_and(|f| f.file_name().is_some_and(|f| target_dirs.iter().any(|x| x == f))) + { return Ok(dir); } else if !dir.pop() { return Err(Error::new(ErrorKind::NotFound, "Target path not found")); diff --git a/crates/devolutions-pedm-shared/src/policy.rs b/crates/devolutions-pedm-shared/src/policy.rs index 02139b8ec..f019b91d8 100644 --- a/crates/devolutions-pedm-shared/src/policy.rs +++ b/crates/devolutions-pedm-shared/src/policy.rs @@ -325,16 +325,14 @@ pub struct ElevationConfigurations { #[repr(transparent)] #[derive(Serialize, Deserialize, JsonSchema, Debug, PartialEq, Eq, Hash, Clone)] #[serde(try_from = "String")] -pub struct Id { - id: String, -} +pub struct Id(String); impl Id { pub fn try_new(id: String) -> anyhow::Result { let pat = Regex::new(ID_PATTERN)?; pat.is_match(&id) - .then(|| Id { id }) + .then(|| Id(id)) .ok_or_else(|| anyhow::anyhow!("Invalid ID")) } } @@ -349,7 +347,7 @@ impl TryFrom for Id { impl fmt::Display for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.id.fmt(f) + self.0.fmt(f) } } @@ -379,9 +377,7 @@ impl Identifiable for Profile { impl Default for Profile { fn default() -> Self { Self { - id: Id { - id: "default".to_owned(), - }, + id: Id("default".to_owned()), name: "Unnamed profile".to_owned(), elevation_method: ElevationMethod::LocalAdmin, elevation_settings: ElevationConfigurations::default(), diff --git a/crates/devolutions-pedm/Cargo.toml b/crates/devolutions-pedm/Cargo.toml index f7622e510..575c8ef3d 100644 --- a/crates/devolutions-pedm/Cargo.toml +++ b/crates/devolutions-pedm/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" license = "MIT/Apache-2.0" authors = ["Devolutions Inc. "] description = "Devolutions Agent PEDM module" -build = "build.rs" publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -39,10 +38,5 @@ tower-http = { version = "0.5.2", features = ["timeout"] } parking_lot = "0.12.3" cfg-if = "1.0.0" -[build-dependencies] -devolutions-pedm-shared = { path = "../devolutions-pedm-shared", features = ["build", "policy"] } -schemars = "0.8.21" -serde_json = "1.0.124" - [lints] workspace = true \ No newline at end of file diff --git a/crates/devolutions-pedm/build.rs b/crates/devolutions-pedm/build.rs deleted file mode 100644 index 4b6194ce3..000000000 --- a/crates/devolutions-pedm/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -use devolutions_pedm_shared::build::target_dir; -use devolutions_pedm_shared::policy::Configuration; -use schemars::schema_for; -use std::fs; -use std::io::Result; - -fn main() -> Result<()> { - let schema = schema_for!(Configuration); - - let mut out_path = target_dir()?; - out_path.push("policy.schema.json"); - - fs::write( - &out_path, - serde_json::to_string_pretty(&schema).expect("failed to serialize PEDM schema"), - )?; - - Ok(()) -} diff --git a/crates/devolutions-pedm/openapi/dotnet-client/README.md b/crates/devolutions-pedm/openapi/dotnet-client/README.md index b8803fe99..6240a4365 100644 --- a/crates/devolutions-pedm/openapi/dotnet-client/README.md +++ b/crates/devolutions-pedm/openapi/dotnet-client/README.md @@ -5,7 +5,7 @@ No description provided (generated by Openapi Generator https://github.com/opena This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: -- SDK version: 2024.7.5 +- SDK version: 2024.8.13 - Generator version: 7.7.0 - Build package: org.openapitools.codegen.languages.CSharpClientCodegen diff --git a/crates/devolutions-pedm/openapi/dotnet-client/build.ps1 b/crates/devolutions-pedm/openapi/dotnet-client/build.ps1 new file mode 100644 index 000000000..ce6eeca72 --- /dev/null +++ b/crates/devolutions-pedm/openapi/dotnet-client/build.ps1 @@ -0,0 +1,10 @@ +#!/bin/env pwsh + +$ErrorActionPreference = "Stop" + +Push-Location -Path $PSScriptRoot + +dotnet build --configuration Release +dotnet pack --configuration Release + +Pop-Location diff --git a/crates/devolutions-pedm/openapi/dotnet-client/config.json b/crates/devolutions-pedm/openapi/dotnet-client/config.json index dfd68dc9c..b3cd82921 100644 --- a/crates/devolutions-pedm/openapi/dotnet-client/config.json +++ b/crates/devolutions-pedm/openapi/dotnet-client/config.json @@ -2,7 +2,7 @@ "packageAuthors": "Devolutions Inc.", "packageName": "Devolutions.Pedm.Client", "packageTitle": "Devolutions PEDM REST API Client", - "packageVersion": "2024.7.5", + "packageVersion": "2024.8.13", "packageDescription": "Client for Devolutions PEDM REST API", "packageGuid": "0eb49e08-5842-4a2e-a5ac-926e6dd65c15", "packageCopyright": "© Devolutions Inc. All rights reserved.", diff --git a/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Client/Configuration.cs b/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Client/Configuration.cs index 91983e458..476a97cac 100644 --- a/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Client/Configuration.cs +++ b/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Client/Configuration.cs @@ -32,7 +32,7 @@ public class Configuration : IReadableConfiguration /// Version of the package. /// /// Version of the package. - public const string Version = "2024.7.5"; + public const string Version = "2024.8.13"; /// /// Identifier for ISO 8601 DateTime Format @@ -116,7 +116,7 @@ public class Configuration : IReadableConfiguration public Configuration() { Proxy = null; - UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/2024.7.5/csharp"); + UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/2024.8.13/csharp"); BasePath = "http://localhost"; DefaultHeaders = new ConcurrentDictionary(); ApiKey = new ConcurrentDictionary(); @@ -539,7 +539,7 @@ public static string ToDebugReport() report += " OS: " + System.Environment.OSVersion + "\n"; report += " .NET Framework Version: " + System.Environment.Version + "\n"; report += " Version of the API: \n"; - report += " SDK Package Version: 2024.7.5\n"; + report += " SDK Package Version: 2024.8.13\n"; return report; } diff --git a/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Devolutions.Pedm.Client.csproj b/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Devolutions.Pedm.Client.csproj index c45141a24..7d0e28037 100644 --- a/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Devolutions.Pedm.Client.csproj +++ b/crates/devolutions-pedm/openapi/dotnet-client/src/Devolutions.Pedm.Client/Devolutions.Pedm.Client.csproj @@ -12,7 +12,7 @@ Client for Devolutions PEDM REST API © Devolutions Inc. All rights reserved. Devolutions.Pedm.Client - 2024.7.5 + 2024.8.13 bin\$(Configuration)\$(TargetFramework)\Devolutions.Pedm.Client.xml https://github.com/Devolutions/devolutions-gateway.git git diff --git a/crates/devolutions-pedm/openapi/pedm-api.yaml b/crates/devolutions-pedm/openapi/pedm-api.yaml index 8bfcf16cd..b832596f7 100644 --- a/crates/devolutions-pedm/openapi/pedm-api.yaml +++ b/crates/devolutions-pedm/openapi/pedm-api.yaml @@ -644,7 +644,7 @@ components: MaximumSeconds: 0 $ref: '#/components/schemas/ElevationConfigurations' Id: - default: '' + default: default $ref: '#/components/schemas/Id' Name: default: Unnamed profile