You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// LoadUserConfig allows users to apply their own configuration by providing a JSON file.
97
-
// The custom configuration will override the default settings previously loaded.
98
-
// It reads the file from the provided filename path and unmarshals its content into the configMap.
99
-
// If reading or unmarshalling fails, an error is returned.
100
-
funcLoadUserConfig(filenamestring) error {
101
-
// Read the user-provided JSON configuration file and unmarshal it into the global configMap.
102
-
userConfigBytes, err:=os.ReadFile(filename)
103
-
iferr!=nil {
104
-
returnerr
105
-
}
106
-
// Override the default configuration with the user's custom settings.
107
-
returnjson.Unmarshal(userConfigBytes, &configMap)
108
-
}
109
-
110
-
// Structs
111
-
112
98
// EndpointConfig is a struct that holds configuration details for a specific API endpoint.
113
99
// It includes what type of content it can accept and what content type it should send.
114
100
typeEndpointConfigstruct {
115
101
Acceptstring`json:"accept"`// Accept specifies the MIME type the endpoint can handle in responses.
116
102
ContentType*string`json:"content_type"`// ContentType, if not nil, specifies the MIME type to set for requests sent to the endpoint. A pointer is used to distinguish between a missing field and an empty string.
117
103
}
118
104
119
-
// UnifiedAPIHandler is a struct that implements the APIHandler interface.
120
-
// It holds a Logger instance to facilitate logging across various API handling methods.
121
-
// This handler is responsible for encoding and decoding request and response data,
122
-
// determining content types, and other API interactions as defined by the APIHandler interface.
105
+
// JamfAPIHandler implements the APIHandler interface for the Jamf Pro API.
123
106
typeJamfAPIHandlerstruct {
124
-
loggerLogger// logger is used to output logs for the API handling processes.
107
+
logger httpclient.Logger// logger is used to output logs for the API handling processes.
108
+
OverrideBaseDomainstring// OverrideBaseDomain is used to override the base domain for URL construction.
109
+
InstanceNamestring// InstanceName is the name of the Jamf instance.
125
110
}
126
111
127
112
// Functions
128
113
129
114
// GetBaseDomain returns the appropriate base domain for URL construction.
130
115
// It uses OverrideBaseDomain if set, otherwise falls back to DefaultBaseDomain.
131
-
func (c*Client) GetBaseDomain() string {
132
-
ifc.OverrideBaseDomain!="" {
133
-
returnc.OverrideBaseDomain
116
+
func (j*JamfAPIHandler) GetBaseDomain() string {
117
+
ifj.OverrideBaseDomain!="" {
118
+
returnj.OverrideBaseDomain
134
119
}
135
120
returnDefaultBaseDomain
136
121
}
137
122
138
123
// ConstructAPIResourceEndpoint returns the full URL for a Jamf API resource endpoint path.
0 commit comments