Add 7 missing SDK methods and fix README type name
- Fix AgentKeyRequest → RegisterAgentKeyInput in README - Add ListAgents, UnfreezeAgent, DeleteAgent to agents.go - Add GetMe, IssueApiToken to auth.go - Add DownloadExport to exports.go - Add Health package-level function in health.go - Add corresponding types and document all exports in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fdedb7247
commit
c21e9fcfc6
6 files changed
+245
-3
No files matched your search
+50
-1
@@ -1,6 +1,11 @@
|
||||
package elydora
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CreateExport creates a new compliance export job.
|
||||
func (c *Client) CreateExport(params *CreateExportRequest) (*CreateExportResponse, error) {
|
||||
@@ -28,3 +33,47 @@ func (c *Client) GetExport(exportID string) (*GetExportResponse, error) {
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// DownloadExport downloads the raw file data for a completed export.
|
||||
func (c *Client) DownloadExport(exportID string) ([]byte, error) {
|
||||
u := c.baseURL + fmt.Sprintf("/v1/exports/%s/download", exportID)
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, u, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("elydora: create request: %w", err)
|
||||
}
|
||||
if c.token != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+c.token)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("elydora: http request: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("elydora: read response body: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
var errResp errorResponse
|
||||
if jsonErr := json.Unmarshal(body, &errResp); jsonErr == nil && errResp.Error.Code != "" {
|
||||
return nil, &ElydoraError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Code: errResp.Error.Code,
|
||||
Message: errResp.Error.Message,
|
||||
RequestID: errResp.Error.RequestID,
|
||||
Details: errResp.Error.Details,
|
||||
}
|
||||
}
|
||||
return nil, &ElydoraError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Code: ErrorCodeInternalError,
|
||||
Message: string(body),
|
||||
}
|
||||
}
|
||||
|
||||
return body, nil
|
||||
}
|
||||
Reference in new issue
Block a user