Skip to content

Commit

Permalink
Merge pull request #530 from tzvatot/version-gates-2
Browse files Browse the repository at this point in the history
Bump ocm-api-model to v0.0.162
  • Loading branch information
zgalor authored Dec 21, 2021
2 parents accb14a + 0becae5 commit 6dae69a
Show file tree
Hide file tree
Showing 8 changed files with 6,664 additions and 6,296 deletions.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
This document describes the relevant changes between releases of the OCM API
SDK.

## 0.1.229 Dec 21 2021

- Update to model 0.0.161:
- Add support for adding version gate.

## 0.1.228 Dec 20 2021

- Update to metamodel 0.0.46:
- Remove unused imports.
- Check result of `Flush` method.
- Cancel poll context.
- Avoid some ineffectual assigments.
- Avoid some ineffectual assignments.
- Explicitly use `jsoniter` package selector.

- Update to model 0.0.161:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export GOPROXY=https://proxy.golang.org
export CGO_ENABLED=0

# Details of the model to use:
model_version:=v0.0.161
model_version:=v0.0.162
model_url:=https://github.com/openshift-online/ocm-api-model.git

# Details of the metamodel to use:
Expand Down
12,651 changes: 6,358 additions & 6,293 deletions clustersmgmt/v1/openapi.go

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions clustersmgmt/v1/version_gates_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ limitations under the License.
package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1

import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
"path"
Expand All @@ -47,6 +49,16 @@ func NewVersionGatesClient(transport http.RoundTripper, path string) *VersionGat
}
}

// Add creates a request for the 'add' method.
//
// Adds a new version gate
func (c *VersionGatesClient) Add() *VersionGatesAddRequest {
return &VersionGatesAddRequest{
transport: c.transport,
path: c.path,
}
}

// List creates a request for the 'list' method.
//
// Retrieves a list of version gates.
Expand All @@ -67,6 +79,142 @@ func (c *VersionGatesClient) VersionGate(id string) *VersionGateClient {
)
}

// VersionGatesAddRequest is the request for the 'add' method.
type VersionGatesAddRequest struct {
transport http.RoundTripper
path string
query url.Values
header http.Header
body *VersionGate
}

// Parameter adds a query parameter.
func (r *VersionGatesAddRequest) Parameter(name string, value interface{}) *VersionGatesAddRequest {
helpers.AddValue(&r.query, name, value)
return r
}

// Header adds a request header.
func (r *VersionGatesAddRequest) Header(name string, value interface{}) *VersionGatesAddRequest {
helpers.AddHeader(&r.header, name, value)
return r
}

// Body sets the value of the 'body' parameter.
//
// Details of the version gate
func (r *VersionGatesAddRequest) Body(value *VersionGate) *VersionGatesAddRequest {
r.body = value
return r
}

// Send sends this request, waits for the response, and returns it.
//
// This is a potentially lengthy operation, as it requires network communication.
// Consider using a context and the SendContext method.
func (r *VersionGatesAddRequest) Send() (result *VersionGatesAddResponse, err error) {
return r.SendContext(context.Background())
}

// SendContext sends this request, waits for the response, and returns it.
func (r *VersionGatesAddRequest) SendContext(ctx context.Context) (result *VersionGatesAddResponse, err error) {
query := helpers.CopyQuery(r.query)
header := helpers.CopyHeader(r.header)
buffer := &bytes.Buffer{}
err = writeVersionGatesAddRequest(r, buffer)
if err != nil {
return
}
uri := &url.URL{
Path: r.path,
RawQuery: query.Encode(),
}
request := &http.Request{
Method: "POST",
URL: uri,
Header: header,
Body: ioutil.NopCloser(buffer),
}
if ctx != nil {
request = request.WithContext(ctx)
}
response, err := r.transport.RoundTrip(request)
if err != nil {
return
}
defer response.Body.Close()
result = &VersionGatesAddResponse{}
result.status = response.StatusCode
result.header = response.Header
if result.status >= 400 {
result.err, err = errors.UnmarshalErrorStatus(response.Body, result.status)
if err != nil {
return
}
err = result.err
return
}
err = readVersionGatesAddResponse(result, response.Body)
if err != nil {
return
}
return
}

// VersionGatesAddResponse is the response for the 'add' method.
type VersionGatesAddResponse struct {
status int
header http.Header
err *errors.Error
body *VersionGate
}

// Status returns the response status code.
func (r *VersionGatesAddResponse) Status() int {
if r == nil {
return 0
}
return r.status
}

// Header returns header of the response.
func (r *VersionGatesAddResponse) Header() http.Header {
if r == nil {
return nil
}
return r.header
}

// Error returns the response error.
func (r *VersionGatesAddResponse) Error() *errors.Error {
if r == nil {
return nil
}
return r.err
}

// Body returns the value of the 'body' parameter.
//
// Details of the version gate
func (r *VersionGatesAddResponse) Body() *VersionGate {
if r == nil {
return nil
}
return r.body
}

// GetBody returns the value of the 'body' parameter and
// a flag indicating if the parameter has a value.
//
// Details of the version gate
func (r *VersionGatesAddResponse) GetBody() (value *VersionGate, ok bool) {
ok = r != nil && r.body != nil
if ok {
value = r.body
}
return
}

// VersionGatesListRequest is the request for the 'list' method.
type VersionGatesListRequest struct {
transport http.RoundTripper
Expand Down
16 changes: 16 additions & 0 deletions clustersmgmt/v1/version_gates_resource_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ import (
"github.com/openshift-online/ocm-sdk-go/helpers"
)

func readVersionGatesAddRequest(request *VersionGatesAddServerRequest, r *http.Request) error {
var err error
request.body, err = UnmarshalVersionGate(r.Body)
return err
}
func writeVersionGatesAddRequest(request *VersionGatesAddRequest, writer io.Writer) error {
return MarshalVersionGate(request.body, writer)
}
func readVersionGatesAddResponse(response *VersionGatesAddResponse, reader io.Reader) error {
var err error
response.body, err = UnmarshalVersionGate(reader)
return err
}
func writeVersionGatesAddResponse(response *VersionGatesAddServerResponse, w http.ResponseWriter) error {
return MarshalVersionGate(response.body, w)
}
func readVersionGatesListRequest(request *VersionGatesListServerRequest, r *http.Request) error {
var err error
query := r.URL.Query()
Expand Down
91 changes: 91 additions & 0 deletions clustersmgmt/v1/version_gates_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import (
// VersionGatesServer represents the interface the manages the 'version_gates' resource.
type VersionGatesServer interface {

// Add handles a request for the 'add' method.
//
// Adds a new version gate
Add(ctx context.Context, request *VersionGatesAddServerRequest, response *VersionGatesAddServerResponse) error

// List handles a request for the 'list' method.
//
// Retrieves a list of version gates.
Expand All @@ -41,6 +46,54 @@ type VersionGatesServer interface {
VersionGate(id string) VersionGateServer
}

// VersionGatesAddServerRequest is the request for the 'add' method.
type VersionGatesAddServerRequest struct {
body *VersionGate
}

// Body returns the value of the 'body' parameter.
//
// Details of the version gate
func (r *VersionGatesAddServerRequest) Body() *VersionGate {
if r == nil {
return nil
}
return r.body
}

// GetBody returns the value of the 'body' parameter and
// a flag indicating if the parameter has a value.
//
// Details of the version gate
func (r *VersionGatesAddServerRequest) GetBody() (value *VersionGate, ok bool) {
ok = r != nil && r.body != nil
if ok {
value = r.body
}
return
}

// VersionGatesAddServerResponse is the response for the 'add' method.
type VersionGatesAddServerResponse struct {
status int
err *errors.Error
body *VersionGate
}

// Body sets the value of the 'body' parameter.
//
// Details of the version gate
func (r *VersionGatesAddServerResponse) Body(value *VersionGate) *VersionGatesAddServerResponse {
r.body = value
return r
}

// Status sets the status code.
func (r *VersionGatesAddServerResponse) Status(value int) *VersionGatesAddServerResponse {
r.status = value
return r
}

// VersionGatesListServerRequest is the request for the 'list' method.
type VersionGatesListServerRequest struct {
order *string
Expand Down Expand Up @@ -236,6 +289,9 @@ func (r *VersionGatesListServerResponse) Status(value int) *VersionGatesListServ
func dispatchVersionGates(w http.ResponseWriter, r *http.Request, server VersionGatesServer, segments []string) {
if len(segments) == 0 {
switch r.Method {
case "POST":
adaptVersionGatesAddRequest(w, r, server)
return
case "GET":
adaptVersionGatesListRequest(w, r, server)
return
Expand All @@ -255,6 +311,41 @@ func dispatchVersionGates(w http.ResponseWriter, r *http.Request, server Version
}
}

// adaptVersionGatesAddRequest translates the given HTTP request into a call to
// the corresponding method of the given server. Then it translates the
// results returned by that method into an HTTP response.
func adaptVersionGatesAddRequest(w http.ResponseWriter, r *http.Request, server VersionGatesServer) {
request := &VersionGatesAddServerRequest{}
err := readVersionGatesAddRequest(request, r)
if err != nil {
glog.Errorf(
"Can't read request for method '%s' and path '%s': %v",
r.Method, r.URL.Path, err,
)
errors.SendInternalServerError(w, r)
return
}
response := &VersionGatesAddServerResponse{}
response.status = 201
err = server.Add(r.Context(), request, response)
if err != nil {
glog.Errorf(
"Can't process request for method '%s' and path '%s': %v",
r.Method, r.URL.Path, err,
)
errors.SendInternalServerError(w, r)
return
}
err = writeVersionGatesAddResponse(response, w)
if err != nil {
glog.Errorf(
"Can't write response for method '%s' and path '%s': %v",
r.Method, r.URL.Path, err,
)
return
}
}

// adaptVersionGatesListRequest translates the given HTTP request into a call to
// the corresponding method of the given server. Then it translates the
// results returned by that method into an HTTP response.
Expand Down
43 changes: 43 additions & 0 deletions openapi/clusters_mgmt/v1/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6461,6 +6461,49 @@
}
},
"/api/clusters_mgmt/v1/versions/{version_id}/gates": {
"post": {
"description": "Adds a new version gate",
"parameters": [
{
"name": "version_id",
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VersionGate"
}
}
}
},
"responses": {
"201": {
"description": "Success.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VersionGate"
}
}
}
},
"default": {
"description": "Error.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"get": {
"description": "Retrieves a list of version gates.",
"parameters": [
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ limitations under the License.

package sdk

const Version = "0.1.228"
const Version = "0.1.229"

0 comments on commit 6dae69a

Please sign in to comment.