ecloudsdkcore

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const SdkPortalGatewayUrl = "/api/query/openapi/apim/request/sdk"
View Source
const SdkPortalUrl = "/op-apim-portal/apim/request/sdk"

Variables

This section is empty.

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient manages communication In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient() *APIClient

NewAPIClient creates a new API client.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath Change base path to allow switching to mocks

func (*APIClient) Excute

func (c *APIClient) Excute(httpRequest *HttpRequest, config *config.Config, returnType interface{}) (*http.Response, error)

Excute entry for http call

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

type APIPlatformResponse

type APIPlatformResponse struct {
	RequestId    string      `json:"requestId,omitempty"`
	State        ReturnState `json:"state,omitempty"`
	Body         interface{} `json:"body,omitempty"`
	ErrorCode    string      `json:"errorCode,omitempty"`
	ErrorParams  []string    `json:"errorParams,omitempty"`
	ErrorMessage string      `json:"errorMessage,omitempty"`
}

type APIPlatformResponseBody

type APIPlatformResponseBody struct {
	TimeConsuming   int64                  `json:"timeConsuming,omitempty"`
	ResponseBody    string                 `json:"responseBody,omitempty"`
	RequestHeader   map[string]interface{} `json:"requestHeader,omitempty"`
	ResponseHeader  map[string]interface{} `json:"responseHeader,omitempty"`
	ResponseMessage string                 `json:"responseMessage,omitempty"`
	StatusCode      int                    `json:"statusCode,omitempty"`
	HttpMethod      string                 `json:"httpMethod,omitempty"`
	RequestUrl      string                 `json:"requestUrl,omitempty"`
}

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type GenericResponseError

type GenericResponseError struct {
	// contains filtered or unexported fields
}

GenericResponseError Provides access to the body, error and model on returned errors.

func (GenericResponseError) Body

func (e GenericResponseError) Body() []byte

Body returns the raw bytes of the response

func (GenericResponseError) Error

func (e GenericResponseError) Error() string

Error returns non-empty string if there was an error.

func (GenericResponseError) Model

func (e GenericResponseError) Model() interface{}

Model returns the unpacked model of the error

type HttpRequest

type HttpRequest struct {
	Url          string                 `json:"url,omitempty"`
	DefaultUrl   string                 `json:"defaultUrl,omitempty"`
	Method       string                 `json:"method,omitempty"`
	Action       string                 `json:"action,omitempty"`
	Product      string                 `json:"product,omitempty"`
	Version      string                 `json:"version,omitempty"`
	SdkVersion   string                 `json:"sdkVersion,omitempty"`
	Body         interface{}            `json:"body,omitempty"`
	PathParams   map[string]interface{} `json:"pathParams,omitempty"`
	QueryParams  map[string]interface{} `json:"queryParams,omitempty"`
	HeaderParams map[string]interface{} `json:"headerParams,omitempty"`
}

func NewDefaultHttpRequest

func NewDefaultHttpRequest() *HttpRequest

type HttpRequestPosition

type HttpRequestPosition string
const (
	BODY   HttpRequestPosition = "Body"
	QUERY  HttpRequestPosition = "Query"
	PATH   HttpRequestPosition = "Path"
	HEADER HttpRequestPosition = "Header"
)

type OpenApiRequest

type OpenApiRequest struct {
	Product         string                 `json:"product,omitempty"`
	Version         string                 `json:"version,omitempty"`
	SdkVersion      string                 `json:"sdkVersion,omitempty"`
	Language        string                 `json:"language,omitempty"`
	Api             string                 `json:"api,omitempty"`
	PoolId          string                 `json:"poolId,omitempty"`
	HeaderParameter map[string]interface{} `json:"headerParameter,omitempty"`
	PathParameter   map[string]interface{} `json:"pathParameter,omitempty"`
	QueryParameter  map[string]interface{} `json:"queryParameter,omitempty"`
	BodyParameter   interface{}            `json:"bodyParameter,omitempty"`
	AccessKey       string                 `json:"accessKey,omitempty"`
	SecretKey       string                 `json:"secretKey,omitempty"`
}

type ReturnState

type ReturnState string
const (
	OK        ReturnState = "OK"
	ERROR     ReturnState = "ERROR"
	EXCEPTION ReturnState = "EXCEPTION"
	ALARM     ReturnState = "ALARM"
	FORBIDDEN ReturnState = "FORBIDDEN"
)

Source Files

  • api_client.go
  • api_response.go
  • configuration.go
  • http_request.go
  • open_api_request.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL