MF-1833 - Fix spelling of bootstrap on SDK (#1834)

* fix order of parameters and add url checks

Signed-off-by: SammyOina <sammyoina@gmail.com>

* fix spelling in sdk

Signed-off-by: SammyOina <sammyoina@gmail.com>

* wrap jaeger url parsing error

Signed-off-by: SammyOina <sammyoina@gmail.com>

* remove jaeger

Signed-off-by: SammyOina <sammyoina@gmail.com>

* remove empty lines

Signed-off-by: SammyOina <sammyoina@gmail.com>

---------

Signed-off-by: SammyOina <sammyoina@gmail.com>
This commit is contained in:
Sammy Kerata Oina 2023-07-13 13:52:39 +03:00 committed by GitHub
parent f7ba1557cf
commit 52131eba66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -66,20 +66,20 @@ func (sdk mfSDK) AddBootstrap(cfg BootstrapConfig, token string) (string, errors
return id, nil
}
func (sdk mfSDK) Bootstraps(pm PageMetadata, token string) (BoostrapsPage, errors.SDKError) {
func (sdk mfSDK) Bootstraps(pm PageMetadata, token string) (BootstrapPage, errors.SDKError) {
url, err := sdk.withQueryParams(sdk.bootstrapURL, configsEndpoint, pm)
if err != nil {
return BoostrapsPage{}, errors.NewSDKError(err)
return BootstrapPage{}, errors.NewSDKError(err)
}
_, body, sdkerr := sdk.processRequest(http.MethodGet, url, token, string(CTJSON), nil, http.StatusOK)
if sdkerr != nil {
return BoostrapsPage{}, sdkerr
return BootstrapPage{}, sdkerr
}
var bb BoostrapsPage
var bb BootstrapPage
if err = json.Unmarshal(body, &bb); err != nil {
return BoostrapsPage{}, errors.NewSDKError(err)
return BootstrapPage{}, errors.NewSDKError(err)
}
return bb, nil
@ -143,7 +143,6 @@ func (sdk mfSDK) UpdateBootstrapCerts(id, clientCert, clientKey, ca, token strin
}
_, _, sdkerr := sdk.processRequest(http.MethodPatch, url, token, string(CTJSON), data, http.StatusOK)
return sdkerr
}
@ -158,14 +157,12 @@ func (sdk mfSDK) UpdateBootstrapConnection(id string, channels []string, token s
}
_, _, sdkerr := sdk.processRequest(http.MethodPut, url, token, string(CTJSON), data, http.StatusOK)
return sdkerr
}
func (sdk mfSDK) RemoveBootstrap(id, token string) errors.SDKError {
url := fmt.Sprintf("%s/%s/%s", sdk.bootstrapURL, configsEndpoint, id)
_, _, err := sdk.processRequest(http.MethodDelete, url, token, string(CTJSON), nil, http.StatusNoContent)
return err
}

View File

@ -75,7 +75,7 @@ type revokeCertsRes struct {
}
// BoostrapsPage contains list of boostrap configs in a page with proper metadata.
type BoostrapsPage struct {
type BootstrapPage struct {
Configs []BootstrapConfig `json:"configs"`
pageRes
}

View File

@ -830,7 +830,7 @@ type SDK interface {
// }
// bootstraps, _ := sdk.Bootstraps(pm, "token")
// fmt.Println(bootstraps)
Bootstraps(pm PageMetadata, token string) (BoostrapsPage, errors.SDKError)
Bootstraps(pm PageMetadata, token string) (BootstrapPage, errors.SDKError)
// Whitelist updates Thing state Config with given ID belonging to the user identified by the given token.
//