@@ -11,8 +11,8 @@ import (
11
11
// APIHandler is an interface for encoding, decoding, and implenting contexual api functions for different API implementations.
12
12
// It encapsulates behavior for encoding and decoding requests and responses.
13
13
type APIHandler interface {
14
- ConstructAPIResourceEndpoint (instanceName string , endpointPath string , log logger.Logger ) string
15
- ConstructAPIAuthEndpoint (instanceName string , endpointPath string , log logger.Logger ) string
14
+ ConstructAPIResourceEndpoint (APIResourceEndpointIdentifier string , endpointPath string , log logger.Logger ) string
15
+ ConstructAPIAuthEndpoint (APIAuthEndpointIdentifier string , endpointPath string , log logger.Logger ) string
16
16
MarshalRequest (body interface {}, method string , endpoint string , log logger.Logger ) ([]byte , error )
17
17
MarshalMultipartRequest (fields map [string ]string , files map [string ]string , log logger.Logger ) ([]byte , string , error )
18
18
GetContentTypeHeader (method string , log logger.Logger ) string
@@ -29,23 +29,24 @@ type APIHandler interface {
29
29
GetAPIRequestHeaders (endpoint string ) map [string ]string // Provides standard headers required for making API requests.
30
30
}
31
31
32
- // LoadAPIHandler returns an APIHandler based on the provided API type.
33
- // 'apiType' parameter could be "jamf" or "graph" to specify which API handler to load.
34
- func LoadAPIHandler (apiType string , log logger.Logger ) (APIHandler , error ) {
32
+ // Modify the function signature to accept instanceName, tenantID, and tenantName.
33
+ func LoadAPIHandler (apiType , instanceName , tenantID , tenantName string , log logger.Logger ) (APIHandler , error ) {
35
34
var apiHandler APIHandler
36
35
switch apiType {
37
36
case "jamfpro" :
38
37
apiHandler = & jamfpro.JamfAPIHandler {
39
- Logger : log ,
40
- // Initialize with necessary parameters
38
+ Logger : log ,
39
+ InstanceName : instanceName , // Assuming you add InstanceName field to JamfAPIHandler
41
40
}
42
- log .Info ("API handler loaded successfully" , zap .String ("APIType" , apiType ))
41
+ log .Info ("Jamf Pro API handler loaded successfully" , zap .String ("APIType" , apiType ), zap . String ( "InstanceName" , instanceName ))
43
42
44
43
case "msgraph" :
45
44
apiHandler = & msgraph.GraphAPIHandler {
46
- // Initialize with necessary parameters
45
+ Logger : log ,
46
+ TenantID : tenantID , // Assuming you add TenantID field to GraphAPIHandler
47
+ TenantName : tenantName , // Assuming you add TenantName field to GraphAPIHandler
47
48
}
48
- log .Info ("API handler loaded successfully" , zap .String ("APIType" , apiType ))
49
+ log .Info ("Microsoft Graph API handler loaded successfully" , zap .String ("APIType" , apiType ), zap . String ( "TenantID" , tenantID ), zap . String ( "TenantName" , tenantName ))
49
50
50
51
default :
51
52
return nil , log .Error ("Unsupported API type" , zap .String ("APIType" , apiType ))
0 commit comments