mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Update sdk
This commit is contained in:
		
				
					committed by
					
						 Kim "BKC" Carlbäcker
						Kim "BKC" Carlbäcker
					
				
			
			
				
	
			
			
			
						parent
						
							9847b38518
						
					
				
				
					commit
					8de8ec027d
				
			
							
								
								
									
										51
									
								
								vendor/code.gitea.io/sdk/gitea/repo_hook.go → vendor/code.gitea.io/sdk/gitea/hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								vendor/code.gitea.io/sdk/gitea/repo_hook.go → vendor/code.gitea.io/sdk/gitea/hook.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,12 +30,30 @@ type Hook struct { | ||||
| 	Created time.Time         `json:"created_at"` | ||||
| } | ||||
| 
 | ||||
| // ListOrgHooks list all the hooks of one organization | ||||
| func (c *Client) ListOrgHooks(org string) ([]*Hook, error) { | ||||
| 	hooks := make([]*Hook, 0, 10) | ||||
| 	return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks) | ||||
| } | ||||
| 
 | ||||
| // ListRepoHooks list all the hooks of one repository | ||||
| func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error) { | ||||
| 	hooks := make([]*Hook, 0, 10) | ||||
| 	return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) | ||||
| } | ||||
| 
 | ||||
| // GetOrgHook get a hook of an organization | ||||
| func (c *Client) GetOrgHook(org string, id int64) (*Hook, error) { | ||||
| 	h := new(Hook) | ||||
| 	return h, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil, h) | ||||
| } | ||||
| 
 | ||||
| // GetRepoHook get a hook of a repository | ||||
| func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) { | ||||
| 	h := new(Hook) | ||||
| 	return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil, h) | ||||
| } | ||||
| 
 | ||||
| // CreateHookOption options when create a hook | ||||
| type CreateHookOption struct { | ||||
| 	Type   string            `json:"type" binding:"Required"` | ||||
| @@ -44,7 +62,17 @@ type CreateHookOption struct { | ||||
| 	Active bool              `json:"active"` | ||||
| } | ||||
| 
 | ||||
| // CreateRepoHook create one hook with options | ||||
| // CreateOrgHook create one hook for an organization, with options | ||||
| func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error) { | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	h := new(Hook) | ||||
| 	return h, c.getParsedResponse("POST", fmt.Sprintf("/orgs/%s/hooks", org), jsonHeader, bytes.NewReader(body), h) | ||||
| } | ||||
| 
 | ||||
| // CreateRepoHook create one hook for a repository, with options | ||||
| func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error) { | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| @@ -61,7 +89,17 @@ type EditHookOption struct { | ||||
| 	Active *bool             `json:"active"` | ||||
| } | ||||
| 
 | ||||
| // EditRepoHook modify one hook with hook id and options | ||||
| // EditOrgHook modify one hook of an organization, with hook id and options | ||||
| func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error { | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	_, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), jsonHeader, bytes.NewReader(body)) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| // EditRepoHook modify one hook of a repository, with hook id and options | ||||
| func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error { | ||||
| 	body, err := json.Marshal(&opt) | ||||
| 	if err != nil { | ||||
| @@ -71,7 +109,14 @@ func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) e | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| // DeleteRepoHook delete one hook with hook id | ||||
| // DeleteOrgHook delete one hook from an organization, with hook id | ||||
| func (c *Client) DeleteOrgHook(org string, id int64) error { | ||||
| 	_, err := c.getResponse("DELETE", fmt.Sprintf("/org/%s/hooks/%d", org, id), nil, nil) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // DeleteRepoHook delete one hook from a repository, with hook id | ||||
| func (c *Client) DeleteRepoHook(user, repo string, id int64) error { | ||||
| 	_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil) | ||||
| 	return err | ||||
							
								
								
									
										31
									
								
								vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								vendor/code.gitea.io/sdk/gitea/repo_collaborator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -10,6 +10,29 @@ import ( | ||||
| 	"fmt" | ||||
| ) | ||||
|  | ||||
| // ListCollaborators list a repository's collaborators | ||||
| func (c *Client) ListCollaborators(user, repo string) ([]*User, error) { | ||||
| 	collaborators := make([]*User, 0, 10) | ||||
| 	err := c.getParsedResponse("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), | ||||
| 		nil, nil, &collaborators) | ||||
| 	return collaborators, err | ||||
| } | ||||
|  | ||||
| // IsCollaborator check if a user is a collaborator of a repository | ||||
| func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) { | ||||
| 	status, err := c.getStatusCode("GET", | ||||
| 		fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), | ||||
| 		nil, nil) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	if status == 204 { | ||||
| 		return true, nil | ||||
| 	} | ||||
| 	return false, nil | ||||
| } | ||||
|  | ||||
| // AddCollaboratorOption options when add some user as a collaborator of a repository | ||||
| type AddCollaboratorOption struct { | ||||
| 	Permission *string `json:"permission"` | ||||
| @@ -24,3 +47,11 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo | ||||
| 	_, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body)) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // DeleteCollaborator remove a collaborator from a repository | ||||
| func (c *Client) DeleteCollaborator(user, repo, collaborator string) error { | ||||
| 	_, err := c.getResponse("DELETE", | ||||
| 		fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), | ||||
| 		nil, nil) | ||||
| 	return err | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user