From 0b718b8b184d1f012766d9eb8b3c1ec833d4a4f0 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Thu, 3 Aug 2023 17:28:02 +0300 Subject: [PATCH] Add IAM identity alias to API --- cluster/docs/ClusterAPI_docs.go | 3 + cluster/docs/ClusterAPI_swagger.json | 3 + cluster/docs/ClusterAPI_swagger.yaml | 2 + docs/docs.go | 104 +++++++++++++++++++++++++++ docs/swagger.json | 104 +++++++++++++++++++++++++++ docs/swagger.yaml | 69 ++++++++++++++++++ http/api/iam.go | 3 + 7 files changed, 288 insertions(+) diff --git a/cluster/docs/ClusterAPI_docs.go b/cluster/docs/ClusterAPI_docs.go index d9c38872..38376ca2 100644 --- a/cluster/docs/ClusterAPI_docs.go +++ b/cluster/docs/ClusterAPI_docs.go @@ -1997,6 +1997,9 @@ const docTemplateClusterAPI = `{ "identity.User": { "type": "object", "properties": { + "alias": { + "type": "string" + }, "auth": { "$ref": "#/definitions/identity.UserAuth" }, diff --git a/cluster/docs/ClusterAPI_swagger.json b/cluster/docs/ClusterAPI_swagger.json index 5ff2aaca..9a86fdb5 100644 --- a/cluster/docs/ClusterAPI_swagger.json +++ b/cluster/docs/ClusterAPI_swagger.json @@ -1989,6 +1989,9 @@ "identity.User": { "type": "object", "properties": { + "alias": { + "type": "string" + }, "auth": { "$ref": "#/definitions/identity.UserAuth" }, diff --git a/cluster/docs/ClusterAPI_swagger.yaml b/cluster/docs/ClusterAPI_swagger.yaml index 3f597676..5a23830d 100644 --- a/cluster/docs/ClusterAPI_swagger.yaml +++ b/cluster/docs/ClusterAPI_swagger.yaml @@ -583,6 +583,8 @@ definitions: type: object identity.User: properties: + alias: + type: string auth: $ref: '#/definitions/identity.UserAuth' name: diff --git a/docs/docs.go b/docs/docs.go index 5ac06bf8..deb291e0 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -375,6 +375,92 @@ const docTemplate = `{ } } }, + "/api/v3/cluster/fs/{storage}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "List all files on a filesystem. The listing can be ordered by name, size, or date of last modification in ascending or descending order.", + "produces": [ + "application/json" + ], + "tags": [ + "v16.?.?" + ], + "summary": "List all files on a filesystem", + "operationId": "cluster-3-list-files", + "parameters": [ + { + "type": "string", + "description": "Name of the filesystem", + "name": "storage", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "glob pattern for file names", + "name": "glob", + "in": "query" + }, + { + "type": "integer", + "description": "minimal size of files", + "name": "size_min", + "in": "query" + }, + { + "type": "integer", + "description": "maximal size of files", + "name": "size_max", + "in": "query" + }, + { + "type": "integer", + "description": "minimal last modification time", + "name": "lastmod_start", + "in": "query" + }, + { + "type": "integer", + "description": "maximal last modification time", + "name": "lastmod_end", + "in": "query" + }, + { + "type": "string", + "description": "none, name, size, lastmod", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "asc, desc", + "name": "order", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/api.FileInfo" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + } + } + }, "/api/v3/cluster/healthy": { "get": { "security": [ @@ -4594,6 +4680,9 @@ const docTemplate = `{ "description": "percent 0-100*npcu", "type": "number" }, + "error": { + "type": "string" + }, "is_throttling": { "type": "boolean" }, @@ -5327,6 +5416,12 @@ const docTemplate = `{ }, "event": { "type": "string" + }, + "level": { + "type": "string" + }, + "message": { + "type": "string" } } }, @@ -5344,6 +5439,9 @@ const docTemplate = `{ "api.FileInfo": { "type": "object", "properties": { + "core_id": { + "type": "string" + }, "last_modified": { "type": "integer", "format": "int64" @@ -5475,6 +5573,9 @@ const docTemplate = `{ "api.IAMUser": { "type": "object", "properties": { + "alias": { + "type": "string" + }, "auth": { "$ref": "#/definitions/api.IAMUserAuth" }, @@ -6886,6 +6987,9 @@ const docTemplate = `{ }, "token": { "type": "string" + }, + "ttl_sec": { + "type": "integer" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index fff31f09..730ad42d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -367,6 +367,92 @@ } } }, + "/api/v3/cluster/fs/{storage}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "List all files on a filesystem. The listing can be ordered by name, size, or date of last modification in ascending or descending order.", + "produces": [ + "application/json" + ], + "tags": [ + "v16.?.?" + ], + "summary": "List all files on a filesystem", + "operationId": "cluster-3-list-files", + "parameters": [ + { + "type": "string", + "description": "Name of the filesystem", + "name": "storage", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "glob pattern for file names", + "name": "glob", + "in": "query" + }, + { + "type": "integer", + "description": "minimal size of files", + "name": "size_min", + "in": "query" + }, + { + "type": "integer", + "description": "maximal size of files", + "name": "size_max", + "in": "query" + }, + { + "type": "integer", + "description": "minimal last modification time", + "name": "lastmod_start", + "in": "query" + }, + { + "type": "integer", + "description": "maximal last modification time", + "name": "lastmod_end", + "in": "query" + }, + { + "type": "string", + "description": "none, name, size, lastmod", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "asc, desc", + "name": "order", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/api.FileInfo" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + } + } + }, "/api/v3/cluster/healthy": { "get": { "security": [ @@ -4586,6 +4672,9 @@ "description": "percent 0-100*npcu", "type": "number" }, + "error": { + "type": "string" + }, "is_throttling": { "type": "boolean" }, @@ -5319,6 +5408,12 @@ }, "event": { "type": "string" + }, + "level": { + "type": "string" + }, + "message": { + "type": "string" } } }, @@ -5336,6 +5431,9 @@ "api.FileInfo": { "type": "object", "properties": { + "core_id": { + "type": "string" + }, "last_modified": { "type": "integer", "format": "int64" @@ -5467,6 +5565,9 @@ "api.IAMUser": { "type": "object", "properties": { + "alias": { + "type": "string" + }, "auth": { "$ref": "#/definitions/api.IAMUserAuth" }, @@ -6878,6 +6979,9 @@ }, "token": { "type": "string" + }, + "ttl_sec": { + "type": "integer" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 74094d81..9b114a01 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -174,6 +174,8 @@ definitions: cpu_used: description: percent 0-100*npcu type: number + error: + type: string is_throttling: type: boolean memory_limit_bytes: @@ -668,6 +670,10 @@ definitions: type: object event: type: string + level: + type: string + message: + type: string type: object api.EventFilters: properties: @@ -678,6 +684,8 @@ definitions: type: object api.FileInfo: properties: + core_id: + type: string last_modified: format: int64 type: integer @@ -765,6 +773,8 @@ definitions: type: object api.IAMUser: properties: + alias: + type: string auth: $ref: '#/definitions/api.IAMUserAuth' name: @@ -1791,6 +1801,8 @@ definitions: type: array token: type: string + ttl_sec: + type: integer type: object api.SessionsActive: additionalProperties: @@ -2664,6 +2676,63 @@ paths: summary: List of identities in the cluster tags: - v16.?.? + /api/v3/cluster/fs/{storage}: + get: + description: List all files on a filesystem. The listing can be ordered by name, + size, or date of last modification in ascending or descending order. + operationId: cluster-3-list-files + parameters: + - description: Name of the filesystem + in: path + name: storage + required: true + type: string + - description: glob pattern for file names + in: query + name: glob + type: string + - description: minimal size of files + in: query + name: size_min + type: integer + - description: maximal size of files + in: query + name: size_max + type: integer + - description: minimal last modification time + in: query + name: lastmod_start + type: integer + - description: maximal last modification time + in: query + name: lastmod_end + type: integer + - description: none, name, size, lastmod + in: query + name: sort + type: string + - description: asc, desc + in: query + name: order + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/api.FileInfo' + type: array + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.Error' + security: + - ApiKeyAuth: [] + summary: List all files on a filesystem + tags: + - v16.?.? /api/v3/cluster/healthy: get: description: Whether the cluster is healthy diff --git a/http/api/iam.go b/http/api/iam.go index 7b87c51d..78866e6b 100644 --- a/http/api/iam.go +++ b/http/api/iam.go @@ -7,6 +7,7 @@ import ( type IAMUser struct { Name string `json:"name"` + Alias string `json:"alias"` Superuser bool `json:"superuser"` Auth IAMUserAuth `json:"auth"` Policies []IAMPolicy `json:"policies"` @@ -14,6 +15,7 @@ type IAMUser struct { func (u *IAMUser) Marshal(user identity.User, policies []access.Policy) { u.Name = user.Name + u.Alias = user.Alias u.Superuser = user.Superuser u.Auth = IAMUserAuth{ API: IAMUserAuthAPI{ @@ -46,6 +48,7 @@ func (u *IAMUser) Marshal(user identity.User, policies []access.Policy) { func (u *IAMUser) Unmarshal() (identity.User, []access.Policy) { iamuser := identity.User{ Name: u.Name, + Alias: u.Alias, Superuser: u.Superuser, Auth: identity.UserAuth{ API: identity.UserAuthAPI{