2020-10-13 11:17:37 -04:00
/ *
* 3 DS OUTSCALE API
*
* Welcome to the 3 DS OUTSCALE ' s API documentation . < br / > < br / > The 3 DS OUTSCALE API enables you to manage your resources in the 3 DS OUTSCALE Cloud . This documentation describes the different actions available along with code examples . < br / > < br / > Note that the 3 DS OUTSCALE Cloud is compatible with Amazon Web Services ( AWS ) APIs , but some resources have different names in AWS than in the 3 DS OUTSCALE API . You can find a list of the differences [ here ] ( https : //wiki.outscale.net/display/EN/3DS+OUTSCALE+APIs+Reference).<br /><br /> You can also manage your resources using the [Cockpit](https://wiki.outscale.net/display/EN/About+Cockpit) web interface.
*
2021-04-20 11:18:45 -04:00
* API version : 1.8
2020-10-13 11:17:37 -04:00
* Contact : support @ outscale . com
* Generated by : OpenAPI Generator ( https : //openapi-generator.tech)
* /
package osc
import (
_context "context"
2021-04-20 11:18:45 -04:00
"github.com/antihax/optional"
2020-10-13 11:17:37 -04:00
_ioutil "io/ioutil"
_nethttp "net/http"
_neturl "net/url"
)
// Linger please
var (
_ _context . Context
)
// InternetServiceApiService InternetServiceApi service
type InternetServiceApiService service
// CreateInternetServiceOpts Optional parameters for the method 'CreateInternetService'
type CreateInternetServiceOpts struct {
2021-04-20 11:18:45 -04:00
CreateInternetServiceRequest optional . Interface
2020-10-13 11:17:37 -04:00
}
/ *
CreateInternetService Method for CreateInternetService
* @ param ctx _context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
* @ param optional nil or * CreateInternetServiceOpts - Optional Parameters :
2021-04-20 11:18:45 -04:00
* @ param "CreateInternetServiceRequest" ( optional . Interface of CreateInternetServiceRequest ) -
2020-10-13 11:17:37 -04:00
@ return CreateInternetServiceResponse
* /
func ( a * InternetServiceApiService ) CreateInternetService ( ctx _context . Context , localVarOptionals * CreateInternetServiceOpts ) ( CreateInternetServiceResponse , * _nethttp . Response , error ) {
var (
localVarHTTPMethod = _nethttp . MethodPost
localVarPostBody interface { }
localVarFormFileName string
localVarFileName string
localVarFileBytes [ ] byte
localVarReturnValue CreateInternetServiceResponse
)
// create path and map variables
localVarPath := a . client . cfg . BasePath + "/CreateInternetService"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := _neturl . Values { }
localVarFormParams := _neturl . Values { }
// to determine the Content-Type header
localVarHTTPContentTypes := [ ] string { "application/json" }
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType ( localVarHTTPContentTypes )
if localVarHTTPContentType != "" {
localVarHeaderParams [ "Content-Type" ] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
if localVarOptionals != nil && localVarOptionals . CreateInternetServiceRequest . IsSet ( ) {
localVarOptionalCreateInternetServiceRequest , localVarOptionalCreateInternetServiceRequestok := localVarOptionals . CreateInternetServiceRequest . Value ( ) . ( CreateInternetServiceRequest )
if ! localVarOptionalCreateInternetServiceRequestok {
return localVarReturnValue , nil , reportError ( "createInternetServiceRequest should be CreateInternetServiceRequest" )
}
localVarPostBody = & localVarOptionalCreateInternetServiceRequest
}
if ctx != nil {
// API Key Authentication
if auth , ok := ctx . Value ( ContextAPIKey ) . ( APIKey ) ; ok {
var key string
if auth . Prefix != "" {
key = auth . Prefix + " " + auth . Key
} else {
key = auth . Key
}
localVarHeaderParams [ "Authorization" ] = key
}
}
r , err := a . client . prepareRequest ( ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , localVarFormFileName , localVarFileName , localVarFileBytes )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( r )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := _ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
if localVarHTTPResponse . StatusCode == 200 {
var v CreateInternetServiceResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 400 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 401 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 500 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}
// DeleteInternetServiceOpts Optional parameters for the method 'DeleteInternetService'
type DeleteInternetServiceOpts struct {
2021-04-20 11:18:45 -04:00
DeleteInternetServiceRequest optional . Interface
2020-10-13 11:17:37 -04:00
}
/ *
DeleteInternetService Method for DeleteInternetService
* @ param ctx _context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
* @ param optional nil or * DeleteInternetServiceOpts - Optional Parameters :
2021-04-20 11:18:45 -04:00
* @ param "DeleteInternetServiceRequest" ( optional . Interface of DeleteInternetServiceRequest ) -
2020-10-13 11:17:37 -04:00
@ return DeleteInternetServiceResponse
* /
func ( a * InternetServiceApiService ) DeleteInternetService ( ctx _context . Context , localVarOptionals * DeleteInternetServiceOpts ) ( DeleteInternetServiceResponse , * _nethttp . Response , error ) {
var (
localVarHTTPMethod = _nethttp . MethodPost
localVarPostBody interface { }
localVarFormFileName string
localVarFileName string
localVarFileBytes [ ] byte
localVarReturnValue DeleteInternetServiceResponse
)
// create path and map variables
localVarPath := a . client . cfg . BasePath + "/DeleteInternetService"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := _neturl . Values { }
localVarFormParams := _neturl . Values { }
// to determine the Content-Type header
localVarHTTPContentTypes := [ ] string { "application/json" }
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType ( localVarHTTPContentTypes )
if localVarHTTPContentType != "" {
localVarHeaderParams [ "Content-Type" ] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
if localVarOptionals != nil && localVarOptionals . DeleteInternetServiceRequest . IsSet ( ) {
localVarOptionalDeleteInternetServiceRequest , localVarOptionalDeleteInternetServiceRequestok := localVarOptionals . DeleteInternetServiceRequest . Value ( ) . ( DeleteInternetServiceRequest )
if ! localVarOptionalDeleteInternetServiceRequestok {
return localVarReturnValue , nil , reportError ( "deleteInternetServiceRequest should be DeleteInternetServiceRequest" )
}
localVarPostBody = & localVarOptionalDeleteInternetServiceRequest
}
if ctx != nil {
// API Key Authentication
if auth , ok := ctx . Value ( ContextAPIKey ) . ( APIKey ) ; ok {
var key string
if auth . Prefix != "" {
key = auth . Prefix + " " + auth . Key
} else {
key = auth . Key
}
localVarHeaderParams [ "Authorization" ] = key
}
}
r , err := a . client . prepareRequest ( ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , localVarFormFileName , localVarFileName , localVarFileBytes )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( r )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := _ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
if localVarHTTPResponse . StatusCode == 200 {
var v DeleteInternetServiceResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 400 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 401 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 500 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}
// LinkInternetServiceOpts Optional parameters for the method 'LinkInternetService'
type LinkInternetServiceOpts struct {
2021-04-20 11:18:45 -04:00
LinkInternetServiceRequest optional . Interface
2020-10-13 11:17:37 -04:00
}
/ *
LinkInternetService Method for LinkInternetService
* @ param ctx _context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
* @ param optional nil or * LinkInternetServiceOpts - Optional Parameters :
2021-04-20 11:18:45 -04:00
* @ param "LinkInternetServiceRequest" ( optional . Interface of LinkInternetServiceRequest ) -
2020-10-13 11:17:37 -04:00
@ return LinkInternetServiceResponse
* /
func ( a * InternetServiceApiService ) LinkInternetService ( ctx _context . Context , localVarOptionals * LinkInternetServiceOpts ) ( LinkInternetServiceResponse , * _nethttp . Response , error ) {
var (
localVarHTTPMethod = _nethttp . MethodPost
localVarPostBody interface { }
localVarFormFileName string
localVarFileName string
localVarFileBytes [ ] byte
localVarReturnValue LinkInternetServiceResponse
)
// create path and map variables
localVarPath := a . client . cfg . BasePath + "/LinkInternetService"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := _neturl . Values { }
localVarFormParams := _neturl . Values { }
// to determine the Content-Type header
localVarHTTPContentTypes := [ ] string { "application/json" }
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType ( localVarHTTPContentTypes )
if localVarHTTPContentType != "" {
localVarHeaderParams [ "Content-Type" ] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
if localVarOptionals != nil && localVarOptionals . LinkInternetServiceRequest . IsSet ( ) {
localVarOptionalLinkInternetServiceRequest , localVarOptionalLinkInternetServiceRequestok := localVarOptionals . LinkInternetServiceRequest . Value ( ) . ( LinkInternetServiceRequest )
if ! localVarOptionalLinkInternetServiceRequestok {
return localVarReturnValue , nil , reportError ( "linkInternetServiceRequest should be LinkInternetServiceRequest" )
}
localVarPostBody = & localVarOptionalLinkInternetServiceRequest
}
if ctx != nil {
// API Key Authentication
if auth , ok := ctx . Value ( ContextAPIKey ) . ( APIKey ) ; ok {
var key string
if auth . Prefix != "" {
key = auth . Prefix + " " + auth . Key
} else {
key = auth . Key
}
localVarHeaderParams [ "Authorization" ] = key
}
}
r , err := a . client . prepareRequest ( ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , localVarFormFileName , localVarFileName , localVarFileBytes )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( r )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := _ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
if localVarHTTPResponse . StatusCode == 200 {
var v LinkInternetServiceResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 400 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 401 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 500 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}
// ReadInternetServicesOpts Optional parameters for the method 'ReadInternetServices'
type ReadInternetServicesOpts struct {
2021-04-20 11:18:45 -04:00
ReadInternetServicesRequest optional . Interface
2020-10-13 11:17:37 -04:00
}
/ *
ReadInternetServices Method for ReadInternetServices
* @ param ctx _context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
* @ param optional nil or * ReadInternetServicesOpts - Optional Parameters :
2021-04-20 11:18:45 -04:00
* @ param "ReadInternetServicesRequest" ( optional . Interface of ReadInternetServicesRequest ) -
2020-10-13 11:17:37 -04:00
@ return ReadInternetServicesResponse
* /
func ( a * InternetServiceApiService ) ReadInternetServices ( ctx _context . Context , localVarOptionals * ReadInternetServicesOpts ) ( ReadInternetServicesResponse , * _nethttp . Response , error ) {
var (
localVarHTTPMethod = _nethttp . MethodPost
localVarPostBody interface { }
localVarFormFileName string
localVarFileName string
localVarFileBytes [ ] byte
localVarReturnValue ReadInternetServicesResponse
)
// create path and map variables
localVarPath := a . client . cfg . BasePath + "/ReadInternetServices"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := _neturl . Values { }
localVarFormParams := _neturl . Values { }
// to determine the Content-Type header
localVarHTTPContentTypes := [ ] string { "application/json" }
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType ( localVarHTTPContentTypes )
if localVarHTTPContentType != "" {
localVarHeaderParams [ "Content-Type" ] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
if localVarOptionals != nil && localVarOptionals . ReadInternetServicesRequest . IsSet ( ) {
localVarOptionalReadInternetServicesRequest , localVarOptionalReadInternetServicesRequestok := localVarOptionals . ReadInternetServicesRequest . Value ( ) . ( ReadInternetServicesRequest )
if ! localVarOptionalReadInternetServicesRequestok {
return localVarReturnValue , nil , reportError ( "readInternetServicesRequest should be ReadInternetServicesRequest" )
}
localVarPostBody = & localVarOptionalReadInternetServicesRequest
}
if ctx != nil {
// API Key Authentication
if auth , ok := ctx . Value ( ContextAPIKey ) . ( APIKey ) ; ok {
var key string
if auth . Prefix != "" {
key = auth . Prefix + " " + auth . Key
} else {
key = auth . Key
}
localVarHeaderParams [ "Authorization" ] = key
}
}
r , err := a . client . prepareRequest ( ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , localVarFormFileName , localVarFileName , localVarFileBytes )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( r )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := _ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
if localVarHTTPResponse . StatusCode == 200 {
var v ReadInternetServicesResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 400 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 401 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 500 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}
// UnlinkInternetServiceOpts Optional parameters for the method 'UnlinkInternetService'
type UnlinkInternetServiceOpts struct {
2021-04-20 11:18:45 -04:00
UnlinkInternetServiceRequest optional . Interface
2020-10-13 11:17:37 -04:00
}
/ *
UnlinkInternetService Method for UnlinkInternetService
* @ param ctx _context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
* @ param optional nil or * UnlinkInternetServiceOpts - Optional Parameters :
2021-04-20 11:18:45 -04:00
* @ param "UnlinkInternetServiceRequest" ( optional . Interface of UnlinkInternetServiceRequest ) -
2020-10-13 11:17:37 -04:00
@ return UnlinkInternetServiceResponse
* /
func ( a * InternetServiceApiService ) UnlinkInternetService ( ctx _context . Context , localVarOptionals * UnlinkInternetServiceOpts ) ( UnlinkInternetServiceResponse , * _nethttp . Response , error ) {
var (
localVarHTTPMethod = _nethttp . MethodPost
localVarPostBody interface { }
localVarFormFileName string
localVarFileName string
localVarFileBytes [ ] byte
localVarReturnValue UnlinkInternetServiceResponse
)
// create path and map variables
localVarPath := a . client . cfg . BasePath + "/UnlinkInternetService"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := _neturl . Values { }
localVarFormParams := _neturl . Values { }
// to determine the Content-Type header
localVarHTTPContentTypes := [ ] string { "application/json" }
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType ( localVarHTTPContentTypes )
if localVarHTTPContentType != "" {
localVarHeaderParams [ "Content-Type" ] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
if localVarOptionals != nil && localVarOptionals . UnlinkInternetServiceRequest . IsSet ( ) {
localVarOptionalUnlinkInternetServiceRequest , localVarOptionalUnlinkInternetServiceRequestok := localVarOptionals . UnlinkInternetServiceRequest . Value ( ) . ( UnlinkInternetServiceRequest )
if ! localVarOptionalUnlinkInternetServiceRequestok {
return localVarReturnValue , nil , reportError ( "unlinkInternetServiceRequest should be UnlinkInternetServiceRequest" )
}
localVarPostBody = & localVarOptionalUnlinkInternetServiceRequest
}
if ctx != nil {
// API Key Authentication
if auth , ok := ctx . Value ( ContextAPIKey ) . ( APIKey ) ; ok {
var key string
if auth . Prefix != "" {
key = auth . Prefix + " " + auth . Key
} else {
key = auth . Key
}
localVarHeaderParams [ "Authorization" ] = key
}
}
r , err := a . client . prepareRequest ( ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , localVarFormFileName , localVarFileName , localVarFileBytes )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( r )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := _ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
if localVarHTTPResponse . StatusCode == 200 {
var v UnlinkInternetServiceResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 400 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 401 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
return localVarReturnValue , localVarHTTPResponse , newErr
}
if localVarHTTPResponse . StatusCode == 500 {
var v ErrorResponse
err = a . client . decode ( & v , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr . error = err . Error ( )
return localVarReturnValue , localVarHTTPResponse , newErr
}
newErr . model = v
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}