Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apiintegrations/apihandler/apihandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ func LoadAPIHandler(apiType, instanceName, tenantID, tenantName string, log logg
case "jamfpro":
apiHandler = &jamfpro.JamfAPIHandler{
Logger: log,
InstanceName: instanceName, // Used for constructing the resource and auth endpoints
InstanceName: instanceName, // Used for constructing both jamf pro resource and auth endpoints
}
log.Info("Jamf Pro API handler loaded successfully", zap.String("APIType", apiType), zap.String("InstanceName", instanceName))

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

Expand Down
2 changes: 2 additions & 0 deletions apiintegrations/jamfpro/jamfpro_api_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (j *JamfAPIHandler) SetBaseDomain() string {
}

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

// ConstructAPIAuthEndpoint constructs the full URL for a Jamf API auth endpoint path and logs the URL.
// It uses the instance name to construct the full URL.
func (j *JamfAPIHandler) ConstructAPIAuthEndpoint(endpointPath string, log logger.Logger) string {
urlBaseDomain := j.SetBaseDomain()
url := fmt.Sprintf("https://%s%s%s", j.InstanceName, urlBaseDomain, endpointPath)
Expand Down
8 changes: 4 additions & 4 deletions apiintegrations/msgraph/msgraph_api_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import (
"go.uber.org/zap"
)

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

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

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