161 lines
4.5 KiB
Go
161 lines
4.5 KiB
Go
|
/*
|
||
|
* oc-catalog API
|
||
|
*
|
||
|
* Backend of the oc-search project
|
||
|
*
|
||
|
* API version: 1.0.0
|
||
|
* Contact: opencloud@irt-saintexupery.com
|
||
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||
|
*/
|
||
|
|
||
|
package swagger
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"io/ioutil"
|
||
|
"net/http"
|
||
|
"net/url"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// Linger please
|
||
|
var (
|
||
|
_ context.Context
|
||
|
)
|
||
|
|
||
|
type UserApiService service
|
||
|
|
||
|
/*
|
||
|
UserApiService
|
||
|
Logs user into the system
|
||
|
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
- @param username The username for login
|
||
|
- @param password The password for login
|
||
|
*/
|
||
|
func (a *UserApiService) UserControllerLogin(ctx context.Context, username string, password string) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/user/login"
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
localVarQueryParams.Add("username", parameterToString(username, ""))
|
||
|
localVarQueryParams.Add("password", parameterToString(password, ""))
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
UserApiService
|
||
|
Logs out current logged in user session
|
||
|
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
*/
|
||
|
func (a *UserApiService) UserControllerLogout(ctx context.Context) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/user/logout"
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|