Refactoring
This commit is contained in:
28
pkg/cloudapi/locations/get_url.go
Normal file
28
pkg/cloudapi/locations/get_url.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package locations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
func (l Locations) GetUrl(ctx context.Context, options ...opts.DecortOpts) (string, error) {
|
||||
url := "/locations/getUrl"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
if option != nil {
|
||||
if option.IsAdmin {
|
||||
prefix = "/" + option.AdminValue
|
||||
}
|
||||
}
|
||||
url = prefix + url
|
||||
res, err := l.client.DecortApiCall(ctx, typed.POST, url, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
Reference in New Issue
Block a user