Skip to content

Commit

Permalink
Third minor release of version 2
Browse files Browse the repository at this point in the history
Fix PSCouchDBDocument guid. Added Partition parameter on
Set-CouchDBDocument. Added Set-CouchDBMaintenanceMode cmdlet.
  • Loading branch information
MatteoGuadrini committed May 29, 2021
2 parents bc1a758 + dd5231e commit 076875c
Show file tree
Hide file tree
Showing 56 changed files with 11,637 additions and 460 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release notes

## 2.3.0
May 28, 2021

- Fix **PSCouchDBDocument** guid.
- Add *Partition* parameter on **Set-CouchDBDocument**.
- Add **Set-CouchDBMaintenanceMode** cmdlet.

## 2.2.0
Sep 19, 2020

Expand Down
6 changes: 4 additions & 2 deletions 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.2.0'
ModuleVersion = '2.3.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -144,6 +144,7 @@
"Set-CouchDBRevisionLimit",
"Set-CouchDBSession",
"Set-CouchDBProxy",
"Set-CouchDBMaintenanceMode",
"Grant-CouchDBDatabasePermission",
"Revoke-CouchDBDatabasePermission",
"Request-CouchDBReplication",
Expand Down Expand Up @@ -290,7 +291,8 @@
"rmdoc",
"rmuser",
"rmadmin",
"cdsa"
"cdsa",
"cdbmaint"
)

# DSC resources to export from this module
Expand Down
3 changes: 2 additions & 1 deletion PSCouchDB/PSCouchDB.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PSCouchDBDocument {
# Constructors
# No specified _id
PSCouchDBDocument () {
$this._id = (New-CouchDBUuids -Count 1).uuids[0]
$this._id = (New-Guid).Guid.Replace('-', $null)
$this.doc.Add('_id', $this._id)
}

Expand Down Expand Up @@ -1394,6 +1394,7 @@ class PSCouchDBRequest {
}
try {
[System.Net.WebResponse] $resp = $this.client.GetResponse()
$resp.Close()
$this.uri.LastStatusCode = $resp.StatusCode
} catch [System.Net.WebException] {
[System.Net.HttpWebResponse] $errcode = $_.Exception.Response
Expand Down
1 change: 1 addition & 0 deletions PSCouchDB/alias/CouchDBalias.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ New-Alias -Name "scrpl" -Value Set-CouchDBReplication -Option ReadOnly
New-Alias -Name "scrl" -Value Set-CouchDBRevisionLimit -Option ReadOnly
New-Alias -Name "scs" -Value Set-CouchDBSession -Option ReadOnly
New-Alias -Name "sps" -Value Set-CouchDBProxy -Option ReadOnly
New-Alias -Name "cdbmaint" -Value Set-CouchDBMaintenanceMode -Option ReadOnly
New-Alias -Name "gcdbp" -Value Grant-CouchDBDatabasePermission -Option ReadOnly
New-Alias -Name "rcdbp" -Value Revoke-CouchDBDatabasePermission -Option ReadOnly
New-Alias -Name "rcdbr" -Value Request-CouchDBReplication -Option ReadOnly
Expand Down
5 changes: 5 additions & 0 deletions PSCouchDB/functions/CouchDBdocument.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ function Set-CouchDBDocument () {
The CouchDB revision document.
.PARAMETER Data
The data in Json format, PSCouchDBDocument or hastable.
.PARAMETER Partition
The CouchDB partition.
.PARAMETER Replace
Overwrite data.
.PARAMETER Attachment
Expand Down Expand Up @@ -618,6 +620,7 @@ function Set-CouchDBDocument () {
[Parameter(mandatory = $true)]
[string] $Revision,
$Data,
[string] $Partition,
[switch] $Replace,
[string] $Attachment,
[switch] $BatchMode,
Expand Down Expand Up @@ -679,6 +682,8 @@ function Set-CouchDBDocument () {
$parameters += "new_edits=false"
$Revision = $null
}
# Check Partition
if ($Partition) { $Document = "${Partition}:${Document}" }
# Convert doc object to json
$Data = $Data.ToJson(99)
Send-CouchDBRequest -Server $Server -Port $Port -Method "PUT" -Database $Database -Document $Document -Revision $Revision -Params $parameters -Data $Data -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential
Expand Down
65 changes: 65 additions & 0 deletions PSCouchDB/functions/CouchDBserver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,68 @@ function Remove-CouchDBProxy () {
$Global:PSDefaultParameterValues["*CouchDB*:ProxyCredential"] = $null
$Global:PSDefaultParameterValues["*CouchDB*:ProxyServer"] = $null
}

function Set-CouchDBMaintenanceMode () {
<#
.SYNOPSIS
Enable/Disable maintenance mode.
.DESCRIPTION
Enable/Disable maintenance mode.
.NOTES
CouchDB API:
GET /_db_updates
.PARAMETER Server
The CouchDB server name. Default is localhost.
.PARAMETER Port
The CouchDB server port. Default is 5984.
.PARAMETER Node
The CouchDB node of cluster. Default is couchdb@localhost.
.PARAMETER Maintenance
Maintenance on/off. Default is $true.
.PARAMETER Authorization
The CouchDB authorization form; user and password.
Authorization format like this: user:password
ATTENTION: if the password is not specified, it will be prompted.
.PARAMETER Ssl
Set ssl connection on CouchDB server.
This modify protocol to https and port to 6984.
.PARAMETER ProxyServer
Proxy server through which all non-local calls pass.
Ex. ... -ProxyServer 'http://myproxy.local:8080' ...
.PARAMETER ProxyCredential
Proxy server credential. It must be specified with a PSCredential object.
.EXAMPLE
Set-CouchDBMaintenanceMode -Authorization admin:password
Enable maintenance mode.
.EXAMPLE
Set-CouchDBMaintenanceMode -Maintenance:$false -Authorization admin:password
Disable maintenance mode.
.LINK
https://pscouchdb.readthedocs.io/en/latest/server.html#server-operation
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true)]
[string] $Server,
[int] $Port,
[string] $Node,
[bool] $Maintenance = $true,
$Authorization,
[switch] $Ssl,
[string] $ProxyServer,
[pscredential] $ProxyCredential
)
# Compose doc
if (-not($Node)) {
if ((Get-CouchDBNode -Server $Server -Port $Port -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential).name) {
$Node = (Get-CouchDBNode -Server $Server -Port $Port -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential).name
} else {
$Node = Read-Host "Enter the node name (ex. couchdb@localhost)"
}
}
$Database = "_node"
$Document = "$Node/_config/couchdb/maintenance_mode"
$Data = $Maintenance | ConvertTo-Json
# Request
Send-CouchDBRequest -Server $Server -Port $Port -Method "PUT" -Database $Database -Document $Document -Data $Data -Authorization $Authorization -Ssl:$Ssl -ProxyServer $ProxyServer -ProxyCredential $ProxyCredential
}
Binary file modified docs/build/doctrees/auth.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/classes.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/cmdlets.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/config.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/databases.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/ddoc.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/documents.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/intro.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/permission.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/server.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/support.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/uses.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: aa916f445d3f5a8bbc098f4ea69de939
config: 7842dbe2cdf77bebdb8cc379df60cf5c
tags: 645f666f9bcd5a90fca523b33c5a78b7
8 changes: 7 additions & 1 deletion docs/build/html/_sources/cmdlets.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ Server
Remove-CouchDBReshards [[-Server] <String>] [[-Port] <Int32>] [-JobId] <String> [[-Authorization] <Object>] [-Ssl] [[-ProxyServer] <String>] [[-ProxyCredential] <PSCredential>] [<CommonParameters>]
**Set-CouchDBMaintenanceMode**

.. code-block:: powershell
Set-CouchDBMaintenanceMode [[-Server] <String>] [[-Port] <Int32>] [[-Node] <String>] [[-Maintenance] <Boolean>] [[-Authorization] <Object>] [-Ssl] [[-ProxyServer] <String>] [[-ProxyCredential] <PSCredential>] [<CommonParameters>]
Replication
***********

Expand Down Expand Up @@ -489,7 +495,7 @@ Documents

.. code-block:: powershell
Set-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [-Document] <String> [-Revision] <String> [[-Data] <Object>] [-Replace] [[-Attachment] <String>] [-BatchMode] [-NoConflict] [[-Authorization] <String>] [-Ssl] [[-ProxyServer] <String>] [[-ProxyCredential] <Object>] [<CommonParameters>]
Set-CouchDBDocument [[-Server] <String>] [[-Port] <Int32>] [-Database] <String> [-Document] <String> [-Revision] <String> [[-Data] <Object>] [[-Partition] <String>] [-Replace] [[-Attachment] <String>] [-BatchMode] [-NoConflict] [[-Authorization] <Object>] [-Ssl] [[-ProxyServer] <String>] [[-ProxyCredential] <PSCredential>] [<CommonParameters>]
**Remove-CouchDBDocument**

Expand Down
1 change: 1 addition & 0 deletions docs/build/html/_sources/documents.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Latest Forces retrieving latest “leaf” revision, no matter what
LocalSequence Includes last update sequence for the document.
Metadata Acts same as specifying all conflicts, deleted_conflicts and revs_info query parameters.
OpenRevisions Retrieves documents of specified leaf revisions. Additionally, value all id default and to return all leaf revisions.
Partition CouchDB partition name
================ ===========

And if use **_all_docs** view, in this table you can find all the possible parameters.
Expand Down
17 changes: 16 additions & 1 deletion docs/build/html/_sources/server.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,19 @@ Request, configure, or stop, a replication operation.
using module PSCouchDB
$rep = New-Object PSCouchDBReplication -ArgumentList 'test','test_dump'
$rep.AddDocIds(@("Hitchhikers","Hitchhikers_Guide"))
Request-CouchDBReplication -Data $rep -Authorization "admin:password"
Request-CouchDBReplication -Data $rep -Authorization "admin:password"
Enable/Disable Maintenance
__________________________

Enable maintenance mode.

.. code-block:: powershell
Set-CouchDBMaintenanceMode -Authorization "admin:password"
Disable maintenance mode.

.. code-block:: powershell
Set-CouchDBMaintenanceMode -Maintenance $false -Authorization "admin:password"

0 comments on commit 076875c

Please sign in to comment.