From 091528835fc2b7947cdc51cc9fdea94d56994825 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 15 Aug 2023 15:15:48 +0000 Subject: [PATCH] feat: Add API routes to list org secrets (#629) - Add a new file `gitea/org_action.go` - Add a new file `gitea/secret.go` Signed-off-by: Bo-Yi Wu block by https://github.com/go-gitea/gitea/pull/26485 Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/629 Reviewed-by: Lunny Xiao Reviewed-by: John Olheiser Co-authored-by: Bo-Yi Wu Co-committed-by: Bo-Yi Wu --- gitea/org_action.go | 29 +++++++++++++++++++++++++++++ gitea/secret.go | 14 ++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 gitea/org_action.go create mode 100644 gitea/secret.go diff --git a/gitea/org_action.go b/gitea/org_action.go new file mode 100644 index 0000000..a1dec28 --- /dev/null +++ b/gitea/org_action.go @@ -0,0 +1,29 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import ( + "fmt" + "net/url" +) + +// ListOrgMembershipOption list OrgMembership options +type ListOrgActionSecretOption struct { + ListOptions +} + +// ListOrgMembership list an organization's members +func (c *Client) ListOrgActionSecret(org string, opt ListOrgActionSecretOption) ([]*Secret, *Response, error) { + if err := escapeValidatePathSegments(&org); err != nil { + return nil, nil, err + } + opt.setDefaults() + secrets := make([]*Secret, 0, opt.PageSize) + + link, _ := url.Parse(fmt.Sprintf("/orgs/%s/actions/secrets", org)) + link.RawQuery = opt.getURLQuery().Encode() + resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &secrets) + return secrets, resp, err +} diff --git a/gitea/secret.go b/gitea/secret.go new file mode 100644 index 0000000..0f544a8 --- /dev/null +++ b/gitea/secret.go @@ -0,0 +1,14 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import "time" + +type Secret struct { + // the secret's name + Name string `json:"name"` + // Date and Time of secret creation + Created time.Time `json:"created_at"` +}