diff --git a/README.md b/README.md index 5f792e90..07155525 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To effectively use the `go-api-sdk-jamfpro` SDK, you'll need to set up and confi ### 1. Setting Constants -At the start of your main program, define some constants that will be used to configure the client: +At the start of your main program, you can optionally define define some constants that will be used to configure the client for http client. If you don't set any then defaults from `shared_api_client.go` will be used. ```go const ( @@ -67,13 +67,10 @@ With the OAuth credentials loaded, you can now configure the HTTP client: config := http_client.Config{ DebugMode: true, Logger: http_client.NewDefaultLogger(), - MaxConcurrentRequests: maxConcurrentRequestsAllowed, - TokenLifespan: defaultTokenLifespan, - TokenRefreshBufferPeriod: defaultBufferPeriod, } ``` -Here, the DebugMode is set to true, which means the client will print debug information. The Logger uses the SDK's default logger. The other fields are set using the constants we defined earlier. +Here, the DebugMode is set to true, which means the client will print debug information. The Logger uses the SDK's default logger. 4. Initializing the Jamf Pro Client Once the HTTP client is configured, initialize the Jamf Pro client: diff --git a/sdk/jamfpro/classicapi_computer_groups.go b/sdk/jamfpro/classicapi_computer_groups.go index 51754f1e..4a086966 100644 --- a/sdk/jamfpro/classicapi_computer_groups.go +++ b/sdk/jamfpro/classicapi_computer_groups.go @@ -11,12 +11,12 @@ import ( const uriComputerGroups = "/JSSResource/computergroups" -type ComputerGroupsResponse struct { - Size int `xml:"size"` - Results []ComputerGroupListResponse `xml:"computer_group"` +type ComputerGroupsListResponse struct { + Size int `xml:"size"` + Results []ComputerGroupListItem `xml:"computer_group"` } -type ComputerGroupListResponse struct { +type ComputerGroupListItem struct { ID int `xml:"id,omitempty"` Name string `xml:"name,omitempty"` IsSmart bool `xml:"is_smart,omitempty"` @@ -65,10 +65,10 @@ const ( ) // GetComputerGroups gets a list of all computer groups -func (c *Client) GetComputerGroups() (*ComputerGroupsResponse, error) { +func (c *Client) GetComputerGroups() (*ComputerGroupsListResponse, error) { endpoint := uriComputerGroups - var computerGroups ComputerGroupsResponse + var computerGroups ComputerGroupsListResponse resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &computerGroups) if err != nil { return nil, fmt.Errorf("failed to fetch all Computer Groups: %v", err) diff --git a/sdk/jamfpro/shared_api_client.go b/sdk/jamfpro/shared_api_client.go index d17a3148..34e48074 100644 --- a/sdk/jamfpro/shared_api_client.go +++ b/sdk/jamfpro/shared_api_client.go @@ -18,10 +18,9 @@ import ( ) const ( - concurrentRequests = 10 // Number of simultaneous requests. - maxConcurrentRequestsAllowed = 5 // Maximum allowed concurrent requests. - defaultTokenLifespan = 30 * time.Minute - defaultBufferPeriod = 5 * time.Minute + maxConcurrentRequestsAllowed = 5 // Maximum allowed concurrent requests. + defaultTokenLifespan = 30 * time.Minute // Set default token lifespan + defaultTokenBufferPeriod = 5 * time.Minute // Set default token buffer period before attempting a token refresh ) type Client struct { @@ -49,7 +48,7 @@ func NewClient(config Config) (*Client, error) { config.TokenLifespan = defaultTokenLifespan } if config.TokenRefreshBufferPeriod == 0 { - config.TokenRefreshBufferPeriod = defaultBufferPeriod + config.TokenRefreshBufferPeriod = defaultTokenBufferPeriod } // Initialise http client httpConfig := http_client.Config{