mirror of
https://github.com/openziti/zrok.git
synced 2025-06-24 19:51:32 +02:00
lint and polish for disable endpoint (#834)
This commit is contained in:
parent
9f63b911ed
commit
0fc139e6d9
@ -5,7 +5,6 @@ import (
|
||||
httpTransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/openziti/zrok/environment"
|
||||
restEnvironment "github.com/openziti/zrok/rest_client_zrok/environment"
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -52,9 +51,8 @@ func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
|
||||
}
|
||||
auth := httpTransport.APIKeyAuth("X-TOKEN", "header", env.Environment().Token)
|
||||
req := restEnvironment.NewDisableParams()
|
||||
req.Body = &rest_model_zrok.DisableRequest{
|
||||
Identity: env.Environment().ZitiIdentity,
|
||||
}
|
||||
req.Body.Identity = env.Environment().ZitiIdentity
|
||||
|
||||
_, err = zrok.Environment.Disable(req, auth)
|
||||
if err != nil {
|
||||
logrus.Warnf("share cleanup failed (%v); will clean up local environment", err)
|
||||
|
@ -14,8 +14,6 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewDisableParams creates a new DisableParams object,
|
||||
@ -64,7 +62,7 @@ DisableParams contains all the parameters to send to the API endpoint
|
||||
type DisableParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.DisableRequest
|
||||
Body DisableBody
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
@ -120,13 +118,13 @@ func (o *DisableParams) SetHTTPClient(client *http.Client) {
|
||||
}
|
||||
|
||||
// WithBody adds the body to the disable params
|
||||
func (o *DisableParams) WithBody(body *rest_model_zrok.DisableRequest) *DisableParams {
|
||||
func (o *DisableParams) WithBody(body DisableBody) *DisableParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the disable params
|
||||
func (o *DisableParams) SetBody(body *rest_model_zrok.DisableRequest) {
|
||||
func (o *DisableParams) SetBody(body DisableBody) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
@ -137,10 +135,8 @@ func (o *DisableParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
|
@ -6,10 +6,12 @@ package environment
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// DisableReader is a Reader for the Disable structure.
|
||||
@ -210,3 +212,41 @@ func (o *DisableInternalServerError) readResponse(response runtime.ClientRespons
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
DisableBody disable body
|
||||
swagger:model DisableBody
|
||||
*/
|
||||
type DisableBody struct {
|
||||
|
||||
// identity
|
||||
Identity string `json:"identity,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this disable body
|
||||
func (o *DisableBody) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this disable body based on context it is used
|
||||
func (o *DisableBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (o *DisableBody) MarshalBinary() ([]byte, error) {
|
||||
if o == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(o)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (o *DisableBody) UnmarshalBinary(b []byte) error {
|
||||
var res DisableBody
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*o = res
|
||||
return nil
|
||||
}
|
||||
|
@ -343,7 +343,11 @@ func init() {
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/disableRequest"
|
||||
"properties": {
|
||||
"identity": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -1862,14 +1866,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identity": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -2587,7 +2583,11 @@ func init() {
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/disableRequest"
|
||||
"properties": {
|
||||
"identity": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -4111,14 +4111,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identity": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -6,9 +6,12 @@ package environment
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
)
|
||||
@ -69,3 +72,40 @@ func (o *Disable) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
|
||||
// DisableBody disable body
|
||||
//
|
||||
// swagger:model DisableBody
|
||||
type DisableBody struct {
|
||||
|
||||
// identity
|
||||
Identity string `json:"identity,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this disable body
|
||||
func (o *DisableBody) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this disable body based on context it is used
|
||||
func (o *DisableBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (o *DisableBody) MarshalBinary() ([]byte, error) {
|
||||
if o == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(o)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (o *DisableBody) UnmarshalBinary(b []byte) error {
|
||||
var res DisableBody
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*o = res
|
||||
return nil
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewDisableParams creates a new DisableParams object
|
||||
@ -36,7 +34,7 @@ type DisableParams struct {
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.DisableRequest
|
||||
Body DisableBody
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
@ -50,7 +48,7 @@ func (o *DisableParams) BindRequest(r *http.Request, route *middleware.MatchedRo
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body rest_model_zrok.DisableRequest
|
||||
var body DisableBody
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
} else {
|
||||
@ -65,7 +63,7 @@ func (o *DisableParams) BindRequest(r *http.Request, route *middleware.MatchedRo
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
o.Body = body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ from zrok_api.models.account_body import AccountBody
|
||||
from zrok_api.models.auth_user import AuthUser
|
||||
from zrok_api.models.change_password_body import ChangePasswordBody
|
||||
from zrok_api.models.configuration import Configuration
|
||||
from zrok_api.models.disable_request import DisableRequest
|
||||
from zrok_api.models.disable_body import DisableBody
|
||||
from zrok_api.models.enable_body import EnableBody
|
||||
from zrok_api.models.environment import Environment
|
||||
from zrok_api.models.environment_and_resources import EnvironmentAndResources
|
||||
|
@ -41,7 +41,7 @@ class EnvironmentApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool
|
||||
:param DisableRequest body:
|
||||
:param DisableBody body:
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
@ -62,7 +62,7 @@ class EnvironmentApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool
|
||||
:param DisableRequest body:
|
||||
:param DisableBody body:
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
|
@ -20,7 +20,7 @@ from zrok_api.models.account_body import AccountBody
|
||||
from zrok_api.models.auth_user import AuthUser
|
||||
from zrok_api.models.change_password_body import ChangePasswordBody
|
||||
from zrok_api.models.configuration import Configuration
|
||||
from zrok_api.models.disable_request import DisableRequest
|
||||
from zrok_api.models.disable_body import DisableBody
|
||||
from zrok_api.models.enable_body import EnableBody
|
||||
from zrok_api.models.environment import Environment
|
||||
from zrok_api.models.environment_and_resources import EnvironmentAndResources
|
||||
|
110
sdk/python/sdk/zrok/zrok_api/models/disable_body.py
Normal file
110
sdk/python/sdk/zrok/zrok_api/models/disable_body.py
Normal file
@ -0,0 +1,110 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
zrok
|
||||
|
||||
zrok client access # noqa: E501
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
"""
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
class DisableBody(object):
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
"""
|
||||
Attributes:
|
||||
swagger_types (dict): The key is attribute name
|
||||
and the value is attribute type.
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
swagger_types = {
|
||||
'identity': 'str'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'identity': 'identity'
|
||||
}
|
||||
|
||||
def __init__(self, identity=None): # noqa: E501
|
||||
"""DisableBody - a model defined in Swagger""" # noqa: E501
|
||||
self._identity = None
|
||||
self.discriminator = None
|
||||
if identity is not None:
|
||||
self.identity = identity
|
||||
|
||||
@property
|
||||
def identity(self):
|
||||
"""Gets the identity of this DisableBody. # noqa: E501
|
||||
|
||||
|
||||
:return: The identity of this DisableBody. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._identity
|
||||
|
||||
@identity.setter
|
||||
def identity(self, identity):
|
||||
"""Sets the identity of this DisableBody.
|
||||
|
||||
|
||||
:param identity: The identity of this DisableBody. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
|
||||
self._identity = identity
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
if issubclass(DisableBody, dict):
|
||||
for key, value in self.items():
|
||||
result[key] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, DisableBody):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
@ -659,7 +659,9 @@ paths:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/disableRequest"
|
||||
properties:
|
||||
identity:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: environment disabled
|
||||
@ -1156,12 +1158,6 @@ definitions:
|
||||
passwordRequirements:
|
||||
$ref: "#/definitions/passwordRequirements"
|
||||
|
||||
disableRequest:
|
||||
type: object
|
||||
properties:
|
||||
identity:
|
||||
type: string
|
||||
|
||||
environment:
|
||||
type: object
|
||||
properties:
|
||||
|
Loading…
x
Reference in New Issue
Block a user