From 4b1c08cd96a6b7630afb257a233e38c1d208bcf8 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 2 Apr 2024 11:10:55 +0900 Subject: [PATCH] trivial. fix constraint orgniazations and users --- api/swagger/docs.go | 372 ++++++++++++++++++++++++++++++- api/swagger/swagger.json | 372 ++++++++++++++++++++++++++++++- api/swagger/swagger.yaml | 247 +++++++++++++++++++- internal/model/organization.go | 2 +- internal/usecase/organization.go | 26 +++ 5 files changed, 1015 insertions(+), 4 deletions(-) diff --git a/api/swagger/docs.go b/api/swagger/docs.go index 42dfe176..d8548d1c 100644 --- a/api/swagger/docs.go +++ b/api/swagger/docs.go @@ -2267,6 +2267,169 @@ const docTemplate = `{ } } }, + "/clusters/{clusterId}/policy-status": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "클러스터의 정책과 정책 템플릿, 버전 등을 포함한 상태 목록을 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[ListClusterPolicyStatus] 클러스터의 정책과 정책 템플릿, 버전 조회", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "pageSize", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "pageNumber", + "name": "pageNumber", + "in": "query" + }, + { + "type": "string", + "description": "sortColumn", + "name": "sortColumn", + "in": "query" + }, + { + "type": "string", + "description": "sortOrder", + "name": "sortOrder", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv", + "description": "filters", + "name": "filters", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse" + } + } + } + } + }, + "/clusters/{clusterId}/policy-templates/{templateId}": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "템플릿의 클러스터 버전 등 상태를 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[GetClusterPolicyTemplateStatus] 클러스터 템플릿 상태 상세 조회", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 템플릿 식별자(uuid)", + "name": "templateId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse" + } + } + } + }, + "patch": { + "security": [ + { + "JWT": [] + } + ], + "description": "해당 템플릿의 버전 업데이트 및 연관된 정책의 새 기본값을 설정한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[UpdateClusterPolicyTemplateStatus] 템플릿 버전 업데이트", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 템플릿 식별자(uuid)", + "name": "templateId", + "in": "path", + "required": true + }, + { + "description": "update cluster policy template status request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/clusters/{clusterId}/site-values": { "get": { "security": [ @@ -3910,6 +4073,50 @@ const docTemplate = `{ } } }, + "/organizations/{organizationId}/policies/{policyId}/edit": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "정책 정보를 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Policy" + ], + "summary": "[GetPolicy] 정책 조회", + "parameters": [ + { + "type": "string", + "description": "조직 식별자(o로 시작)", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 식별자(uuid)", + "name": "policyId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetPolicyResponse" + } + } + } + } + }, "/organizations/{organizationId}/policy-templates": { "get": { "security": [ @@ -9489,6 +9696,46 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse": { + "type": "object", + "properties": { + "policyDescription": { + "type": "string", + "example": "org 레이블 설정 여부 검사" + }, + "policyId": { + "type": "string", + "example": "0091fe9b-e44b-423d-9562-ac2b73089593" + }, + "policyMandatory": { + "type": "boolean" + }, + "policyName": { + "type": "string", + "example": "org 레이블 요구" + }, + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateDescription": { + "type": "string", + "example": "파라미터로 설정된 레이블 검사" + }, + "templateId": { + "type": "string", + "example": "708d1e5b-4e6f-40e9-87a3-329e2fd051a5" + }, + "templateLatestVerson": { + "type": "string", + "example": "v1.0.3" + }, + "templateName": { + "type": "string", + "example": "레이블 요구" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.ClusterResponse": { "type": "object", "properties": { @@ -10859,6 +11106,50 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse": { + "type": "object", + "properties": { + "affectedPolicies": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyStatus" + } + }, + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateDescription": { + "type": "string", + "example": "파라미터로 설정된 레이블 검사" + }, + "templateId": { + "type": "string", + "example": "708d1e5b-4e6f-40e9-87a3-329e2fd051a5" + }, + "templateLatestVerson": { + "type": "string", + "example": "v1.0.3" + }, + "templateLatestVersonReleaseDate": { + "type": "string", + "format": "date-time" + }, + "templateMandatory": { + "type": "boolean" + }, + "templateName": { + "type": "string", + "example": "레이블 요구" + }, + "updatedPolicyParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.GetClusterResponse": { "type": "object", "properties": { @@ -11437,6 +11728,17 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse": { + "type": "object", + "properties": { + "polices": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.ListOrganizationResponse": { "type": "object", "properties": { @@ -11828,6 +12130,23 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.PolicyParameter": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatable": { + "type": "boolean" + }, + "value": { + "type": "string" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.PolicyResponse": { "type": "object", "properties": { @@ -11844,6 +12163,12 @@ const docTemplate = `{ "enforcementAction": { "type": "string" }, + "filledParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ParameterDef" + } + }, "id": { "type": "string", "example": "d98ef5f1-4a68-4047-a446-2207787ce3ff" @@ -11862,7 +12187,7 @@ const docTemplate = `{ }, "parameters": { "type": "string", - "example": "\"labels\":{\"key\":\"owner\",\"allowedRegex:^[a-zA-Z]+.agilebank.demo$}\"" + "example": "{\"labels\":{\"key\":\"owner\",\"allowedRegex:^[a-zA-Z]+.agilebank.demo$}\"}" }, "policyName": { "type": "string", @@ -11895,6 +12220,24 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.PolicyStatus": { + "type": "object", + "properties": { + "policyId": { + "type": "string", + "example": "0091fe9b-e44b-423d-9562-ac2b73089593" + }, + "policyName": { + "type": "string" + }, + "policyPolicyParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyParameter" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.PolicyTemplateResponse": { "type": "object", "properties": { @@ -13180,6 +13523,19 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest": { + "type": "object", + "properties": { + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateTargetVerson": { + "type": "string", + "example": "v1.0.3" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.UpdateDashboardRequest": { "type": "object", "properties": { @@ -13729,6 +14085,20 @@ const docTemplate = `{ } } }, + "github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.VerifyIdentityForLostIdRequest": { "type": "object", "required": [ diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index e44189d6..7b2293c4 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -2261,6 +2261,169 @@ } } }, + "/clusters/{clusterId}/policy-status": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "클러스터의 정책과 정책 템플릿, 버전 등을 포함한 상태 목록을 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[ListClusterPolicyStatus] 클러스터의 정책과 정책 템플릿, 버전 조회", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "pageSize", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "description": "pageNumber", + "name": "pageNumber", + "in": "query" + }, + { + "type": "string", + "description": "sortColumn", + "name": "sortColumn", + "in": "query" + }, + { + "type": "string", + "description": "sortOrder", + "name": "sortOrder", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv", + "description": "filters", + "name": "filters", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse" + } + } + } + } + }, + "/clusters/{clusterId}/policy-templates/{templateId}": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "템플릿의 클러스터 버전 등 상태를 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[GetClusterPolicyTemplateStatus] 클러스터 템플릿 상태 상세 조회", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 템플릿 식별자(uuid)", + "name": "templateId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse" + } + } + } + }, + "patch": { + "security": [ + { + "JWT": [] + } + ], + "description": "해당 템플릿의 버전 업데이트 및 연관된 정책의 새 기본값을 설정한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ClusterPolicyStatus" + ], + "summary": "[UpdateClusterPolicyTemplateStatus] 템플릿 버전 업데이트", + "parameters": [ + { + "type": "string", + "description": "클러스터 식별자(uuid)", + "name": "clusterId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 템플릿 식별자(uuid)", + "name": "templateId", + "in": "path", + "required": true + }, + { + "description": "update cluster policy template status request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/clusters/{clusterId}/site-values": { "get": { "security": [ @@ -3904,6 +4067,50 @@ } } }, + "/organizations/{organizationId}/policies/{policyId}/edit": { + "get": { + "security": [ + { + "JWT": [] + } + ], + "description": "정책 정보를 조회한다.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Policy" + ], + "summary": "[GetPolicy] 정책 조회", + "parameters": [ + { + "type": "string", + "description": "조직 식별자(o로 시작)", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "정책 식별자(uuid)", + "name": "policyId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetPolicyResponse" + } + } + } + } + }, "/organizations/{organizationId}/policy-templates": { "get": { "security": [ @@ -9483,6 +9690,46 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse": { + "type": "object", + "properties": { + "policyDescription": { + "type": "string", + "example": "org 레이블 설정 여부 검사" + }, + "policyId": { + "type": "string", + "example": "0091fe9b-e44b-423d-9562-ac2b73089593" + }, + "policyMandatory": { + "type": "boolean" + }, + "policyName": { + "type": "string", + "example": "org 레이블 요구" + }, + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateDescription": { + "type": "string", + "example": "파라미터로 설정된 레이블 검사" + }, + "templateId": { + "type": "string", + "example": "708d1e5b-4e6f-40e9-87a3-329e2fd051a5" + }, + "templateLatestVerson": { + "type": "string", + "example": "v1.0.3" + }, + "templateName": { + "type": "string", + "example": "레이블 요구" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.ClusterResponse": { "type": "object", "properties": { @@ -10853,6 +11100,50 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse": { + "type": "object", + "properties": { + "affectedPolicies": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyStatus" + } + }, + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateDescription": { + "type": "string", + "example": "파라미터로 설정된 레이블 검사" + }, + "templateId": { + "type": "string", + "example": "708d1e5b-4e6f-40e9-87a3-329e2fd051a5" + }, + "templateLatestVerson": { + "type": "string", + "example": "v1.0.3" + }, + "templateLatestVersonReleaseDate": { + "type": "string", + "format": "date-time" + }, + "templateMandatory": { + "type": "boolean" + }, + "templateName": { + "type": "string", + "example": "레이블 요구" + }, + "updatedPolicyParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.GetClusterResponse": { "type": "object", "properties": { @@ -11431,6 +11722,17 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse": { + "type": "object", + "properties": { + "polices": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.ListOrganizationResponse": { "type": "object", "properties": { @@ -11822,6 +12124,23 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.PolicyParameter": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatable": { + "type": "boolean" + }, + "value": { + "type": "string" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.PolicyResponse": { "type": "object", "properties": { @@ -11838,6 +12157,12 @@ "enforcementAction": { "type": "string" }, + "filledParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.ParameterDef" + } + }, "id": { "type": "string", "example": "d98ef5f1-4a68-4047-a446-2207787ce3ff" @@ -11856,7 +12181,7 @@ }, "parameters": { "type": "string", - "example": "\"labels\":{\"key\":\"owner\",\"allowedRegex:^[a-zA-Z]+.agilebank.demo$}\"" + "example": "{\"labels\":{\"key\":\"owner\",\"allowedRegex:^[a-zA-Z]+.agilebank.demo$}\"}" }, "policyName": { "type": "string", @@ -11889,6 +12214,24 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.PolicyStatus": { + "type": "object", + "properties": { + "policyId": { + "type": "string", + "example": "0091fe9b-e44b-423d-9562-ac2b73089593" + }, + "policyName": { + "type": "string" + }, + "policyPolicyParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyParameter" + } + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.PolicyTemplateResponse": { "type": "object", "properties": { @@ -13174,6 +13517,19 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest": { + "type": "object", + "properties": { + "templateCurrentVersion": { + "type": "string", + "example": "v1.0.1" + }, + "templateTargetVerson": { + "type": "string", + "example": "v1.0.3" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.UpdateDashboardRequest": { "type": "object", "properties": { @@ -13723,6 +14079,20 @@ } } }, + "github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "github_com_openinfradev_tks-api_pkg_domain.VerifyIdentityForLostIdRequest": { "type": "object", "required": [ diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 70743dae..ac85f22d 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -546,6 +546,35 @@ definitions: validity: type: integer type: object + github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse: + properties: + policyDescription: + example: org 레이블 설정 여부 검사 + type: string + policyId: + example: 0091fe9b-e44b-423d-9562-ac2b73089593 + type: string + policyMandatory: + type: boolean + policyName: + example: org 레이블 요구 + type: string + templateCurrentVersion: + example: v1.0.1 + type: string + templateDescription: + example: 파라미터로 설정된 레이블 검사 + type: string + templateId: + example: 708d1e5b-4e6f-40e9-87a3-329e2fd051a5 + type: string + templateLatestVerson: + example: v1.0.3 + type: string + templateName: + example: 레이블 요구 + type: string + type: object github_com_openinfradev_tks-api_pkg_domain.ClusterResponse: properties: byoClusterEndpointHost: @@ -1470,6 +1499,37 @@ definitions: $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.ClusterNode' type: array type: object + github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse: + properties: + affectedPolicies: + items: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyStatus' + type: array + templateCurrentVersion: + example: v1.0.1 + type: string + templateDescription: + example: 파라미터로 설정된 레이블 검사 + type: string + templateId: + example: 708d1e5b-4e6f-40e9-87a3-329e2fd051a5 + type: string + templateLatestVerson: + example: v1.0.3 + type: string + templateLatestVersonReleaseDate: + format: date-time + type: string + templateMandatory: + type: boolean + templateName: + example: 레이블 요구 + type: string + updatedPolicyParameters: + items: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter' + type: array + type: object github_com_openinfradev_tks-api_pkg_domain.GetClusterResponse: properties: cluster: @@ -1841,6 +1901,13 @@ definitions: id: type: string type: object + github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse: + properties: + polices: + items: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.ClusterPolicyStatusResponse' + type: array + type: object github_com_openinfradev_tks-api_pkg_domain.ListOrganizationResponse: properties: organizations: @@ -2099,6 +2166,17 @@ definitions: value: type: integer type: object + github_com_openinfradev_tks-api_pkg_domain.PolicyParameter: + properties: + name: + type: string + type: + type: string + updatable: + type: boolean + value: + type: string + type: object github_com_openinfradev_tks-api_pkg_domain.PolicyResponse: properties: createdAt: @@ -2110,6 +2188,10 @@ definitions: type: string enforcementAction: type: string + filledParameters: + items: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.ParameterDef' + type: array id: example: d98ef5f1-4a68-4047-a446-2207787ce3ff type: string @@ -2122,7 +2204,7 @@ definitions: refer: match.Match type: object parameters: - example: '"labels":{"key":"owner","allowedRegex:^[a-zA-Z]+.agilebank.demo$}"' + example: '{"labels":{"key":"owner","allowedRegex:^[a-zA-Z]+.agilebank.demo$}"}' type: string policyName: example: label 정책 @@ -2146,6 +2228,18 @@ definitions: updator: $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.SimpleUserResponse' type: object + github_com_openinfradev_tks-api_pkg_domain.PolicyStatus: + properties: + policyId: + example: 0091fe9b-e44b-423d-9562-ac2b73089593 + type: string + policyName: + type: string + policyPolicyParameters: + items: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.PolicyParameter' + type: array + type: object github_com_openinfradev_tks-api_pkg_domain.PolicyTemplateResponse: properties: createdAt: @@ -3001,6 +3095,15 @@ definitions: description: type: string type: object + github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest: + properties: + templateCurrentVersion: + example: v1.0.1 + type: string + templateTargetVerson: + example: v1.0.3 + type: string + type: object github_com_openinfradev_tks-api_pkg_domain.UpdateDashboardRequest: properties: groupName: @@ -3369,6 +3472,15 @@ definitions: type: string type: object type: object + github_com_openinfradev_tks-api_pkg_domain.UpdatedPolicyTemplateParameter: + properties: + name: + type: string + type: + type: string + value: + type: string + type: object github_com_openinfradev_tks-api_pkg_domain.VerifyIdentityForLostIdRequest: properties: email: @@ -5163,6 +5275,111 @@ paths: summary: Get nodes information for BYOH tags: - Clusters + /clusters/{clusterId}/policy-status: + get: + consumes: + - application/json + description: 클러스터의 정책과 정책 템플릿, 버전 등을 포함한 상태 목록을 조회한다. + parameters: + - description: 클러스터 식별자(uuid) + in: path + name: clusterId + required: true + type: string + - description: pageSize + in: query + name: pageSize + type: string + - description: pageNumber + in: query + name: pageNumber + type: string + - description: sortColumn + in: query + name: sortColumn + type: string + - description: sortOrder + in: query + name: sortOrder + type: string + - collectionFormat: csv + description: filters + in: query + items: + type: string + name: filters + type: array + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.ListClusterPolicyStatusResponse' + security: + - JWT: [] + summary: '[ListClusterPolicyStatus] 클러스터의 정책과 정책 템플릿, 버전 조회' + tags: + - ClusterPolicyStatus + /clusters/{clusterId}/policy-templates/{templateId}: + get: + consumes: + - application/json + description: 템플릿의 클러스터 버전 등 상태를 조회한다. + parameters: + - description: 클러스터 식별자(uuid) + in: path + name: clusterId + required: true + type: string + - description: 정책 템플릿 식별자(uuid) + in: path + name: templateId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetClusterPolicyTemplateStatusResponse' + security: + - JWT: [] + summary: '[GetClusterPolicyTemplateStatus] 클러스터 템플릿 상태 상세 조회' + tags: + - ClusterPolicyStatus + patch: + consumes: + - application/json + description: 해당 템플릿의 버전 업데이트 및 연관된 정책의 새 기본값을 설정한다. + parameters: + - description: 클러스터 식별자(uuid) + in: path + name: clusterId + required: true + type: string + - description: 정책 템플릿 식별자(uuid) + in: path + name: templateId + required: true + type: string + - description: update cluster policy template status request + in: body + name: body + required: true + schema: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.UpdateClusterPolicyTemplateStatusRequest' + produces: + - application/json + responses: + "200": + description: OK + security: + - JWT: [] + summary: '[UpdateClusterPolicyTemplateStatus] 템플릿 버전 업데이트' + tags: + - ClusterPolicyStatus /clusters/{clusterId}/site-values: get: consumes: @@ -6184,6 +6401,34 @@ paths: summary: '[UpdatePolicyTargetClusters] 정책 적용 대상 클러스터 수정' tags: - Policy + /organizations/{organizationId}/policies/{policyId}/edit: + get: + consumes: + - application/json + description: 정책 정보를 조회한다. + parameters: + - description: 조직 식별자(o로 시작) + in: path + name: organizationId + required: true + type: string + - description: 정책 식별자(uuid) + in: path + name: policyId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetPolicyResponse' + security: + - JWT: [] + summary: '[GetPolicy] 정책 조회' + tags: + - Policy /organizations/{organizationId}/policies/name/{policyName}/existence: get: consumes: diff --git a/internal/model/organization.go b/internal/model/organization.go index 5f466a31..f912f774 100644 --- a/internal/model/organization.go +++ b/internal/model/organization.go @@ -27,5 +27,5 @@ type Organization struct { SystemNotificationTemplateIds []uuid.UUID `gorm:"-:all"` ClusterCount int `gorm:"-:all"` AdminId *uuid.UUID - Admin *User `gorm:"foreignKey:AdminId"` + Admin *User `gorm:"-:all"` } diff --git a/internal/usecase/organization.go b/internal/usecase/organization.go index 9fa70a56..ea794543 100644 --- a/internal/usecase/organization.go +++ b/internal/usecase/organization.go @@ -32,6 +32,7 @@ type IOrganizationUsecase interface { type OrganizationUsecase struct { repo repository.IOrganizationRepository + userRepo repository.IUserRepository roleRepo repository.IRoleRepository clusterRepo repository.IClusterRepository stackTemplateRepo repository.IStackTemplateRepository @@ -43,6 +44,7 @@ type OrganizationUsecase struct { func NewOrganizationUsecase(r repository.Repository, argoClient argowf.ArgoClient, kc keycloak.IKeycloak) IOrganizationUsecase { return &OrganizationUsecase{ repo: r.Organization, + userRepo: r.User, roleRepo: r.Role, clusterRepo: r.Cluster, stackTemplateRepo: r.StackTemplate, @@ -99,6 +101,22 @@ func (u *OrganizationUsecase) Fetch(ctx context.Context, pg *pagination.Paginati if err != nil { return nil, err } + + // Make Admin object + users, err := u.userRepo.List(ctx) + if err == nil { + for i, organization := range *organizations { + if organization.AdminId == nil { + continue + } + for _, user := range *users { + if user.ID == *organization.AdminId { + (*organizations)[i].Admin = &user + } + } + } + } + return organizations, nil } func (u *OrganizationUsecase) Get(ctx context.Context, organizationId string) (out model.Organization, err error) { @@ -107,6 +125,14 @@ func (u *OrganizationUsecase) Get(ctx context.Context, organizationId string) (o return model.Organization{}, httpErrors.NewNotFoundError(err, "", "") } + // Make Admin object + if out.AdminId != nil { + admin, err := u.userRepo.GetByUuid(ctx, *out.AdminId) + if err == nil { + out.Admin = &admin + } + } + clusters, err := u.clusterRepo.FetchByOrganizationId(ctx, organizationId, uuid.Nil, nil) if err != nil { log.Info(ctx, err)