Skip to content

Commit de9439f

Browse files
committed
Refactor ConstructAPIResourceEndpoint and ConstructAPIAuthEndpoint functions in APIHandler implementations to remove instanceName parameter
1 parent d555fb4 commit de9439f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

apiintegrations/apihandler/apihandler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ func LoadAPIHandler(apiType, instanceName, tenantID, tenantName string, log logg
3636
case "jamfpro":
3737
apiHandler = &jamfpro.JamfAPIHandler{
3838
Logger: log,
39-
InstanceName: instanceName, // Used for constructing the resource and auth endpoints
39+
InstanceName: instanceName, // Used for constructing both jamf pro resource and auth endpoints
4040
}
4141
log.Info("Jamf Pro API handler loaded successfully", zap.String("APIType", apiType), zap.String("InstanceName", instanceName))
4242

4343
case "msgraph":
4444
apiHandler = &msgraph.GraphAPIHandler{
4545
Logger: log,
46-
TenantID: tenantID, // Used for constructing the auth endpoint
46+
TenantID: tenantID, // Used for constructing the graph auth endpoint
4747
}
4848
log.Info("Microsoft Graph API handler loaded successfully", zap.String("APIType", apiType), zap.String("TenantID", tenantID), zap.String("TenantName", tenantName))
4949

apiintegrations/jamfpro/jamfpro_api_url.go

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func (j *JamfAPIHandler) SetBaseDomain() string {
1818
}
1919

2020
// ConstructAPIResourceEndpoint constructs the full URL for a Jamf API resource endpoint path and logs the URL.
21+
// It uses the instance name to construct the full URL.
2122
func (j *JamfAPIHandler) ConstructAPIResourceEndpoint(endpointPath string, log logger.Logger) string {
2223
urlBaseDomain := j.SetBaseDomain()
2324
url := fmt.Sprintf("https://%s%s%s", j.InstanceName, urlBaseDomain, endpointPath)
@@ -26,6 +27,7 @@ func (j *JamfAPIHandler) ConstructAPIResourceEndpoint(endpointPath string, log l
2627
}
2728

2829
// ConstructAPIAuthEndpoint constructs the full URL for a Jamf API auth endpoint path and logs the URL.
30+
// It uses the instance name to construct the full URL.
2931
func (j *JamfAPIHandler) ConstructAPIAuthEndpoint(endpointPath string, log logger.Logger) string {
3032
urlBaseDomain := j.SetBaseDomain()
3133
url := fmt.Sprintf("https://%s%s%s", j.InstanceName, urlBaseDomain, endpointPath)

apiintegrations/msgraph/msgraph_api_url.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import (
88
"go.uber.org/zap"
99
)
1010

11-
// SetBaseDomain returns the appropriate base domain for URL construction.
12-
// It uses j.OverrideBaseDomain if set, otherwise falls back to DefaultBaseDomain.
11+
// SetBaseDomain returns the appropriate base domain for URL construction. It uses DefaultBaseDomain constant.
1312
func (g *GraphAPIHandler) SetBaseDomain() string {
1413
return DefaultBaseDomain
1514
}
1615

1716
// ConstructAPIResourceEndpoint constructs the full URL for a graph API resource endpoint path and logs the URL.
17+
// It uses the base domain to construct the full URL.
1818
func (g *GraphAPIHandler) ConstructAPIResourceEndpoint(endpointPath string, log logger.Logger) string {
1919
urlBaseDomain := g.SetBaseDomain()
20-
url := fmt.Sprintf("https://%s%s%s", g.TenantName, urlBaseDomain, endpointPath)
20+
url := fmt.Sprintf("https://%s%s", urlBaseDomain, endpointPath)
2121
g.Logger.Debug(fmt.Sprintf("Constructed %s API resource endpoint URL", APIName), zap.String("URL", url))
2222
return url
2323
}
2424

2525
// ConstructAPIAuthEndpoint constructs the full URL for the Microsoft Graph API authentication endpoint.
26-
// It uses the provided tenant ID and endpoint path and logs the constructed URL.
26+
// It uses the tenant ID to construct the full URL.
2727
func (g *GraphAPIHandler) ConstructAPIAuthEndpoint(endpointPath string, log logger.Logger) string {
2828
// The base URL for the Microsoft Graph API authentication endpoint.
2929
const baseURL = "https://login.microsoftonline.com"

0 commit comments

Comments
 (0)