Skip to content

Commit

Permalink
Set User-Agent for tools and godep pacakge
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jul 12, 2022
1 parent 15326f3 commit 50ea4e3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion godep/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
depclient "github.com/micromdm/nanodep/client"
)

const mediaType = "application/json;charset=UTF8"
const (
mediaType = "application/json;charset=UTF8"
userAgent = "nanodep-godep/0"
)

// HTTPError encapsulates an HTTP response error from the DEP requests.
// The API returns error information in the request body.
Expand Down Expand Up @@ -103,6 +106,7 @@ func (c *Client) do(ctx context.Context, name, method, path string, in interface
if err != nil {
return err
}
req.Header.Set("User-Agent", userAgent)
if body != nil {
req.Header.Set("Content-Type", mediaType)
}
Expand Down
1 change: 1 addition & 0 deletions tools/dep-account-detail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ URL="${BASE_URL}/proxy/${DEP_NAME}${DEP_ENDPOINT}"
curl \
$CURL_OPTS \
-u depserver:$APIKEY \
-A "nanodep-tools/0" \
"$URL"

1 change: 1 addition & 0 deletions tools/dep-define-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ curl \
-X POST \
-H 'Content-type: application/json;charset=UTF8' \
-T "$1" \
-A "nanodep-tools/0" \
"$URL"
1 change: 1 addition & 0 deletions tools/dep-device-details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jq -n --arg device "$1" '.devices = [$device]' \
-X POST \
-H 'Content-type: application/json;charset=UTF8' \
--data-binary @- \
-A "nanodep-tools/0" \
"$URL"
1 change: 1 addition & 0 deletions tools/dep-get-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ URL="${BASE_URL}/proxy/${DEP_NAME}${DEP_ENDPOINT}?profile_uuid=$1"
curl \
$CURL_OPTS \
-u "depserver:$APIKEY" \
-A "nanodep-tools/0" \
"$URL"
1 change: 1 addition & 0 deletions tools/dep-remove-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ jq -n --arg device "$1" '.devices = [$device]' \
-X DELETE \
-H 'Content-type: application/json;charset=UTF8' \
--data-binary @- \
-A "nanodep-tools/0" \
"$URL"

0 comments on commit 50ea4e3

Please sign in to comment.