diff --git a/internal/server/api/v1/repos/interface.go b/internal/server/api/v1/repos/interface.go index 66877f80..9da73e27 100644 --- a/internal/server/api/v1/repos/interface.go +++ b/internal/server/api/v1/repos/interface.go @@ -18,6 +18,7 @@ type ( ListReposOfUser(ctx context.Context, u *ent.User, q, namespace, name string, sorted bool, page, perPage int) ([]*ent.Repo, error) FindRepoOfUserByID(ctx context.Context, u *ent.User, id string) (*ent.Repo, error) + FindRepoOfUserByNamespaceName(ctx context.Context, u *ent.User, namespace, name string) (*ent.Repo, error) UpdateRepo(ctx context.Context, r *ent.Repo) (*ent.Repo, error) ActivateRepo(ctx context.Context, u *ent.User, r *ent.Repo, c *vo.WebhookConfig) (*ent.Repo, error) DeactivateRepo(ctx context.Context, u *ent.User, r *ent.Repo) (*ent.Repo, error) diff --git a/internal/server/api/v1/repos/middleware.go b/internal/server/api/v1/repos/middleware.go index 0c92820a..06052f45 100644 --- a/internal/server/api/v1/repos/middleware.go +++ b/internal/server/api/v1/repos/middleware.go @@ -33,30 +33,31 @@ func (rm *RepoMiddleware) RepoReadPerm() gin.HandlerFunc { ctx := c.Request.Context() var ( - id = c.Param("id") + namespace = c.Param("namespace") + name = c.Param("name") ) v, _ := c.Get(gb.KeyUser) u := v.(*ent.User) - r, err := rm.i.FindRepoOfUserByID(ctx, u, id) + r, err := rm.i.FindRepoOfUserByNamespaceName(ctx, u, namespace, name) if ent.IsNotFound(err) { - rm.log.Warn("The repository is not found.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("The repository is not found.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusNotFound, "The repository is not found.") return } else if err != nil { - rm.log.Error("It has failed to get the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Error("It has failed to get the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the repository.") return } _, err = rm.i.FindPermOfRepo(ctx, r, u) if ent.IsNotFound(err) { - rm.log.Warn("It is denied to access the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("It is denied to access the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusForbidden, "It is denied to access the repository.") return } else if err != nil { - rm.log.Error("It has failed to get the permission.", zap.String("repoID", id), zap.Error(err)) + rm.log.Error("It has failed to get the permission.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the permission.") return } @@ -70,36 +71,37 @@ func (rm *RepoMiddleware) RepoWritePerm() gin.HandlerFunc { ctx := c.Request.Context() var ( - id = c.Param("id") + namespace = c.Param("namespace") + name = c.Param("name") ) v, _ := c.Get(gb.KeyUser) u := v.(*ent.User) - r, err := rm.i.FindRepoOfUserByID(ctx, u, id) + r, err := rm.i.FindRepoOfUserByNamespaceName(ctx, u, namespace, name) if ent.IsNotFound(err) { - rm.log.Warn("The repository is not found.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("The repository is not found.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusNotFound, "The repository is not found.") return } else if err != nil { - rm.log.Error("It has failed to get the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Error("It has failed to get the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the repository.") return } p, err := rm.i.FindPermOfRepo(ctx, r, u) if ent.IsNotFound(err) { - rm.log.Warn("It is denied to access the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("It is denied to access the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusForbidden, "It is denied to access the repository.") return } else if err != nil { - rm.log.Error("It has failed to get the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Error("It has failed to get the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the permission.") return } if !(p.RepoPerm == perm.RepoPermWrite || p.RepoPerm == perm.RepoPermAdmin) { - rm.log.Warn("The access is forbidden. Only write permission can access.", zap.String("repo_id", id)) + rm.log.Warn("The access is forbidden. Only write permission can access.", zap.String("repo", namespace+"/"+name)) gb.AbortWithErrorResponse(c, http.StatusForbidden, "Only write permission can access.") return } @@ -113,36 +115,37 @@ func (rm *RepoMiddleware) RepoAdminPerm() gin.HandlerFunc { ctx := c.Request.Context() var ( - id = c.Param("id") + namespace = c.Param("namespace") + name = c.Param("name") ) v, _ := c.Get(gb.KeyUser) u := v.(*ent.User) - r, err := rm.i.FindRepoOfUserByID(ctx, u, id) + r, err := rm.i.FindRepoOfUserByNamespaceName(ctx, u, namespace, name) if ent.IsNotFound(err) { - rm.log.Warn("The repository is not found.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("The repository is not found.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusNotFound, "The repository is not found.") return } else if err != nil { - rm.log.Error("It has failed to get the repository.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Error("It has failed to get the repository.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the repository.") return } p, err := rm.i.FindPermOfRepo(ctx, r, u) if ent.IsNotFound(err) { - rm.log.Warn("It is denied to access the repo.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Warn("It is denied to access the repo.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusForbidden, "It is denied to access the repo.") return } else if err != nil { - rm.log.Error("It has failed to get the permission.", zap.String("repo_id", id), zap.Error(err)) + rm.log.Error("It has failed to get the permission.", zap.String("repo", namespace+"/"+name), zap.Error(err)) gb.AbortWithErrorResponse(c, http.StatusInternalServerError, "It has failed to get the permission.") return } if p.RepoPerm != perm.RepoPermAdmin { - rm.log.Warn("The access is forbidden. Only admin permission can access.", zap.String("repo_id", id)) + rm.log.Warn("The access is forbidden. Only admin permission can access.", zap.String("repo", namespace+"/"+name)) gb.AbortWithErrorResponse(c, http.StatusForbidden, "Only admin permission can access.") return } diff --git a/internal/server/api/v1/repos/middleware_test.go b/internal/server/api/v1/repos/middleware_test.go index 2dc7ed1f..7c55c20a 100644 --- a/internal/server/api/v1/repos/middleware_test.go +++ b/internal/server/api/v1/repos/middleware_test.go @@ -19,9 +19,11 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { t.Run("Return 403 error when the permission is read.", func(t *testing.T) { input := struct { - RepoID string + namespace string + name string }{ - RepoID: "1", + namespace: "octocat", + name: "hello-world", } ctrl := gomock.NewController(t) @@ -30,17 +32,16 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { t.Logf("It finds the repository.") m. EXPECT(). - FindRepoOfUserByID(ctx, gomock.AssignableToTypeOf(&ent.User{}), gomock.Eq(input.RepoID)). + FindRepoOfUserByNamespaceName(ctx, gomock.AssignableToTypeOf(&ent.User{}), input.namespace, input.name). Return(&ent.Repo{ - ID: input.RepoID, + Namespace: input.namespace, + Name: input.name, }, nil) t.Logf("It returns the read permission.") m. EXPECT(). - FindPermOfRepo(ctx, gomock.Eq(&ent.Repo{ - ID: input.RepoID, - }), gomock.AssignableToTypeOf(&ent.User{})). + FindPermOfRepo(ctx, gomock.AssignableToTypeOf(&ent.Repo{}), gomock.AssignableToTypeOf(&ent.User{})). Return(&ent.Perm{ RepoPerm: perm.RepoPermRead, }, nil) @@ -49,14 +50,14 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { router := gin.New() rm := NewRepoMiddleware(m) - router.PATCH("/repos/:id", func(c *gin.Context) { + router.PATCH("/repos/:namespace/:name", func(c *gin.Context) { // Mocking middlewares to return a user and a repository. c.Set(global.KeyUser, &ent.User{}) }, rm.RepoWritePerm(), func(c *gin.Context) { c.Status(http.StatusOK) }) - req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s", input.RepoID), nil) + req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s/%s", input.namespace, input.name), nil) w := httptest.NewRecorder() router.ServeHTTP(w, req) @@ -68,9 +69,11 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { t.Run("Return 200 when the permission is write.", func(t *testing.T) { input := struct { - RepoID string + namespace string + name string }{ - RepoID: "1", + namespace: "octocat", + name: "hello-world", } ctrl := gomock.NewController(t) @@ -79,17 +82,16 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { t.Logf("It finds the repository.") m. EXPECT(). - FindRepoOfUserByID(ctx, gomock.AssignableToTypeOf(&ent.User{}), gomock.Eq(input.RepoID)). + FindRepoOfUserByNamespaceName(ctx, gomock.AssignableToTypeOf(&ent.User{}), input.namespace, input.name). Return(&ent.Repo{ - ID: input.RepoID, + Namespace: input.namespace, + Name: input.name, }, nil) t.Logf("It returns the read permission.") m. EXPECT(). - FindPermOfRepo(ctx, gomock.Eq(&ent.Repo{ - ID: input.RepoID, - }), gomock.AssignableToTypeOf(&ent.User{})). + FindPermOfRepo(ctx, gomock.AssignableToTypeOf(&ent.Repo{}), gomock.AssignableToTypeOf(&ent.User{})). Return(&ent.Perm{ RepoPerm: perm.RepoPermWrite, }, nil) @@ -98,14 +100,14 @@ func TestRepoMiddleware_RepoWritePerm(t *testing.T) { router := gin.New() rm := NewRepoMiddleware(m) - router.PATCH("/repos/:id", func(c *gin.Context) { + router.PATCH("/repos/:namespace/:name", func(c *gin.Context) { // Mocking middlewares to return a user and a repository. c.Set(global.KeyUser, &ent.User{}) }, rm.RepoWritePerm(), func(c *gin.Context) { c.Status(http.StatusOK) }) - req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s", input.RepoID), nil) + req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s/%s", input.namespace, input.name), nil) w := httptest.NewRecorder() router.ServeHTTP(w, req) @@ -121,9 +123,11 @@ func TestRepoMiddleware_RepoAdminPerm(t *testing.T) { t.Run("Return 200 when the permission is admin.", func(t *testing.T) { input := struct { - RepoID string + namespace string + name string }{ - RepoID: "1", + namespace: "octocat", + name: "hello-world", } ctrl := gomock.NewController(t) @@ -132,17 +136,16 @@ func TestRepoMiddleware_RepoAdminPerm(t *testing.T) { t.Logf("It finds the repository.") m. EXPECT(). - FindRepoOfUserByID(ctx, gomock.AssignableToTypeOf(&ent.User{}), gomock.Eq(input.RepoID)). + FindRepoOfUserByNamespaceName(ctx, gomock.AssignableToTypeOf(&ent.User{}), input.namespace, input.name). Return(&ent.Repo{ - ID: input.RepoID, + Namespace: input.namespace, + Name: input.name, }, nil) t.Logf("It returns the read permission.") m. EXPECT(). - FindPermOfRepo(ctx, gomock.Eq(&ent.Repo{ - ID: input.RepoID, - }), gomock.AssignableToTypeOf(&ent.User{})). + FindPermOfRepo(ctx, gomock.AssignableToTypeOf(&ent.Repo{}), gomock.AssignableToTypeOf(&ent.User{})). Return(&ent.Perm{ RepoPerm: perm.RepoPermAdmin, }, nil) @@ -151,14 +154,14 @@ func TestRepoMiddleware_RepoAdminPerm(t *testing.T) { router := gin.New() rm := NewRepoMiddleware(m) - router.PATCH("/repos/:id", func(c *gin.Context) { + router.PATCH("/repos/:namespace/:name", func(c *gin.Context) { // Mocking middlewares to return a user and a repository. c.Set(global.KeyUser, &ent.User{}) }, rm.RepoWritePerm(), func(c *gin.Context) { c.Status(http.StatusOK) }) - req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s", input.RepoID), nil) + req, _ := http.NewRequest("PATCH", fmt.Sprintf("/repos/%s/%s", input.namespace, input.name), nil) w := httptest.NewRecorder() router.ServeHTTP(w, req) diff --git a/internal/server/api/v1/repos/mock/interactor.go b/internal/server/api/v1/repos/mock/interactor.go index fdab8b65..395c3033 100644 --- a/internal/server/api/v1/repos/mock/interactor.go +++ b/internal/server/api/v1/repos/mock/interactor.go @@ -259,21 +259,6 @@ func (mr *MockInteractorMockRecorder) FindLockByID(ctx, id interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLockByID", reflect.TypeOf((*MockInteractor)(nil).FindLockByID), ctx, id) } -// FindLockOfRepoByEnv mocks base method. -func (m *MockInteractor) FindLockOfRepoByEnv(ctx context.Context, r *ent.Repo, env string) (*ent.Lock, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FindLockOfRepoByEnv", ctx, r, env) - ret0, _ := ret[0].(*ent.Lock) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// FindLockOfRepoByEnv indicates an expected call of FindLockOfRepoByEnv. -func (mr *MockInteractorMockRecorder) FindLockOfRepoByEnv(ctx, r, env interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLockOfRepoByEnv", reflect.TypeOf((*MockInteractor)(nil).FindLockOfRepoByEnv), ctx, r, env) -} - // FindPermOfRepo mocks base method. func (m *MockInteractor) FindPermOfRepo(ctx context.Context, r *ent.Repo, u *ent.User) (*ent.Perm, error) { m.ctrl.T.Helper() @@ -319,6 +304,21 @@ func (mr *MockInteractorMockRecorder) FindRepoOfUserByID(ctx, u, id interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindRepoOfUserByID", reflect.TypeOf((*MockInteractor)(nil).FindRepoOfUserByID), ctx, u, id) } +// FindRepoOfUserByNamespaceName mocks base method. +func (m *MockInteractor) FindRepoOfUserByNamespaceName(ctx context.Context, u *ent.User, namespace, name string) (*ent.Repo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindRepoOfUserByNamespaceName", ctx, u, namespace, name) + ret0, _ := ret[0].(*ent.Repo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindRepoOfUserByNamespaceName indicates an expected call of FindRepoOfUserByNamespaceName. +func (mr *MockInteractorMockRecorder) FindRepoOfUserByNamespaceName(ctx, u, namespace, name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindRepoOfUserByNamespaceName", reflect.TypeOf((*MockInteractor)(nil).FindRepoOfUserByNamespaceName), ctx, u, namespace, name) +} + // FindUserByID mocks base method. func (m *MockInteractor) FindUserByID(ctx context.Context, id string) (*ent.User, error) { m.ctrl.T.Helper() diff --git a/internal/server/router.go b/internal/server/router.go index 6aded936..b383331b 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -123,32 +123,32 @@ func NewRouter(c *RouterConfig) *gin.Engine { c.Interactor, ) repov1.GET("", r.ListRepos) - repov1.GET("/:id", rm.RepoReadPerm(), r.GetRepo) - repov1.PATCH("/:id", rm.RepoAdminPerm(), r.UpdateRepo) - repov1.GET("/:id/commits", rm.RepoReadPerm(), r.ListCommits) - repov1.GET("/:id/commits/:sha", rm.RepoReadPerm(), r.GetCommit) - repov1.GET("/:id/commits/:sha/statuses", rm.RepoReadPerm(), r.ListStatuses) - repov1.GET("/:id/branches", rm.RepoReadPerm(), r.ListBranches) - repov1.GET("/:id/branches/:branch", rm.RepoReadPerm(), r.GetBranch) - repov1.GET("/:id/tags", rm.RepoReadPerm(), r.ListTags) - repov1.GET("/:id/tags/:tag", rm.RepoReadPerm(), r.GetTag) - repov1.GET("/:id/deployments", rm.RepoReadPerm(), r.ListDeployments) - repov1.POST("/:id/deployments", rm.RepoWritePerm(), r.CreateDeployment) - repov1.GET("/:id/deployments/:number", rm.RepoReadPerm(), r.GetDeploymentByNumber) - repov1.PATCH("/:id/deployments/:number", rm.RepoWritePerm(), r.UpdateDeployment) - repov1.GET("/:id/deployments/:number/changes", rm.RepoReadPerm(), r.ListDeploymentChanges) - repov1.POST("/:id/deployments/:number/rollback", rm.RepoWritePerm(), r.RollbackDeployment) - repov1.GET("/:id/deployments/:number/approvals", rm.RepoReadPerm(), r.ListApprovals) - repov1.POST("/:id/deployments/:number/approvals", rm.RepoReadPerm(), r.CreateApproval) - repov1.GET("/:id/deployments/:number/approval", rm.RepoReadPerm(), r.GetMyApproval) - repov1.PATCH("/:id/deployments/:number/approval", rm.RepoReadPerm(), r.UpdateApproval) - repov1.GET("/:id/approvals/:aid", rm.RepoReadPerm(), r.GetApproval) - repov1.DELETE("/:id/approvals/:aid", rm.RepoReadPerm(), r.DeleteApproval) - repov1.GET("/:id/locks", rm.RepoReadPerm(), r.ListLocks) - repov1.POST("/:id/locks", rm.RepoWritePerm(), r.CreateLock) - repov1.DELETE("/:id/locks/:lockID", rm.RepoWritePerm(), r.DeleteLock) - repov1.GET("/:id/perms", rm.RepoReadPerm(), r.ListPerms) - repov1.GET("/:id/config", rm.RepoReadPerm(), r.GetConfig) + repov1.GET("/:namespace/:name", rm.RepoReadPerm(), r.GetRepo) + repov1.PATCH("/:namespace/:name", rm.RepoAdminPerm(), r.UpdateRepo) + repov1.GET("/:namespace/:name/commits", rm.RepoReadPerm(), r.ListCommits) + repov1.GET("/:namespace/:name/commits/:sha", rm.RepoReadPerm(), r.GetCommit) + repov1.GET("/:namespace/:name/commits/:sha/statuses", rm.RepoReadPerm(), r.ListStatuses) + repov1.GET("/:namespace/:name/branches", rm.RepoReadPerm(), r.ListBranches) + repov1.GET("/:namespace/:name/branches/:branch", rm.RepoReadPerm(), r.GetBranch) + repov1.GET("/:namespace/:name/tags", rm.RepoReadPerm(), r.ListTags) + repov1.GET("/:namespace/:name/tags/:tag", rm.RepoReadPerm(), r.GetTag) + repov1.GET("/:namespace/:name/deployments", rm.RepoReadPerm(), r.ListDeployments) + repov1.POST("/:namespace/:name/deployments", rm.RepoWritePerm(), r.CreateDeployment) + repov1.GET("/:namespace/:name/deployments/:number", rm.RepoReadPerm(), r.GetDeploymentByNumber) + repov1.PATCH("/:namespace/:name/deployments/:number", rm.RepoWritePerm(), r.UpdateDeployment) + repov1.GET("/:namespace/:name/deployments/:number/changes", rm.RepoReadPerm(), r.ListDeploymentChanges) + repov1.POST("/:namespace/:name/deployments/:number/rollback", rm.RepoWritePerm(), r.RollbackDeployment) + repov1.GET("/:namespace/:name/deployments/:number/approvals", rm.RepoReadPerm(), r.ListApprovals) + repov1.POST("/:namespace/:name/deployments/:number/approvals", rm.RepoReadPerm(), r.CreateApproval) + repov1.GET("/:namespace/:name/deployments/:number/approval", rm.RepoReadPerm(), r.GetMyApproval) + repov1.PATCH("/:namespace/:name/deployments/:number/approval", rm.RepoReadPerm(), r.UpdateApproval) + repov1.GET("/:namespace/:name/approvals/:aid", rm.RepoReadPerm(), r.GetApproval) + repov1.DELETE("/:namespace/:name/approvals/:aid", rm.RepoReadPerm(), r.DeleteApproval) + repov1.GET("/:namespace/:name/locks", rm.RepoReadPerm(), r.ListLocks) + repov1.POST("/:namespace/:name/locks", rm.RepoWritePerm(), r.CreateLock) + repov1.DELETE("/:namespace/:name/locks/:lockID", rm.RepoWritePerm(), r.DeleteLock) + repov1.GET("/:namespace/:name/perms", rm.RepoReadPerm(), r.ListPerms) + repov1.GET("/:namespace/:name/config", rm.RepoReadPerm(), r.GetConfig) } usersv1 := v1.Group("/users") diff --git a/openapi.yml b/openapi.yml index 360c3b18..bbaf5af2 100644 --- a/openapi.yml +++ b/openapi.yml @@ -73,18 +73,22 @@ paths: $ref: '#/components/responses/402PaymentRequired' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}: + /repos/{namespace}/{name}: get: tags: - Repo summary: Get the repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string responses: '200': description: Repository @@ -134,18 +138,22 @@ paths: $ref: '#/components/responses/403Forbidden' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/commits: + /repos/{namespace}/{name}/commits: get: tags: - Repo summary: List commits of repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: query name: branch schema: @@ -181,18 +189,22 @@ paths: $ref: '#/components/responses/403Forbidden' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/commits/{sha}: + /repos/{namespace}/{name}/commits/{sha}: get: tags: - Repo summary: Get the commit of repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: sha required: true @@ -216,18 +228,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/commits/{sha}/statuses: + /repos/{namespace}/{name}/commits/{sha}/statuses: get: tags: - Repo summary: List statuses of the commit. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: sha required: true @@ -256,18 +272,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/branches: + /repos/{namespace}/{name}/branches: get: tags: - Repo summary: List branches of the repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: query name: page schema: @@ -295,18 +315,22 @@ paths: $ref: '#/components/responses/403Forbidden' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/branches/{branch}: + /repos/{namespace}/{name}/branches/{branch}: get: tags: - Repo summary: Get the branch of repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: branch required: true @@ -330,18 +354,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/tags: + /repos/{namespace}/{name}/tags: get: tags: - Repo summary: List tags of the repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: query name: page schema: @@ -369,18 +397,22 @@ paths: $ref: '#/components/responses/403Forbidden' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/tags/{tag}: + /repos/{namespace}/{name}/tags/{tag}: get: tags: - Repo summary: Get the tag of the repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: tag required: true @@ -404,18 +436,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments: + /repos/{namespace}/{name}/deployments: get: tags: - Repo summary: List deployments of repository. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: query name: env description: Name for the target deployment environment. @@ -502,18 +538,22 @@ paths: description: The deployment payload or the configuration is invalid. '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments/{number}: + /repos/{namespace}/{name}/deployments/{number}: get: tags: - Repo summary: Get the deployments by the number. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: number required: true @@ -588,7 +628,7 @@ paths: description: The configuration is invalid or it is not approved. '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments/{number}/changes: + /repos/{namespace}/{name}/deployments/{number}/changes: get: tags: - Repo @@ -598,11 +638,15 @@ paths: it compares with the previous succeed deployment. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: number required: true @@ -636,18 +680,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments/{number}/rollback: + /repos/{namespace}/{name}/deployments/{number}/rollback: post: tags: - Repo summary: Rollback by the deployment. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: number required: true @@ -676,18 +724,22 @@ paths: $ref: '#/components/responses/422UnprocessableEntity' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments/{number}/approvals: + /repos/{namespace}/{name}/deployments/{number}/approvals: get: tags: - Repo summary: List approvals for the deployment. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: number required: true @@ -755,18 +807,22 @@ paths: $ref: '#/components/responses/422UnprocessableEntity' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/deployments/{number}/approval: + /repos/{namespace}/{name}/deployments/{number}/approval: get: tags: - Repo summary: Get the approval of user for the deployment. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: number required: true @@ -838,18 +894,22 @@ paths: $ref: '#/components/responses/500InternalError' # Only permitted users can access to Approval API. # To be under repository protects to access without permissions. - /repos/{id}/approvals/{aid}: + /repos/{namespace}/{name}/approvals/{aid}: get: tags: - Repo summary: Get the approval. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id. + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: aid required: true @@ -909,18 +969,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/locks: + /repos/{namespace}/{name}/locks: get: tags: - Repo summary: List locked environments. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id. + type: string + - in: path + name: name + required: true + schema: + type: string responses: '200': description: Locks @@ -973,18 +1037,22 @@ paths: $ref: '#/components/responses/422UnprocessableEntity' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/locks/{lockId}: + /repos/{namespace}/{name}/locks/{lockId}: delete: tags: - Repo summary: Unlock the environment. parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id. + type: string + - in: path + name: name + required: true + schema: + type: string - in: path name: lockId required: true @@ -1008,18 +1076,22 @@ paths: $ref: '#/components/responses/404NotFound' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/perms: + /repos/{namespace}/{name}/perms: get: tags: - Repo summary: Get permissions for the repository parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id. + type: string + - in: path + name: name + required: true + schema: + type: string - in: query name: q schema: @@ -1048,18 +1120,22 @@ paths: $ref: '#/components/responses/403Forbidden' '500': $ref: '#/components/responses/500InternalError' - /repos/{id}/config: + /repos/{namespace}/{name}/config: get: tags: - Repo summary: Get the config file parameters: - in: path - name: id + name: namespace required: true schema: - type: integer - description: The repository id + type: string + - in: path + name: name + required: true + schema: + type: string responses: '200': description: Config