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 <appleboy.tw@gmail.com>

block by https://github.com/go-gitea/gitea/pull/26485

Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/629
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2023-08-15 15:15:48 +00:00 committed by John Olheiser
parent ae1583a7be
commit 091528835f
2 changed files with 43 additions and 0 deletions

29
gitea/org_action.go Normal file
View file

@ -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
}

14
gitea/secret.go Normal file
View file

@ -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"`
}