From 618183d07c90e258bf7c618f84703ee3a236c40a Mon Sep 17 00:00:00 2001 From: rzrbld Date: Mon, 18 May 2020 23:08:46 +0300 Subject: [PATCH] update deps and api specs --- README.md | 12 +- openAPI/openapi.html | 380 ++++++++++++++++++++++++++++++++++++++++ openAPI/openapi_v3.yaml | 2 +- src/go.mod | 6 +- src/go.sum | 6 + src/main.go | 38 ---- 6 files changed, 397 insertions(+), 47 deletions(-) create mode 100644 openAPI/openapi.html diff --git a/README.md b/README.md index d5f6ebd..31f2c7f 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,9 @@ Here is a Web UI for this API - [adminio-ui](https://github.com/rzrbld/adminio-u ![Docker hub stats](https://img.shields.io/docker/pulls/rzrbld/adminio-api?style=flat-square) ![GitHub License](https://img.shields.io/github/license/rzrbld/adminio-api?style=flat-square) +## OpenAPI v3 -### Breaking changes in 0.9 version - - - env renamed: API_HOST_PORT > ADMINIO_HOST_PORT - - API version v1 is depicated and soon will be removed. +see OpenAPI v3 specs at `openAPI/openapi_v3.yaml` or [html version](https://rzrbld.github.io/openapi/) ### Run full stack demo obtain [docker-compose.yml](https://raw.githubusercontent.com/rzrbld/adminio-ui/master/docker-compose.yml) from [adminio-ui](https://github.com/rzrbld/adminio-ui) repository. And run it: @@ -34,6 +32,9 @@ docker run -d \ ``` +### Monitoring +Adminio-API expose metrics for [Prometheus](https://prometheus.io/) at `/metrics` if `ADMINIO_METRICS_ENABLE` is set to `true`. + ### Run manually - [start](https://docs.min.io/) minio server - set env variables @@ -78,6 +79,7 @@ docker run -d \ - slack - wso2 - ### example config + + ### Example config - prometheus config for adminio metrics: `examples/prometheus.yml` - bucket lifecycle: `examples/lifecycle.xml` diff --git a/openAPI/openapi.html b/openAPI/openapi.html new file mode 100644 index 0000000..99e9b04 --- /dev/null +++ b/openAPI/openapi.html @@ -0,0 +1,380 @@ + + + + + + Adminio API + + + + + + + + + +

Adminio API (2.0.0)

Download OpenAPI specification:Download

Adminio API

+

bucket

List all buckets

Responses

200

List all buckets

+
default

unexpected error

+
get/buckets/list
http://localhost:8080/api/v2/buckets/list

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
[
  • {
    }
]

List all buckets with ARN's and Quota's

Responses

200

List all buckets plus ARN and Quota

+
default

unexpected error

+
get/buckets/list-extended
http://localhost:8080/api/v2/buckets/list-extended

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
[
  • {
    }
]

Create a bucket

Request Body schema: multipart/form-data
newBucket
string <string>
newBucketRegion
string <string>

Responses

200

Success

+
default

unexpected error

+
post/bucket/create
http://localhost:8080/api/v2/bucket/create

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Delete bucket

Request Body schema: multipart/form-data
bucketName
string <string>

Responses

200

Success

+
default

unexpected error

+
post/bucket/delete
http://localhost:8080/api/v2/bucket/delete

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

remove bucket events notifications

Request Body schema: multipart/form-data
bucket
string <string>

Responses

200

Success

+
default

unexpected error

+
post/bucket/remove-events
http://localhost:8080/api/v2/bucket/remove-events

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Set bucket events

Request Body schema: multipart/form-data
bucket
string <string>
eventTypes
string <string>
filterPrefix
string <string>
filterSuffix
string <string>

Responses

200

lifecycle XML string or empty string if lifecycle does not exist

+
default

unexpected error

+
post/bucket/set-events
http://localhost:8080/api/v2/bucket/set-events

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Get bucket events

Request Body schema: multipart/form-data
bucket
string <string>

Responses

200

return bucket event

+
default

unexpected error

+
post/bucket/get-events
http://localhost:8080/api/v2/bucket/get-events

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "XMLname":
    {
    },
  • "LambdaConfigs": { },
  • "TopicConfigs": { },
  • "QueueConfigs": { }
}

Get bucket lifecycle

Request Body schema: multipart/form-data
bucketName
string <string>

Responses

200

lifecycle XML string or empty string if lifecycle does not exist

+
default

unexpected error

+
post/bucket/get-lifecycle
http://localhost:8080/api/v2/bucket/get-lifecycle

Response samples

Content type
application/json
Copy
Expand all Collapse all
"string"

Set bucket lifecycle

Request Body schema: multipart/form-data
bucketName
string <string>
lifecycle
string <string>

lifecycle XML string

+

Responses

200

Success

+
default

unexpected error

+
post/bucket/set-lifecycle
http://localhost:8080/api/v2/bucket/set-lifecycle

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Set bucket quota

Request Body schema: multipart/form-data
bucketName
string <string>
quotaType
string <string>
quotaValue
string <string>

quota size in bytes

+

Responses

200

Success

+
default

unexpected error

+
post/bucket/set-quota
http://localhost:8080/api/v2/bucket/set-quota

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Get bucket quota

Request Body schema: multipart/form-data
bucketName
string <string>

Responses

200

bucket quota

+
default

unexpected error

+
post/bucket/get-quota
http://localhost:8080/api/v2/bucket/get-quota

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "quota": 0,
  • "quotatype": "string"
}

Remove bucket quota

Request Body schema: multipart/form-data
bucketName
string <string>

Responses

200

Success

+
default

unexpected error

+
post/bucket/remove-quota
http://localhost:8080/api/v2/bucket/remove-quota

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

user

List all users

Responses

200

List all users

+
default

unexpected error

+
get/users/list
http://localhost:8080/api/v2/users/list

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
{
  • "name":
    {
    }
}

Set User status

Request Body schema: multipart/form-data
accessKey
string <string>
status
string <string>
Enum: "enabled" "disabled"

Responses

200

Success

+
default

unexpected error

+
post/user/set-status
http://localhost:8080/api/v2/user/set-status

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Delete User

Request Body schema: multipart/form-data
accessKey
string <string>

Responses

200

Success

+
default

unexpected error

+
post/user/delete
http://localhost:8080/api/v2/user/delete

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Create User

Request Body schema: multipart/form-data
accessKey
string <string>
secretKey
string <string>

Responses

200

Success

+
default

unexpected error

+
post/user/create
http://localhost:8080/api/v2/user/create

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Create User with bounded policy

Request Body schema: multipart/form-data
accessKey
string <string>
secretKey
string <string>
policyName
string <string>

Responses

200

Success

+
default

unexpected error

+
post/user/create-extended
http://localhost:8080/api/v2/user/create-extended

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Update User - change policy or status

Request Body schema: multipart/form-data
accessKey
string <string>
secretKey
string <string>
policyName
string <string>
status
string <string>
Enum: "enabled" "disabled"

Responses

200

Success

+
default

unexpected error

+
post/user/update
http://localhost:8080/api/v2/user/update

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

policy

List all policies

Responses

200

List all policies

+
default

unexpected error

+
get/policies/list
http://localhost:8080/api/v2/policies/list

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
{
  • "name":
    {
    }
}

Create policy

Request Body schema: multipart/form-data
policyName
string <string>
policyString
string <string>

Responses

200

Success

+
default

unexpected error

+
post/policy/create
http://localhost:8080/api/v2/policy/create

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Delete policy

Request Body schema: multipart/form-data
policyName
string <string>

Responses

200

Success

+
default

unexpected error

+
post/policy/delete
http://localhost:8080/api/v2/policy/delete

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Bound policy to user or group

Request Body schema: multipart/form-data
policyName
string <string>

Ploicy Name

+
entityName
string <string>

Group or User name

+
isGroup
boolean <boolean>
Enum: true false

Responses

200

Success

+
default

unexpected error

+
post/policy/update
http://localhost:8080/api/v2/policy/update

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

group

Group set status

Request Body schema: multipart/form-data
group
string <string>

Group Name

+
status
boolean <boolean>
Enum: "enabled" "disabled"

Responses

200

Success

+
default

unexpected error

+
post/group/set-status
http://localhost:8080/api/v2/group/set-status

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

Group get description

Request Body schema: multipart/form-data
group
string <string>

Group Name

+

Responses

200

Success

+
default

unexpected error

+
post/group/get-description
http://localhost:8080/api/v2/group/get-description

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "name": "string",
  • "status": "string",
  • "members":
    [
    ],
  • "policy": "string"
}

Update Group members

Request Body schema: multipart/form-data
group
string <string>

Group Name

+
members
string <string>

multiple usernames with comma delimiter

+
IsRemove
boolean <boolean>
Enum: true false

set false if you need remove members from group

+

Responses

200

Success

+
default

unexpected error

+
post/group/update-members
http://localhost:8080/api/v2/group/update-members

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "Success": "OK"
}

List all groups

Responses

200

List all groups

+
default

unexpected error

+
get/groups/list
http://localhost:8080/api/v2/groups/list

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
[
  • "string"
]

server

Server basic info

Responses

200

Server Info

+
default

unexpected error

+
get/server/common-info
http://localhost:8080/api/v2/server/common-info

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
{
  • "mode": "string",
  • "sqsARN":
    [
    ],
  • "deploymentID": "string",
  • "buckets":
    {
    },
  • "objects":
    {
    },
  • "usage":
    {
    },
  • "services":
    {
    },
  • "backend":
    {
    },
  • "servers":
    [
    ]
}

Server disk info

Responses

200

Server Disk Info

+
default

unexpected error

+
get/server/disk-info
http://localhost:8080/api/v2/server/disk-info

Response samples

Content type
application/json; charset=UTF-8
Copy
Expand all Collapse all
{
  • "lastUpdate": "string",
  • "objectsCount": 0,
  • "objectsTotalSize": 0,
  • "objectsSizesHistogram":
    {
    },
  • "bucketsCount": 0,
  • "bucketsSizes": { }
}

kv

get value by key

Request Body schema: multipart/form-data
keyString
string <string>

Group Name

+

Responses

200

base64 string

+
default

unexpected error

+
post/kv/get
http://localhost:8080/api/v2/kv/get

Response samples

Content type
application/json
Copy
Expand all Collapse all
"string"
+ + + + \ No newline at end of file diff --git a/openAPI/openapi_v3.yaml b/openAPI/openapi_v3.yaml index 7fea422..c516013 100644 --- a/openAPI/openapi_v3.yaml +++ b/openAPI/openapi_v3.yaml @@ -1,7 +1,7 @@ openapi: "3.0.0" info: description: "Adminio API" - version: "1.0.0" + version: "2.0.0" title: "Adminio API" contact: name: "rzrbld at github.com" diff --git a/src/go.mod b/src/go.mod index c1ab1b2..b799658 100644 --- a/src/go.mod +++ b/src/go.mod @@ -17,13 +17,13 @@ require ( github.com/iris-contrib/middleware/cors v0.0.0-20191219204441-78279b78a367 github.com/iris-contrib/middleware/prometheus v0.0.0-20191219204441-78279b78a367 github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect - github.com/kataras/golog v0.0.13 // indirect + github.com/kataras/golog v0.0.15 // indirect github.com/kataras/iris/v12 v12.1.8 github.com/klauspost/compress v1.10.5 // indirect github.com/kr/text v0.2.0 // indirect github.com/markbates/goth v1.64.0 github.com/mattn/go-colorable v0.1.6 // indirect - github.com/minio/minio v0.0.0-20200514221824-fe8d33452bb9 + github.com/minio/minio v0.0.0-20200518183557-a3f41c70498c github.com/minio/minio-go/v6 v6.0.55 github.com/montanaflynn/stats v0.6.3 // indirect github.com/moul/http2curl v1.0.0 // indirect @@ -48,7 +48,7 @@ require ( github.com/yudai/pp v2.0.1+incompatible // indirect golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect golang.org/x/net v0.0.0-20200513185701-a91f0712d120 // indirect - golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c // indirect + golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect google.golang.org/appengine v1.6.6 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/ini.v1 v1.56.0 // indirect diff --git a/src/go.sum b/src/go.sum index d905992..d6bfff9 100644 --- a/src/go.sum +++ b/src/go.sum @@ -253,6 +253,8 @@ github.com/kataras/golog v0.0.10 h1:vRDRUmwacco/pmBAm8geLn8rHEdc+9Z4NAr5Sh7TG/4= github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= github.com/kataras/golog v0.0.13 h1:zWzk56eWBkdV4kPq3Koh8PS4pUfNQUfHuLc3YACpM7c= github.com/kataras/golog v0.0.13/go.mod h1:lMz0gaBYitlMKvVn2Ykw0WpRoqHrq1kjWId/iLrH67I= +github.com/kataras/golog v0.0.15 h1:NPpVJt7Usc741IahumyieIj6j4q0WbwCq+YaLcBWTqc= +github.com/kataras/golog v0.0.15/go.mod h1:lMz0gaBYitlMKvVn2Ykw0WpRoqHrq1kjWId/iLrH67I= github.com/kataras/iris/v12 v12.1.2/go.mod h1:x8XU9FcsqdBvFyDA9brryw7Px8UZ8lquXwVaYKRzBBc= github.com/kataras/iris/v12 v12.1.8 h1:O3gJasjm7ZxpxwTH8tApZsvf274scSGQAUpNe47c37U= github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= @@ -329,6 +331,8 @@ github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5 github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pArKA= github.com/minio/minio v0.0.0-20200514221824-fe8d33452bb9 h1:dFEqJyuuwQ+VeUm9pJ0w1UoxyrcQMxrLgyKRaZwk3FI= github.com/minio/minio v0.0.0-20200514221824-fe8d33452bb9/go.mod h1:wymaytM/HELuwdz7BGZHmQ3XKq2SxPsLeGxyOCaCLiA= +github.com/minio/minio v0.0.0-20200518183557-a3f41c70498c h1:D1oiteaehouuJUb6xEw7+dBiHFF+iKZp+nzGN7BEFXw= +github.com/minio/minio v0.0.0-20200518183557-a3f41c70498c/go.mod h1:wymaytM/HELuwdz7BGZHmQ3XKq2SxPsLeGxyOCaCLiA= github.com/minio/minio-go/v6 v6.0.53 h1:8jzpwiOzZ5Iz7/goFWqNZRICbyWYShbb5rARjrnSCNI= github.com/minio/minio-go/v6 v6.0.53/go.mod h1:DIvC/IApeHX8q1BAMVCXSXwpmrmM+I+iBvhvztQorfI= github.com/minio/minio-go/v6 v6.0.55-0.20200425081427-89eebdef2af0/go.mod h1:KQMM+/44DSlSGSQWSfRrAZ12FVMmpWNuX37i2AX0jfI= @@ -632,6 +636,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c h1:kISX68E8gSkNYAFRFiDU8rl5RIn1sJYKYb/r2vMLDrU= golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/src/main.go b/src/main.go index 50d84b0..afc726e 100644 --- a/src/main.go +++ b/src/main.go @@ -79,44 +79,6 @@ func main() { v1auth.Get("/callback", hdl.AuthCallback) } - //deprecated, will be removed - v1 := app.Party("/api/v1", crs).AllowMethods(iris.MethodOptions) - { - v1.Get("/list-buckets", hdl.BuckList) - v1.Post("/make-bucket", hdl.BuckMake) - v1.Get("/list-buckets-extended", hdl.BuckListExtended) - v1.Post("/delete-bucket", hdl.BuckDelete) - v1.Post("/get-bucket-lifecycle", hdl.BuckGetLifecycle) - v1.Post("/set-bucket-lifecycle", hdl.BuckSetLifecycle) - v1.Post("/get-bucket-events", hdl.BuckGetEvents) - v1.Post("/set-bucket-events", hdl.BuckSetEvents) - v1.Post("/remove-bucket-events", hdl.BuckRemoveEvents) - - v1.Get("/list-users", hdl.UsrList) - v1.Post("/set-status-user", hdl.UsrSetStats) - v1.Post("/delete-user", hdl.UsrDelete) - v1.Post("/add-user", hdl.UsrAdd) - v1.Post("/create-user-extended", hdl.UsrCreateExtended) - v1.Post("/set-user", hdl.UsrSet) - - v1.Get("/list-policies", hdl.PolList) - v1.Post("/add-policy", hdl.PolAdd) - v1.Post("/delete-policy", hdl.PolDelete) - v1.Post("/set-policy", hdl.PolSet) - - v1.Post("/set-status-group", hdl.GrSetStatus) - v1.Post("/get-description-group", hdl.GrSetDescription) - v1.Post("/update-members-group", hdl.GrUpdateMembers) - v1.Get("/list-groups", hdl.GrList) - - v1.Get("/server-info", hdl.ServerInfo) - v1.Get("/disk-info", hdl.DiskInfo) - - v1.Post("/get-kv", hdl.KvGet) - - } - // ------------------------------------------- - v2 := app.Party("/api/v2", crs).AllowMethods(iris.MethodOptions) { v2.Get("/buckets/list", hdl.BuckList)