-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource compute_script: expose deployment_key and release attributes
- Loading branch information
1 parent
890cb2d
commit f03ccc0
Showing
5 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) BunnyWay d.o.o. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
) | ||
|
||
type ComputeScriptRelease struct { | ||
Id int64 `json:"Id,omitempty"` | ||
Uuid string `json:"Uuid"` | ||
Note string `json:"Note"` | ||
Code string `json:"Code"` | ||
} | ||
|
||
var ErrComputeScriptReleaseNotFound = errors.New("compute script release not found") | ||
|
||
func (c *Client) GetComputeScriptActiveRelease(scriptId int64) (ComputeScriptRelease, error) { | ||
var response ComputeScriptRelease | ||
|
||
resp, err := c.doRequest(http.MethodGet, fmt.Sprintf("%s/compute/script/%d/releases/active", c.apiUrl, scriptId), nil) | ||
if err != nil { | ||
return response, err | ||
} | ||
|
||
if resp.StatusCode == http.StatusNotFound { | ||
return response, ErrComputeScriptReleaseNotFound | ||
} | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return response, errors.New(resp.Status) | ||
} | ||
|
||
bodyResp, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return response, err | ||
} | ||
|
||
_ = resp.Body.Close() | ||
err = json.Unmarshal(bodyResp, &response) | ||
return response, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters