func (h *Hoverfly) SetRequestTemplates(path string) (responseTemplates *matching.RequestTemplateResponsePairPayload, err error) { conf, err := ioutil.ReadFile(path) if err != nil { return nil, err } url := h.buildURL("/api/templates") slingRequest := sling.New().Post(url).Body(strings.NewReader(string(conf))) _, err = h.performAPIRequest(slingRequest) if err != nil { return nil, err } slingRequest = sling.New().Get(url).Body(strings.NewReader(string(conf))) getResponse, err := h.performAPIRequest(slingRequest) if err != nil { return nil, err } requestTemplates, err := unmarshalRequestTemplates(getResponse) if err != nil { return nil, err } return requestTemplates, nil }
// Set will go the state endpoint in Hoverfly, sending JSON that will set the mode of Hoverfly func (h *Hoverfly) SetDelays(path string) (rd []ResponseDelaySchema, err error) { conf, err := ioutil.ReadFile(path) if err != nil { return rd, err } url := h.buildURL("/api/delays") slingRequest := sling.New().Put(url).Body(strings.NewReader(string(conf))) slingRequest, err = h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not authenticate with Hoverfly") } request, err := slingRequest.Request() if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } response, err := h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } slingRequest = sling.New().Get(url).Body(strings.NewReader(string(conf))) slingRequest, err = h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not authenticate with Hoverfly") } request, err = slingRequest.Request() if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } response, err = h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } apiResponse := createAPIDelaysResponse(response) return apiResponse.Data, nil }
func (h *Hoverfly) ImportSimulation(simulationData string) error { url := h.buildURL("/api/records") slingRequest := sling.New().Post(url).Body(strings.NewReader(simulationData)) slingRequest, err := h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return errors.New("Could not authenticate with Hoverfly") } request, err := slingRequest.Request() if err != nil { log.Debug(err.Error()) return errors.New("Could not communicate with Hoverfly") } response, err := h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return errors.New("Could not communicate with Hoverfly") } if response.StatusCode == 401 { return errors.New("Hoverfly requires authentication") } if response.StatusCode != 200 { return errors.New("Import to Hoverfly failed") } return nil }
// GetMiddle will go the middleware endpoint in Hoverfly, parse the JSON response and return the middleware of Hoverfly func (h *Hoverfly) GetMiddleware() (string, error) { url := h.buildURL("/api/middleware") slingRequest := sling.New().Get(url) slingRequest, err := h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return "", errors.New("Could not authenticate with Hoverfly") } request, err := slingRequest.Request() if err != nil { log.Debug(err.Error()) return "", errors.New("Could not communicate with Hoverfly") } response, err := h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return "", errors.New("Could not communicate with Hoverfly") } if response.StatusCode == 401 { return "", errors.New("Hoverfly requires authentication") } defer response.Body.Close() middlewareResponse := h.createMiddlewareSchema(response) return middlewareResponse.Middleware, nil }
//func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) { func (a PetApi) UpdatePetWithForm(petId int64, name string, status string) error { _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/pet/{petId}" path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } // accept header accepts := []string{"application/xml", "application/json"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } type FormParams struct { name string `url:"name,omitempty"` status string `url:"status,omitempty"` } _sling = _sling.BodyForm(&FormParams{name: name, status: status}) // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) if failurePayload != nil { // If the failurePayload is present, there likely was some kind of non-2xx status // returned (and a JSON payload error present) var str []byte str, err = json.Marshal(failurePayload) if err == nil { // For safety, check for an error marshalling... probably superfluous // This will return the JSON error body as a string err = errors.New(string(str)) } } else { // So, there was no network-type error, and nothing in the failure payload, // but we should still check the status code if httpResponse == nil { // This should never happen... err = errors.New("No HTTP Response received.") } else if code := httpResponse.StatusCode; 200 > code || code > 299 { err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) } } } return err }
func newClient(httpClient *http.Client) *client { base := sling.New().Client(httpClient).Base(facebookAPI) return &client{ c: httpClient, sling: base, } }
/** * Returns pet inventories by status * Returns a map of status codes to quantities * @return map[string]int32 */ func (a StoreApi) GetInventory() (map[string]int32, error) { _sling := sling.New().Get(a.Configuration.BasePath) // authentication (api_key) required // set key with prefix in header _sling.Set("api_key", a.Configuration.GetApiKeyWithPrefix("api_key")) // create path and map variables path := "/v2/store/inventory" _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } // accept header accepts := []string{"application/json"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } var successPayload = new(map[string]int32) // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) if failurePayload != nil { // If the failurePayload is present, there likely was some kind of non-2xx status // returned (and a JSON payload error present) var str []byte str, err = json.Marshal(failurePayload) if err == nil { // For safety, check for an error marshalling... probably superfluous // This will return the JSON error body as a string err = errors.New(string(str)) } } else { // So, there was no network-type error, and nothing in the failure payload, // but we should still check the status code if httpResponse == nil { // This should never happen... err = errors.New("No HTTP Response received.") } else if code := httpResponse.StatusCode; 200 > code || code > 299 { err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) } } } return *successPayload, err }
// GetMode will go the state endpoint in Hoverfly, parse the JSON response and return the mode of Hoverfly func (h *Hoverfly) GetDelays() (rd []ResponseDelaySchema, err error) { url := h.buildURL("/api/delays") slingRequest := sling.New().Get(url) slingRequest, err = h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not authenticate with Hoverfly") } request, err := slingRequest.Request() if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } response, err := h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return rd, errors.New("Could not communicate with Hoverfly") } defer response.Body.Close() apiResponse := createAPIDelaysResponse(response) return apiResponse.Data, nil }
/** * Logs user into the system * * @param username The user name for login * @param password The password for login in clear text * @return string */ func (a UserApi) LoginUser(username string, password string) (string, error) { _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/user/login" _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } type QueryParams struct { Username string `url:"username,omitempty"` Password string `url:"password,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{Username: username, Password: password}) // accept header accepts := []string{"application/xml", "application/json"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } var successPayload = new(string) // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) if failurePayload != nil { // If the failurePayload is present, there likely was some kind of non-2xx status // returned (and a JSON payload error present) var str []byte str, err = json.Marshal(failurePayload) if err == nil { // For safety, check for an error marshalling... probably superfluous // This will return the JSON error body as a string err = errors.New(string(str)) } } else { // So, there was no network-type error, and nothing in the failure payload, // but we should still check the status code if httpResponse == nil { // This should never happen... err = errors.New("No HTTP Response received.") } else if code := httpResponse.StatusCode; 200 > code || code > 299 { err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) } } } return *successPayload, err }
func (s *SpectoLab) GetSimulation(simulation Simulation, overrideHost string) ([]byte, error) { var url string if len(overrideHost) > 0 { url = s.buildURL(fmt.Sprintf("/api/v1/users/%v/simulations/%v/versions/%v/data?override-host=%v", simulation.Vendor, simulation.Name, simulation.Version, overrideHost)) } else { url = s.buildURL(fmt.Sprintf("/api/v1/users/%v/simulations/%v/versions/%v/data", simulation.Vendor, simulation.Name, simulation.Version)) } request, err := sling.New().Get(url).Add("Authorization", s.buildAuthorizationHeaderValue()).Add("Content-Type", "application/json").Request() if err != nil { log.Debug(err.Error()) return nil, errors.New("Could not create a request to SpectoLab") } response, err := http.DefaultClient.Do(request) if err != nil { log.Debug(err.Error()) return nil, errors.New("Could not communicate with SpectoLab") } defer response.Body.Close() if response.StatusCode != 200 { return nil, errors.New("Simulation not found in SpectoLab") } body, err := ioutil.ReadAll(response.Body) if err != nil { log.Debug(err.Error()) return nil, errors.New("Could not pull simulation from SpectoLab") } return body, nil }
func UserGet(userId int) (user User, err error) { params := &UserGetParams{UserIds: strconv.Itoa(userId), Version: apiVersion, Fields: "photo_100,status"} response := new(UserGetResponse) _, err = sling.New().Get(path + "users.get").QueryStruct(params).ReceiveSuccess(response) user = response.Users[0] return }
func (s *SpectoLab) UploadSimulation(simulation Simulation, data []byte) (bool, error) { err := s.CreateSimulation(simulation) if err != nil { log.Debug(err) return false, errors.New("Unable to create a simulation on SpectoLab") } url := s.buildURL(fmt.Sprintf("/api/v1/users/%v/simulations/%v/versions/%v/data", simulation.Vendor, simulation.Name, simulation.Version)) request, err := sling.New().Put(url).Add("Authorization", s.buildAuthorizationHeaderValue()).Add("Content-Type", "application/json").Body(strings.NewReader(string(data))).Request() if err != nil { log.Debug(err) return false, errors.New("Could not create a request to check API key against SpectoLab") } response, err := http.DefaultClient.Do(request) if err != nil { log.Debug(err) return false, errors.New("Could not communicate with SpectoLab") } defer response.Body.Close() return response.StatusCode >= 200 && response.StatusCode <= 299, nil }
//Create a new project. //Implementation Notes //This endpoint is for user to create a new project. //@param project New created project. //@return void //func (a HarborAPI) ProjectsPost (prjUsr UsrInfo, project Project) (int, error) { func (a HarborAPI) ProjectsPost(prjUsr UsrInfo, project Project) (int, error) { _sling := sling.New().Post(a.basePath) // create path and map variables path := "/api/projects" _sling = _sling.Path(path) // accept header accepts := []string{"application/json", "text/plain"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } // body params _sling = _sling.BodyJSON(project) req, err := _sling.Request() req.SetBasicAuth(prjUsr.Name, prjUsr.Passwd) client := &http.Client{} httpResponse, err := client.Do(req) defer httpResponse.Body.Close() return httpResponse.StatusCode, err }
//Search for projects and repositories //Implementation Notes //The Search endpoint returns information about the projects and repositories //offered at public status or related to the current logged in user. //The response includes the project and repository list in a proper display order. //@param q Search parameter for project and repository name. //@return []Search func (a testapi) SearchGet(q string, authInfo ...usrInfo) (int, apilib.Search, error) { var httpCode int var body []byte var err error _sling := sling.New().Get(a.basePath) // create path and map variables path := "/api/search" _sling = _sling.Path(path) type QueryParams struct { Query string `url:"q,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{Query: q}) if len(authInfo) > 0 { httpCode, body, err = request(_sling, jsonAcceptHeader, authInfo[0]) } else { httpCode, body, err = request(_sling, jsonAcceptHeader) } var successPayload = new(apilib.Search) err = json.Unmarshal(body, &successPayload) return httpCode, *successPayload, err }
func (h *Hoverfly) generateAuthToken() (string, error) { credentials := HoverflyAuthSchema{ Username: h.Username, Password: h.Password, } jsonCredentials, err := json.Marshal(credentials) if err != nil { return "", err } request, err := sling.New().Post(h.buildURL("/api/token-auth")).Body(strings.NewReader(string(jsonCredentials))).Request() if err != nil { return "", err } response, err := h.httpClient.Do(request) if err != nil { return "", err } body, err := ioutil.ReadAll(response.Body) if err != nil { return "", err } var authToken HoverflyAuthTokenSchema err = json.Unmarshal(body, &authToken) if err != nil { return "", err } return authToken.Token, nil }
//func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) { func (a PetApi) FindPetsByStatus(Status []string) ([]Pet, error) { _sling := sling.New().Get(a.basePath) // create path and map variables path := "/v2/pet/findByStatus" _sling = _sling.Path(path) type QueryParams struct { Status []string `url:"status,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{Status: Status}) // accept header accepts := []string{"application/json", "application/xml"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } response := new([]Pet) _, err := _sling.ReceiveSuccess(response) //fmt.Println("FindPetsByStatus response: ", response, resp, err) return *response, err }
//func (a UserApi) LoginUser (Username string, Password string) (string, error) { func (a UserApi) LoginUser(Username string, Password string) (string, error) { _sling := sling.New().Get(a.basePath) // create path and map variables path := "/v2/user/login" _sling = _sling.Path(path) type QueryParams struct { Username string `url:"username,omitempty"` Password string `url:"password,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{Username: Username, Password: Password}) // accept header accepts := []string{"application/json", "application/xml"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } response := new(string) _, err := _sling.ReceiveSuccess(response) //fmt.Println("LoginUser response: ", response, resp, err) return *response, err }
//func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) { func (a PetApi) UpdatePetWithForm(PetId string, Name string, Status string) error { _sling := sling.New().Post(a.basePath) // create path and map variables path := "/v2/pet/{petId}" path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", PetId), -1) _sling = _sling.Path(path) // accept header accepts := []string{"application/json", "application/xml"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } type FormParams struct { Name string `url:"name,omitempty"` Status string `url:"status,omitempty"` } _sling = _sling.BodyForm(&FormParams{Name: Name, Status: Status}) _, err := _sling.ReceiveSuccess(nil) //fmt.Println("UpdatePetWithForm response: void, ", resp, err) return err }
//func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) { func (a PetApi) UploadFile(PetId int64, AdditionalMetadata string, File *os.File) error { _sling := sling.New().Post(a.basePath) // create path and map variables path := "/v2/pet/{petId}/uploadImage" path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", PetId), -1) _sling = _sling.Path(path) // accept header accepts := []string{"application/json", "application/xml"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } type FormParams struct { AdditionalMetadata string `url:"additionalMetadata,omitempty"` File *os.File `url:"file,omitempty"` } _sling = _sling.BodyForm(&FormParams{AdditionalMetadata: AdditionalMetadata, File: File}) _, err := _sling.ReceiveSuccess(nil) //fmt.Println("UploadFile response: void, ", resp, err) return err }
// Wipe will call the records endpoint in Hoverfly with a DELETE request, triggering Hoverfly to wipe the database func (h *Hoverfly) DeleteSimulations() error { url := h.buildURL("/api/records") slingRequest := sling.New().Delete(url) slingRequest, err := h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return errors.New("Could not authenticate with Hoverfly") } request, err := slingRequest.Request() if err != nil { log.Debug(err.Error()) return errors.New("Could not communicate with Hoverfly") } response, err := h.httpClient.Do(request) if err != nil { log.Debug(err.Error()) return errors.New("Could not communicate with Hoverfly") } defer response.Body.Close() if response.StatusCode == 401 { return errors.New("Hoverfly requires authentication") } if response.StatusCode != 200 { return errors.New("Simulations were not deleted from Hoverfly") } return nil }
func (c *Client) start() error { c.startOnce.Do(func() { // Setup sling url := fmt.Sprintf("https://api.keen.io/3.0/projects/%s/", c.ProjectId) c.sling = sling.New().Client(c.HttpClient).Base(url).Set("Authorization", c.APIKey) pendingWorkCapacity := c.PendingWorkCapacity if pendingWorkCapacity == 0 { pendingWorkCapacity = defaultPendingWorkCapacity } maxBatchSize := c.MaxBatchSize if maxBatchSize == 0 { maxBatchSize = defaultMaxBatchSize } batchTimeout := c.BatchTimeout if int64(batchTimeout) == 0 { batchTimeout = defaultBatchTimeout } c.muster.BatchMaker = func() muster.Batch { return &musterBatch{Client: c} } c.muster.BatchTimeout = batchTimeout c.muster.MaxBatchSize = maxBatchSize c.muster.PendingWorkCapacity = pendingWorkCapacity c.startErr = c.muster.Start() }) return c.startErr }
func (h *Hoverfly) ImportSimulation(simulationData string, v1 bool) error { slingRequest := sling.New().Body(strings.NewReader(simulationData)) if v1 { slingRequest = slingRequest.Post(h.buildURL(v1ApiSimulation)) } else { slingRequest = slingRequest.Put(h.buildURL(v2ApiSimulation)) } slingRequest, err := h.addAuthIfNeeded(slingRequest) if err != nil { log.Debug(err.Error()) return errors.New("Could not authenticate with Hoverfly") } response, err := h.doRequest(slingRequest) if err != nil { return err } if response.StatusCode != 200 { body, _ := ioutil.ReadAll(response.Body) var errorView ErrorSchema json.Unmarshal(body, &errorView) return errors.New("Import to Hoverfly failed: " + errorView.ErrorMessage) } return nil }
//Search projects by projectName and isPublic func (a testapi) ProjectsGet(projectName string, isPublic int32, authInfo ...usrInfo) (int, []apilib.Project, error) { _sling := sling.New().Get(a.basePath) //create api path path := "api/projects" _sling = _sling.Path(path) type QueryParams struct { ProjectName string `url:"project_name,omitempty"` IsPubilc int32 `url:"is_public,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{ProjectName: projectName, IsPubilc: isPublic}) var successPayload []apilib.Project var httpStatusCode int var err error var body []byte if len(authInfo) > 0 { httpStatusCode, body, err = request(_sling, jsonAcceptHeader, authInfo[0]) } else { httpStatusCode, body, err = request(_sling, jsonAcceptHeader) } if err == nil && httpStatusCode == 200 { err = json.Unmarshal(body, &successPayload) } return httpStatusCode, successPayload, err }
//Delete a repository or a tag in a repository. //Delete a repository or a tag in a repository. //This endpoint let user delete repositories and tags with repo name and tag.\n //@param repoName The name of repository which will be deleted. //@param tag Tag of a repository. //@return void //func (a HarborAPI) RepositoriesDelete(prjUsr UsrInfo, repoName string, tag string) (int, error) { func (a HarborAPI) RepositoriesDelete(prjUsr UsrInfo, repoName string, tag string) (int, error) { _sling := sling.New().Delete(a.basePath) // create path and map variables path := "/api/repositories" _sling = _sling.Path(path) type QueryParams struct { RepoName string `url:"repo_name,omitempty"` Tag string `url:"tag,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{RepoName: repoName, Tag: tag}) // accept header accepts := []string{"application/json", "text/plain"} for key := range accepts { _sling = _sling.Set("Accept", accepts[key]) break // only use the first Accept } req, err := _sling.Request() req.SetBasicAuth(prjUsr.Name, prjUsr.Passwd) //fmt.Printf("request %+v", req) client := &http.Client{} httpResponse, err := client.Do(req) defer httpResponse.Body.Close() if err != nil { // handle error } return httpResponse.StatusCode, err }
func GroupGet(groupId int) (group Community, err error) { params := &GroupGetParams{GroupIds: strconv.Itoa(groupId), Version: apiVersion, Fields: "photo_100,description"} response := new(GroupGetResponse) _, err = sling.New().Get(path + "groups.getById").QueryStruct(params).ReceiveSuccess(response) group = response.Groups[0] return }
func wallGet(params *WallGetParams) (posts []Post, users []User, groups []Community, err error) { response := new(WallGetExtendedResponse) _, err = sling.New().Get(path + "wall.get").QueryStruct(params).ReceiveSuccess(response) posts = response.Response.Posts users = response.Response.Profiles groups = response.Response.Groups return }
//Mark a registered user as be removed. func (a testapi) UsersDelete(userID int, authInfo usrInfo) (int, error) { _sling := sling.New().Delete(a.basePath) // create path and map variables path := "/api/users/" + fmt.Sprintf("%d", userID) _sling = _sling.Path(path) httpStatusCode, _, err := request(_sling, jsonAcceptHeader, authInfo) return httpStatusCode, err }
func ResolveScreenName(name string) (objectType string, id int, err error) { params := &ResolveScreenNameParams{Version: apiVersion, ScreenName: name} response := new(ResolveScreenNameResponse) _, err = sling.New().Get(path + "utils.resolveScreenName").QueryStruct(params).ReceiveSuccess(response) objectType = response.Response.Type id = response.Response.ObjectId return }
//Delete project role member accompany with projectID func (a testapi) DeleteProjectMember(authInfo usrInfo, projectID string, userID string) (int, error) { _sling := sling.New().Delete(a.basePath) path := "/api/projects/" + projectID + "/members/" + userID _sling = _sling.Path(path) httpStatusCode, _, err := request(_sling, jsonAcceptHeader, authInfo) return httpStatusCode, err }
//Delete project by projectID func (a testapi) ProjectsDelete(prjUsr usrInfo, projectID string) (int, error) { _sling := sling.New().Delete(a.basePath) //create api path path := "api/projects/" + projectID _sling = _sling.Path(path) httpStatusCode, _, err := request(_sling, jsonAcceptHeader, prjUsr) return httpStatusCode, err }