diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..14572ed
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,81 @@
+# Contributing to PSProxmox
+
+Thank you for your interest in contributing to PSProxmox! This document provides guidelines and instructions for contributing.
+
+## Code of Conduct
+
+By participating in this project, you agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
+
+## How Can I Contribute?
+
+### Reporting Bugs
+
+This section guides you through submitting a bug report. Following these guidelines helps maintainers understand your report, reproduce the behavior, and find related reports.
+
+- Use the bug report template when creating an issue
+- Include detailed steps to reproduce the problem
+- Describe the behavior you observed and what you expected to see
+- Include PowerShell and Proxmox VE version information
+
+### Suggesting Enhancements
+
+This section guides you through submitting an enhancement suggestion, including completely new features and minor improvements to existing functionality.
+
+- Use the feature request template when creating an issue
+- Provide a clear and detailed explanation of the feature you want
+- Explain why this enhancement would be useful to most PSProxmox users
+
+### Pull Requests
+
+- Fill in the required template
+- Follow the C# and PowerShell style guides
+- Include tests for new features or bug fixes
+- Update documentation as needed
+- End all files with a newline
+
+## Development Workflow
+
+1. Fork the repository
+2. Create a new branch for your changes
+3. Make your changes
+4. Add or update tests as needed
+5. Run tests to ensure they pass
+6. Update documentation as needed
+7. Submit a pull request
+
+## Style Guides
+
+### Git Commit Messages
+
+- Use the present tense ("Add feature" not "Added feature")
+- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
+- Limit the first line to 72 characters or less
+- Reference issues and pull requests liberally after the first line
+
+### C# Style Guide
+
+- Follow the [Microsoft C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions)
+- Use 4 spaces for indentation
+- Use camelCase for private fields and parameters
+- Use PascalCase for public/protected properties and methods
+- Add XML documentation comments for all public members
+
+### PowerShell Style Guide
+
+- Follow the [PowerShell Best Practices and Style Guide](https://github.com/PoshCode/PowerShellPracticeAndStyle)
+- Use proper verb-noun naming for cmdlets
+- Include comment-based help for all cmdlets
+- Use pipeline input where appropriate
+
+## Testing
+
+- Write tests for all new features and bug fixes
+- Run tests before submitting a pull request
+- Ensure all tests pass
+
+## Documentation
+
+- Update the README.md with details of changes to the interface
+- Update the CHANGELOG.md with details of changes
+- Update XML documentation comments for all public members
+- Update comment-based help for all cmdlets
diff --git a/Client/ProxmoxApiClient.cs b/Client/ProxmoxApiClient.cs
index 8757f6d..9287dea 100644
--- a/Client/ProxmoxApiClient.cs
+++ b/Client/ProxmoxApiClient.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Net;
using System.Text;
using System.Management.Automation;
@@ -78,7 +79,7 @@ namespace PSProxmox.Client
}
string url = $"{_connection.ApiUrl}/{endpoint}";
-
+
// Log the URL if verbose is enabled
if (_cmdlet != null)
{
@@ -89,7 +90,7 @@ namespace PSProxmox.Client
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = method;
request.Headers.Add("Cookie", $"PVEAuthCookie={_connection.Ticket}");
-
+
if (method != "GET")
{
request.Headers.Add("CSRFPreventionToken", _connection.CSRFPreventionToken);
@@ -104,10 +105,9 @@ namespace PSProxmox.Client
// Add parameters for POST/PUT requests
if (parameters != null && (method == "POST" || method == "PUT"))
{
- string postData = string.Join("&", Array.ConvertAll(
- parameters.Keys.ToArray(),
- key => $"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(parameters[key])}"
- ));
+ string postData = string.Join("&",
+ parameters.Keys.Select(key => $"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(parameters[key])}")
+ );
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
diff --git a/Cmdlets/LeaveProxmoxClusterCmdlet.cs b/Cmdlets/LeaveProxmoxClusterCmdlet.cs
index 5249960..8ae848f 100644
--- a/Cmdlets/LeaveProxmoxClusterCmdlet.cs
+++ b/Cmdlets/LeaveProxmoxClusterCmdlet.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Management.Automation;
using PSProxmox.Client;
using PSProxmox.Session;
@@ -14,7 +15,7 @@ namespace PSProxmox.Cmdlets
/// Leave-ProxmoxCluster -Connection $connection -Force
///
///
- [Cmdlet(VerbsCommon.Leave, "ProxmoxCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
+ [Cmdlet("Leave", "ProxmoxCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class LeaveProxmoxClusterCmdlet : PSCmdlet
{
///
@@ -53,7 +54,12 @@ namespace PSProxmox.Cmdlets
}
WriteVerbose($"Removing node {Connection.Server} from cluster");
- client.Delete("cluster/leave", parameters);
+ string queryString = "";
+ if (parameters.Count > 0)
+ {
+ queryString = "?" + string.Join("&", parameters.Select(p => $"{p.Key}={p.Value}"));
+ }
+ client.Delete($"cluster/leave{queryString}");
WriteVerbose($"Node {Connection.Server} removed from cluster");
}
diff --git a/Cmdlets/NewProxmoxStorageCmdlet.cs b/Cmdlets/NewProxmoxStorageCmdlet.cs
index 032773a..ebaeabc 100644
--- a/Cmdlets/NewProxmoxStorageCmdlet.cs
+++ b/Cmdlets/NewProxmoxStorageCmdlet.cs
@@ -73,7 +73,7 @@ namespace PSProxmox.Cmdlets
/// Additional parameters for the storage.
///
[Parameter(Mandatory = false)]
- public Hashtable AdditionalParameters { get; set; }
+ public Dictionary AdditionalParameters { get; set; }
///
/// Processes the cmdlet.
@@ -119,7 +119,7 @@ namespace PSProxmox.Cmdlets
}
// Create the storage
- string createResponse = client.Post("storage", parameters);
+ client.Post("storage", parameters);
// Get the created storage
string storageResponse = client.Get($"storage/{Name}");
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6fb1a0a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 freedbygrace
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Models/ProxmoxRole.cs b/Models/ProxmoxRole.cs
index 582b53d..da28805 100644
--- a/Models/ProxmoxRole.cs
+++ b/Models/ProxmoxRole.cs
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System.Collections.Generic;
+using System.Linq;
namespace PSProxmox.Models
{
@@ -30,6 +31,6 @@ namespace PSProxmox.Models
/// Gets the role's privileges as a list.
///
[JsonIgnore]
- public List PrivilegesList => Privileges?.Split(',') ?? new List();
+ public List PrivilegesList => Privileges?.Split(',').ToList() ?? new List();
}
}
diff --git a/PSProxmox.Main.csproj b/PSProxmox.Main.csproj
new file mode 100644
index 0000000..ceb277b
--- /dev/null
+++ b/PSProxmox.Main.csproj
@@ -0,0 +1,99 @@
+
+
+
+ netstandard2.0
+ PSProxmox
+ PSProxmox
+ 2023.04.28.1324
+ PSProxmox Contributors
+ PSProxmox
+ PowerShell module for managing Proxmox VE clusters
+ MIT
+ https://github.com/freedbygrace/PSProxmox
+ https://github.com/freedbygrace/PSProxmox
+ git
+ PowerShell;Proxmox;VE;Virtualization
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PSProxmox.Main.sln b/PSProxmox.Main.sln
new file mode 100644
index 0000000..1a5cc9c
--- /dev/null
+++ b/PSProxmox.Main.sln
@@ -0,0 +1,24 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSProxmox", "PSProxmox.csproj", "{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F1E2D3C4-B5A6-9876-5432-1098F7E6D5C4}
+ EndGlobalSection
+EndGlobal
diff --git a/PSProxmox.csproj b/PSProxmox.csproj
index a2d9c77..7843b7e 100644
--- a/PSProxmox.csproj
+++ b/PSProxmox.csproj
@@ -13,7 +13,7 @@
-
+