Skip to content

Add support for API version 7 #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ This project includes a client library for working with NGINX Plus API.

## Compatibility

This Client works against versions 4 to 6 of the NGINX Plus API. The table below shows the version of NGINX Plus where the API was first introduced.
This Client works against versions 4 to 7 of the NGINX Plus API. The table below shows the version of NGINX Plus where the API was first introduced.

| API version | NGINX Plus version |
|-------------|--------------------|
| 4 | R18 |
| 5 | R19 |
| 6 | R20 |
| 7 | R25 |

## Using the Client

Expand Down
49 changes: 47 additions & 2 deletions client/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const (
// APIVersion is the default version of NGINX Plus API supported by the client.
APIVersion = 6
APIVersion = 7

pathNotFoundCode = "PathNotFound"
streamContext = true
Expand All @@ -25,7 +25,7 @@ const (
)

var (
supportedAPIVersions = versions{4, 5, 6}
supportedAPIVersions = versions{4, 5, 6, 7}

// Default values for servers in Upstreams.
defaultMaxConns = 0
Expand Down Expand Up @@ -273,6 +273,7 @@ type StreamZoneSyncStatus struct {

// Responses represents HTTP response related stats.
type Responses struct {
Codes HTTPCodes
Responses1xx uint64 `json:"1xx"`
Responses2xx uint64 `json:"2xx"`
Responses3xx uint64 `json:"3xx"`
Expand All @@ -281,6 +282,50 @@ type Responses struct {
Total uint64
}

// HTTPCodes represents HTTP response codes
type HTTPCodes struct {
HTTPContinue uint64 `json:"100,omitempty"`
HTTPSwitchingProtocols uint64 `json:"101,omitempty"`
HTTPProcessing uint64 `json:"102,omitempty"`
HTTPOk uint64 `json:"200,omitempty"`
HTTPCreated uint64 `json:"201,omitempty"`
HTTPAccepted uint64 `json:"202,omitempty"`
HTTPNoContent uint64 `json:"204,omitempty"`
HTTPPartialContent uint64 `json:"206,omitempty"`
HTTPSpecialResponse uint64 `json:"300,omitempty"`
HTTPMovedPermanently uint64 `json:"301,omitempty"`
HTTPMovedTemporarily uint64 `json:"302,omitempty"`
HTTPSeeOther uint64 `json:"303,omitempty"`
HTTPNotModified uint64 `json:"304,omitempty"`
HTTPTemporaryRedirect uint64 `json:"307,omitempty"`
HTTPBadRequest uint64 `json:"400,omitempty"`
HTTPUnauthorized uint64 `json:"401,omitempty"`
HTTPForbidden uint64 `json:"403,omitempty"`
HTTPNotFound uint64 `json:"404,omitempty"`
HTTPNotAllowed uint64 `json:"405,omitempty"`
HTTPRequestTimeOut uint64 `json:"408,omitempty"`
HTTPConflict uint64 `json:"409,omitempty"`
HTTPLengthRequired uint64 `json:"411,omitempty"`
HTTPPreconditionFailed uint64 `json:"412,omitempty"`
HTTPRequestEntityTooLarge uint64 `json:"413,omitempty"`
HTTPRequestURITooLarge uint64 `json:"414,omitempty"`
HTTPUnsupportedMediaType uint64 `json:"415,omitempty"`
HTTPRangeNotSatisfiable uint64 `json:"416,omitempty"`
HTTPTooManyRequests uint64 `json:"429,omitempty"`
HTTPClose uint64 `json:"444,omitempty"`
HTTPRequestHeaderTooLarge uint64 `json:"494,omitempty"`
HTTPSCertError uint64 `json:"495,omitempty"`
HTTPSNoCert uint64 `json:"496,omitempty"`
HTTPToHTTPS uint64 `json:"497,omitempty"`
HTTPClientClosedRequest uint64 `json:"499,omitempty"`
HTTPInternalServerError uint64 `json:"500,omitempty"`
HTTPNotImplemented uint64 `json:"501,omitempty"`
HTTPBadGateway uint64 `json:"502,omitempty"`
HTTPServiceUnavailable uint64 `json:"503,omitempty"`
HTTPGatewayTimeOut uint64 `json:"504,omitempty"`
HTTPInsufficientStorage uint64 `json:"507,omitempty"`
}

// Sessions represents stream session related stats.
type Sessions struct {
Sessions2xx uint64 `json:"2xx"`
Expand Down