add apt gestion
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
274ea454dd
commit
c4776d81dd
22 changed files with 1465 additions and 163 deletions
|
|
@ -25,20 +25,26 @@ func New(baseURL string) *Client {
|
|||
}
|
||||
|
||||
type CreateRepoInput struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
SourceURL string `json:"source_url"`
|
||||
SyncMode string `json:"sync_mode,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
SourceURL string `json:"source_url"`
|
||||
SyncMode string `json:"sync_mode,omitempty"`
|
||||
AptSuite string `json:"apt_suite,omitempty"`
|
||||
AptComponents []string `json:"apt_components,omitempty"`
|
||||
AptArchitectures []string `json:"apt_architectures,omitempty"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
SourceURL string `json:"source_url"`
|
||||
Frozen bool `json:"frozen"`
|
||||
SyncMode string `json:"sync_mode"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
SourceURL string `json:"source_url"`
|
||||
Frozen bool `json:"frozen"`
|
||||
SyncMode string `json:"sync_mode"`
|
||||
AptSuite string `json:"apt_suite,omitempty"`
|
||||
AptComponents []string `json:"apt_components,omitempty"`
|
||||
AptArchitectures []string `json:"apt_architectures,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type listReposResponse struct {
|
||||
|
|
@ -84,6 +90,29 @@ func (c *Client) GetRepo(ctx context.Context, id int64) (*Repo, error) {
|
|||
return &repo, nil
|
||||
}
|
||||
|
||||
type UpdateRepoInput struct {
|
||||
SourceURL *string `json:"source_url,omitempty"`
|
||||
SyncMode *string `json:"sync_mode,omitempty"`
|
||||
AptSuite *string `json:"apt_suite,omitempty"`
|
||||
AptComponents []string `json:"apt_components,omitempty"`
|
||||
AptArchitectures []string `json:"apt_architectures,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Client) UpdateRepo(ctx context.Context, id int64, in UpdateRepoInput) (*Repo, error) {
|
||||
body, _ := json.Marshal(in)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch,
|
||||
fmt.Sprintf("%s/api/v1/repos/%d", c.baseURL, id), bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
var repo Repo
|
||||
if err := c.do(req, &repo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &repo, nil
|
||||
}
|
||||
|
||||
func (c *Client) DeleteRepo(ctx context.Context, id int64) error {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, fmt.Sprintf("%s/api/v1/repos/%d", c.baseURL, id), nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue