Skip to content

Commit 9edadb1

Browse files
authored
Merge pull request #58 from deploymenttheory/dev
Dev
2 parents 60eed37 + e9272d2 commit 9edadb1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

apihandlers/jamfpro/jamfpro_api_url.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ func (j *JamfAPIHandler) SetBaseDomain() string {
2121
func (j *JamfAPIHandler) ConstructAPIResourceEndpoint(instanceName string, endpointPath string, log logger.Logger) string {
2222
urlBaseDomain := j.SetBaseDomain()
2323
url := fmt.Sprintf("https://%s%s%s", instanceName, urlBaseDomain, endpointPath)
24-
j.Logger.Info(fmt.Sprintf("Constructed %s API resource endpoint URL", APIName), zap.String("URL", url))
24+
j.Logger.Debug(fmt.Sprintf("Constructed %s API resource endpoint URL", APIName), zap.String("URL", url))
2525
return url
2626
}
2727

2828
// ConstructAPIAuthEndpoint constructs the full URL for a Jamf API auth endpoint path and logs the URL.
2929
func (j *JamfAPIHandler) ConstructAPIAuthEndpoint(instanceName string, endpointPath string, log logger.Logger) string {
3030
urlBaseDomain := j.SetBaseDomain()
3131
url := fmt.Sprintf("https://%s%s%s", instanceName, urlBaseDomain, endpointPath)
32-
j.Logger.Info(fmt.Sprintf("Constructed %s API authentication URL", APIName), zap.String("URL", url))
32+
j.Logger.Debug(fmt.Sprintf("Constructed %s API authentication URL", APIName), zap.String("URL", url))
3333
return url
3434
}

errors/http_error_handling.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func HandleAPIError(resp *http.Response, log logger.Logger) error {
5454
if err != nil || errMsg == "" {
5555
errMsg = fmt.Sprintf("Unexpected error with status code: %d", resp.StatusCode)
5656
// Logging with structured fields
57-
log.Warn("Failed to decode API error message, using default error message",
57+
log.Error("Failed to decode API error message, using default error message",
5858
zap.String("status", resp.Status),
5959
zap.String("error_message", errMsg),
6060
)
@@ -163,6 +163,10 @@ func IsNonRetryableStatusCode(resp *http.Response) bool {
163163

164164
// IsRateLimitError checks if the provided response indicates a rate limit error.
165165
func IsRateLimitError(resp *http.Response) bool {
166+
if resp == nil {
167+
// If the response is nil, it cannot be a rate limit error.
168+
return false
169+
}
166170
return resp.StatusCode == http.StatusTooManyRequests
167171
}
168172

httpclient/httpclient_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (c *Client) executeHTTPRequest(req *http.Request, log logger.Logger, method
330330
}
331331

332332
// Log the response status code for successful requests
333-
log.Info("Request sent successfully",
333+
log.Debug("Request sent successfully",
334334
zap.String("method", method),
335335
zap.String("endpoint", endpoint),
336336
zap.Int("status_code", resp.StatusCode),

0 commit comments

Comments
 (0)