Read-Only API

Available in Nexus Repository OSS and Nexus Repository Pro

Introduction

This set of endpoints is used to enable and disable read-only mode on the underlying database. This is useful when conducting some maintenance activities.

Endpoints

Get State

GET /service/rest/v1/read-only

This endpoint allows us to query the current read-only state of the database.

curl -u admin:admin123 -X GET http://localhost:8081/service/rest/v1/read-only

The resulting JSON document contains information about whether or not the database is currently "frozen" (i.e. in read-only mode), the reason why it may have been frozen, and whether or not the freeze was system initiated:

{
  "frozen" : false,
  "summaryReason" : "",
  "systemInitiated" : false
}

Enable

POST /service/rest/v1/read-only/freeze

This endpoint allows us to put the database into read-only mode.

curl -u admin:admin123 -X POST http://localhost:8081/service/rest/v1/read-only/freeze

After issuing the freeze action, the database should be in read-only mode.

$ curl -u admin:admin123 -X GET http://localhost:8081/service/rest/v1/read-only
{
  "frozen" : true,
  "summaryReason" : "activated by an administrator at 2018-01-22 15:04:05 +00:00",
  "systemInitiated" : false
}

Release

POST /service/rest/v1/read-only/release

This endpoint allows us to take the database out of read-only mode.

curl -u admin:admin123 -X POST http://localhost:8081/service/rest/v1/read-only/release

After issuing the release action, the database should no longer be in read-only mode.

$ curl -u admin:admin123 -X GET http://localhost:8081/service/rest/v1/read-only
{
  "frozen" : false,
  "summaryReason" : "",
  "systemInitiated" : false
}

Force Release

POST /service/rest/v1/read-only/force-release

In certain rare instances we may need to forcibly take the database out of read-only mode. This endpoint allows us to do that.

curl -u admin:admin123 -X POST http://localhost:8081/service/rest/v1/read-only/force-release

After issuing the force-release action, the database should no longer be in read-only mode.

$ curl -u admin:admin123 -X GET http://localhost:8081/service/rest/v1/read-only
{
  "frozen" : false,
  "summaryReason" : "",
  "systemInitiated" : false
}