openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk-client-go] 02/03: Remove "experimental" gateway api (#2547)
Date Wed, 09 Aug 2017 20:27:46 GMT
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git

commit 0358422b67c2b02853ad2b775fe62345a0b1a09b
Author: David Cariello <drcariel@us.ibm.com>
AuthorDate: Tue Aug 8 12:14:35 2017 -0500

    Remove "experimental" gateway api (#2547)
---
 whisk/api.go | 220 +++++------------------------------------------------------
 1 file changed, 18 insertions(+), 202 deletions(-)

diff --git a/whisk/api.go b/whisk/api.go
index 6408367..9667017 100644
--- a/whisk/api.go
+++ b/whisk/api.go
@@ -33,7 +33,6 @@ type ApiCreateRequest struct {
 }
 type ApiCreateRequestOptions ApiOptions
 type ApiCreateResponse RetApi
-type ApiCreateResponseV2 RetApiV2
 
 // wsk api list : Request, Response
 type ApiListRequest struct {
@@ -44,8 +43,8 @@ type ApiListRequestOptions struct {
     Skip            int       `url:"skip"`
     Docs            bool      `url:"docs,omitempty"`
 }
+//type ApiListResponse RetApiArray
 type ApiListResponse RetApiArray
-type ApiListResponseV2 RetApiArrayV2
 
 // wsk api get : Request, Response
 type ApiGetRequest struct {
@@ -53,7 +52,6 @@ type ApiGetRequest struct {
 }
 type ApiGetRequestOptions ApiOptions
 type ApiGetResponse RetApiArray
-type ApiGetResponseV2 RetApiArrayV2
 
 // wsk api delete : Request, Response
 type ApiDeleteRequest struct {
@@ -105,7 +103,7 @@ type RetApiArray struct {
 type ApiItem struct {
     ApiId           string    `json:"id,omitempty"`
     QueryKey        string    `json:"key,omitempty"`
-    ApiValue        *RetApi   `json:"value,omitempty"`
+    ApiValue        *RetApi `json:"value,omitempty"`
 }
 
 type RetApi struct {
@@ -120,33 +118,7 @@ type ApiSwagger struct {
     SwaggerName     string    `json:"swagger,omitempty"`
     BasePath        string    `json:"basePath,omitempty"`
     Info            *ApiSwaggerInfo `json:"info,omitempty"`
-    Paths           map[string]map[string]*ApiSwaggerOperationV1 `json:"paths,omitempty"`
-    XConfig         map[string]map[string][]map[string]map[string]interface{} `json:"x-ibm-configuration,omitempty"`
-}
-
-type RetApiArrayV2 struct {
-    Apis            []ApiItemV2 `json:"apis,omitempty"`
-}
-
-type ApiItemV2 struct {
-    ApiId           string    `json:"id,omitempty"`
-    QueryKey        string    `json:"key,omitempty"`
-    ApiValue        *RetApiV2 `json:"value,omitempty"`
-}
-
-type RetApiV2 struct {
-    Namespace       string    `json:"namespace"`
-    BaseUrl         string    `json:"gwApiUrl"`
-    Activated       bool      `json:"gwApiActivated"`
-    TenantId        string    `json:"tenantId"`
-    Swagger         *ApiSwaggerV2 `json:"apidoc,omitempty"`
-}
-
-type ApiSwaggerV2 struct {
-    SwaggerName     string    `json:"swagger,omitempty"`
-    BasePath        string    `json:"basePath,omitempty"`
-    Info            *ApiSwaggerInfo `json:"info,omitempty"`
-    Paths           map[string]map[string]*ApiSwaggerOperationV2 `json:"paths,omitempty"`
 // Paths["/a/path"]["get"] -> a generic object
+    Paths           map[string]map[string]*ApiSwaggerOperation `json:"paths,omitempty"` 
// Paths["/a/path"]["get"] -> a generic object
     SecurityDef     interface{} `json:"securityDefinitions,omitempty"`
     Security        interface{} `json:"security,omitempty"`
     XConfig         interface{} `json:"x-ibm-configuration,omitempty"`
@@ -158,26 +130,13 @@ type ApiSwaggerInfo struct {
     Version         string    `json:"version,omitempty"`
 }
 
-type ApiSwaggerOperationV1 struct {
-    Responses       interface{} `json:"responses"`
-    XOpenWhisk      *ApiSwaggerOpXOpenWhiskV1 `json:"x-ibm-op-ext,omitempty"`
-}
-
-type ApiSwaggerOperationV2 struct {
+type ApiSwaggerOperation struct {
     OperationId     string    `json:"operationId"`
     Responses       interface{} `json:"responses"`
-    XOpenWhisk      *ApiSwaggerOpXOpenWhiskV2 `json:"x-openwhisk,omitempty"`
+    XOpenWhisk      *ApiSwaggerOpXOpenWhisk `json:"x-openwhisk,omitempty"`
 }
 
-type ApiSwaggerOpXOpenWhiskV1 struct {
-    ActionName      string    `json:"actionName"`
-    Namespace       string    `json:"actionNamespace"`
-    ActionUrlVerb   string    `json:"backendMethod"`
-    ActionUrl       string    `json:"backendUrl"`
-    Policies        interface{} `json:"policies"`
-}
-
-type ApiSwaggerOpXOpenWhiskV2 struct {
+type ApiSwaggerOpXOpenWhisk struct {
     ActionName      string    `json:"action"`
     Namespace       string    `json:"namespace"`
     Package         string    `json:"package"`
@@ -199,154 +158,11 @@ const (
     DoNotOverwrite = false
 )
 
-////////////////////
+/////////////////
 // Api Methods //
-////////////////////
+/////////////////
 
 func (s *ApiService) List(apiListOptions *ApiListRequestOptions) (*ApiListResponse, *http.Response,
error) {
-    route := "web/whisk.system/routemgmt/getApi.http"
-    Debug(DbgInfo, "Api GET/list route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, apiListOptions)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, apiListOptions,
err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": apiListOptions})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgInfo, "Api GET/list route with api options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("GET", routeUrl, nil, DoNotIncludeNamespaceInUrl,
AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix,
EncodeBodyAsJson, AuthRequired) error: '%s'\n", routeUrl, err)
-        errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": routeUrl, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    apiArray := new(ApiListResponse)
-    resp, err := s.client.Do(req, &apiArray, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
-        return nil, resp, err
-    }
-
-    return apiArray, resp, err
-}
-
-func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite
bool) (*ApiCreateResponse, *http.Response, error) {
-    route := "web/whisk.system/routemgmt/createApi.http"
-    Debug(DbgInfo, "Api PUT route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgError, "Api create route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("POST", routeUrl, api, DoNotIncludeNamespaceInUrl,
AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(POST, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix,
EncodeBodyAsJson) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    retApi := new(ApiCreateResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
-        return nil, resp, err
-    }
-
-    return retApi, resp, nil
-}
-
-func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponse,
*http.Response, error) {
-    route := "web/whisk.system/routemgmt/getApi.http"
-    Debug(DbgInfo, "Api GET route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgError, "Api get route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("GET", routeUrl, nil, DoNotIncludeNamespaceInUrl,
AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix,
EncodeBodyAsJson, AuthRequired) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    retApi := new(ApiGetResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
-        return nil, resp, err
-    }
-
-    return retApi, resp, nil
-}
-
-func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response,
error) {
-    route := "web/whisk.system/routemgmt/deleteApi.http"
-    Debug(DbgInfo, "Api DELETE route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, whiskErr
-    }
-    Debug(DbgError, "Api DELETE route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("DELETE", routeUrl, nil, DoNotIncludeNamespaceInUrl,
AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(DELETE, %s, nil, DoNotIncludeNamespaceInUrl,
AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK,
DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, whiskErr
-    }
-
-    retApi := new(ApiDeleteResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
-        return resp, err
-    }
-
-    return nil, nil
-}
-
-/////////////
-// V2 Cmds //
-/////////////
-func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResponseV2, *http.Response,
error) {
     route := "web/whisk.system/apimgmt/getApi.http"
 
     routeUrl, err := addRouteOptions(route, apiListOptions)
@@ -370,7 +186,7 @@ func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResp
         return nil, nil, whiskErr
     }
 
-    apiArray := new(ApiListResponseV2)
+    apiArray := new(ApiListResponse)
     resp, err := s.client.Do(req, &apiArray, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
@@ -386,7 +202,7 @@ func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResp
     return apiArray, resp, err
 }
 
-func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite
bool) (*ApiCreateResponseV2, *http.Response, error) {
+func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite
bool) (*ApiCreateResponse, *http.Response, error) {
     route := "web/whisk.system/apimgmt/createApi.http"
     Debug(DbgInfo, "Api PUT route: %s\n", route)
 
@@ -411,7 +227,7 @@ func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOp
         return nil, nil, whiskErr
     }
 
-    retApi := new(ApiCreateResponseV2)
+    retApi := new(ApiCreateResponse)
     resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
@@ -427,7 +243,7 @@ func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOp
     return retApi, resp, nil
 }
 
-func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponseV2,
*http.Response, error) {
+func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponse,
*http.Response, error) {
     route := "web/whisk.system/apimgmt/getApi.http"
     Debug(DbgInfo, "Api GET route: %s\n", route)
 
@@ -452,7 +268,7 @@ func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions)
(*
         return nil, nil, whiskErr
     }
 
-    retApi := new(ApiGetResponseV2)
+    retApi := new(ApiGetResponse)
     resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(),
err)
@@ -462,7 +278,7 @@ func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions)
(*
     return retApi, resp, nil
 }
 
-func (s *ApiService) DeleteV2(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response,
error) {
+func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response,
error) {
     route := "web/whisk.system/apimgmt/deleteApi.http"
     Debug(DbgInfo, "Api DELETE route: %s\n", route)
 
@@ -498,7 +314,7 @@ func (s *ApiService) DeleteV2(api *ApiDeleteRequest, options *ApiDeleteRequestOp
 }
 
 
-func validateApiListResponse(apiList *ApiListResponseV2) error {
+func validateApiListResponse(apiList *ApiListResponse) error {
     for i:=0; i<len(apiList.Apis); i++ {
         if apiList.Apis[i].ApiValue == nil {
             Debug(DbgError, "validateApiResponse: No value stanza in api %v\n", apiList.Apis[i])
@@ -515,7 +331,7 @@ func validateApiListResponse(apiList *ApiListResponseV2) error {
     return nil
 }
 
-func validateApiSwaggerResponse(swagger *ApiSwaggerV2) error {
+func validateApiSwaggerResponse(swagger *ApiSwagger) error {
     if swagger == nil {
         Debug(DbgError, "validateApiSwaggerResponse: No apidoc stanza in api\n")
         errMsg := wski18n.T("Internal error. Missing apidoc stanza in API configuration")
@@ -533,7 +349,7 @@ func validateApiSwaggerResponse(swagger *ApiSwaggerV2) error {
     return nil
 }
 
-func validateApiPath(path map[string]*ApiSwaggerOperationV2) error {
+func validateApiPath(path map[string]*ApiSwaggerOperation) error {
     for op, opv := range path {
         err := validateApiOperation(op, opv)
         if err != nil {
@@ -544,7 +360,7 @@ func validateApiPath(path map[string]*ApiSwaggerOperationV2) error {
     return nil
 }
 
-func validateApiOperation(opName string, op *ApiSwaggerOperationV2) error {
+func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
     if (op.XOpenWhisk != nil && len(op.OperationId) == 0) {
         Debug(DbgError, "validateApiOperation: No operationId field in operation %v\n", op)
         errMsg := wski18n.T("Missing operationId field in API configuration for operation
{{.op}}",

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>.

Mime
View raw message