Skip to content

Commit

Permalink
New major release
Browse files Browse the repository at this point in the history
Fix some method and the constructor on PSCouchDBRequest.
Added positional parameters for some cmdlets.
  • Loading branch information
MatteoGuadrini committed Aug 26, 2021
2 parents 1b9d995 + c2e2ed4 commit caf7a20
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release notes

## 2.4.0
May 28, 2021

- Fix **PSCouchDBRequest** constructor.
- Fix *SetServer* method on **PSCouchDBRequest** class.
- Fix *AddAuthorization* method on **PSCouchDBRequest** class.
- Fix *SetDatabase/Document/Attachment* method on **PSCouchDBRequest** class.
- Add positional parameters value for some cmdlets.
- Remove *Username* and *Password* in *ToString* method on **PSCouchDBRequest** for security reason.

## 2.3.0
May 28, 2021

Expand Down
2 changes: 1 addition & 1 deletion PSCouchDB/PSCouchDB.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)

# Version number of this module.
ModuleVersion = '2.3.2'
ModuleVersion = '2.4'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
5 changes: 4 additions & 1 deletion PSCouchDB/PSCouchDB.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1573,13 +1573,16 @@ class PSCouchDBRequest {
}

[string] ToString () {
$stringUri = New-Object -TypeName System.UriBuilder -ArgumentList $this.uri.Uri
# Remove Username and Password in string mode for security reason
$stringUri.Password = $stringUri.UserName = $null
$str = "
{0} {1}
Host: {2}
Param: {3}
Uri: {4}
{5}" -f $this.method, $this.uri.Path, $this.uri.Host, $this.uri.Query, $this.uri, $this.data
{5}" -f $this.method, $this.uri.Path, $this.uri.Host, $this.uri.Query, $stringUri.Uri, $this.data
return $str
}
}
Expand Down
4 changes: 2 additions & 2 deletions PSCouchDB/functions/CouchDBauthentication.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function Set-CouchDBSession () {
https://pscouchdb.readthedocs.io/en/latest/auth.html
#>
param(
[Parameter(mandatory = $true)]
[Parameter(mandatory = $true, Position = 0)]
[string] $UserId,
[Parameter(mandatory = $true)]
[Parameter(mandatory = $true, Position = 1)]
[SecureString] $Password
)
[PSCredential]$credOject = New-Object System.Management.Automation.PSCredential ($UserId, $Password)
Expand Down
5 changes: 5 additions & 0 deletions PSCouchDB/functions/CouchDBconfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ function Get-CouchDBConfiguration () {
[string] $Server,
[int] $Port,
[string] $Node = (Get-CouchDBNode -Server $Server -Port $Port -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential).name,
[Parameter(Position = 0)]
[string] $Session,
[Parameter(Position = 1)]
[string] $Key,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -407,10 +409,13 @@ function Set-CouchDBConfiguration () {
[int] $Port,
[string] $Node = $(if ((Get-CouchDBNode -Server $Server -Port $Port -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential).name -contains "couchdb@localhost") { "couchdb@localhost" } else { "couchdb@127.0.0.1" }),
[Parameter(mandatory = $true)]
[Parameter(Position = 0)]
[string] $Element,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[string] $Key,
[Parameter(mandatory = $true)]
[Parameter(Position = 2)]
[string] $Value,
$Authorization,
[switch] $Ssl,
Expand Down
40 changes: 39 additions & 1 deletion PSCouchDB/functions/CouchDBdatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Test-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -111,7 +112,9 @@ function Copy-CouchDBDatabase () {
[int] $Port,
[int] $RemotePort,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(Position = 1)]
[string] $Destination = $(if ($RemoteServer) {$Database} else {$Database + "_new"}),
[array] $ExcludeIds,
$Authorization,
Expand Down Expand Up @@ -237,6 +240,7 @@ function Get-CouchDBDatabase () {
[int] $Port,
[Parameter(ParameterSetName = "Database")]
[Parameter(ParameterSetName = "AllDatabase")]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(ParameterSetName = "AllDatabase")]
[switch] $AllDatabase,
Expand Down Expand Up @@ -343,7 +347,9 @@ function New-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(Position = 1)]
[switch] $Partition,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -394,6 +400,7 @@ function Remove-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch]$Force,
Expand Down Expand Up @@ -444,6 +451,7 @@ function Get-CouchDBIndex () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -498,10 +506,13 @@ function New-CouchDBIndex () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[string] $Name,
[Parameter(mandatory = $true)]
[Parameter(Position = 2)]
[array] $Fields,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -566,10 +577,13 @@ function Remove-CouchDBIndex () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[string] $DesignDoc,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 2)]
[string] $Name,
$Authorization,
[switch]$Force,
Expand All @@ -591,7 +605,7 @@ function Get-CouchDBDatabaseInfo () {
Returns information of a list of the specified databases in the CouchDB instance.
.NOTES
CouchDB API:
GET /_purged_infos_limit
GET /_dbs_info
.PARAMETER Server
The CouchDB server name. Default is localhost.
.PARAMETER Port
Expand Down Expand Up @@ -621,6 +635,7 @@ function Get-CouchDBDatabaseInfo () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[array] $Keys,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -675,7 +690,9 @@ function Get-CouchDBDatabaseShards () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(Position = 1)]
[string] $Document,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -724,6 +741,7 @@ function Sync-CouchDBDatabaseShards () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -775,6 +793,7 @@ function Compress-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -827,6 +846,7 @@ function Write-CouchDBFullCommit () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch]$Force,
Expand Down Expand Up @@ -879,6 +899,7 @@ function Clear-CouchDBView () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -927,6 +948,7 @@ function Get-CouchDBDatabasePurgedLimit () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -977,8 +999,10 @@ function Set-CouchDBDatabasePurgedLimit () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[int] $Limit,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1031,10 +1055,13 @@ function Get-CouchDBMissingRevision () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[string] $Document,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 2)]
[array] $Revision,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1088,10 +1115,13 @@ function Get-CouchDBRevisionDifference () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true)]
[Parameter(Position = 1)]
[string] $Document,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 2)]
[array] $Revision,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1141,6 +1171,7 @@ function Get-CouchDBRevisionLimit () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1190,7 +1221,9 @@ function Set-CouchDBRevisionLimit () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(Position = 1)]
[int] $Limit = 1000,
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1244,7 +1277,9 @@ function Export-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(Position = 1)]
[string] $Path = $(Join-Path -Path "$($PWD.path)" -ChildPath "$($Database)_$(Get-Date -Format 'MM-dd-yyyy_HH_mm_ss').json"),
$Authorization,
[switch] $Ssl,
Expand Down Expand Up @@ -1336,8 +1371,10 @@ function Import-CouchDBDatabase () {
[string] $Server,
[int] $Port,
[Parameter(mandatory = $true)]
[Parameter(Position = 0)]
[string] $Database,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 1)]
[string] $Path,
[switch] $RemoveRevision,
$Authorization,
Expand Down Expand Up @@ -1402,6 +1439,7 @@ function Connect-CouchDBDatabase () {
[string] $Server = 'localhost',
[int] $Port = 5984,
[Parameter(mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Position = 0)]
[string] $Database,
$Authorization
)
Expand Down
Loading

0 comments on commit caf7a20

Please sign in to comment.