...

Source file src/github.com/redhat-developer/odo/pkg/apiserver-gen/go/api_devstate.go

Documentation: github.com/redhat-developer/odo/pkg/apiserver-gen/go

     1  /*
     2   * odo dev
     3   *
     4   * API interface for 'odo dev'
     5   *
     6   * API version: 0.1
     7   * Generated by: OpenAPI Generator (https://openapi-generator.tech)
     8   */
     9  
    10  package openapi
    11  
    12  import (
    13  	"encoding/json"
    14  	"net/http"
    15  	"strings"
    16  
    17  	"github.com/gorilla/mux"
    18  )
    19  
    20  // DevstateApiController binds http requests to an api service and writes the service results to the http response
    21  type DevstateApiController struct {
    22  	service      DevstateApiServicer
    23  	errorHandler ErrorHandler
    24  }
    25  
    26  // DevstateApiOption for how the controller is set up.
    27  type DevstateApiOption func(*DevstateApiController)
    28  
    29  // WithDevstateApiErrorHandler inject ErrorHandler into controller
    30  func WithDevstateApiErrorHandler(h ErrorHandler) DevstateApiOption {
    31  	return func(c *DevstateApiController) {
    32  		c.errorHandler = h
    33  	}
    34  }
    35  
    36  // NewDevstateApiController creates a default api controller
    37  func NewDevstateApiController(s DevstateApiServicer, opts ...DevstateApiOption) Router {
    38  	controller := &DevstateApiController{
    39  		service:      s,
    40  		errorHandler: DefaultErrorHandler,
    41  	}
    42  
    43  	for _, opt := range opts {
    44  		opt(controller)
    45  	}
    46  
    47  	return controller
    48  }
    49  
    50  // Routes returns all the api routes for the DevstateApiController
    51  func (c *DevstateApiController) Routes() Routes {
    52  	return Routes{
    53  		{
    54  			"DevstateApplyCommandCommandNamePatch",
    55  			strings.ToUpper("Patch"),
    56  			"/api/v1/devstate/applyCommand/{commandName}",
    57  			c.DevstateApplyCommandCommandNamePatch,
    58  		},
    59  		{
    60  			"DevstateApplyCommandPost",
    61  			strings.ToUpper("Post"),
    62  			"/api/v1/devstate/applyCommand",
    63  			c.DevstateApplyCommandPost,
    64  		},
    65  		{
    66  			"DevstateChartGet",
    67  			strings.ToUpper("Get"),
    68  			"/api/v1/devstate/chart",
    69  			c.DevstateChartGet,
    70  		},
    71  		{
    72  			"DevstateCommandCommandNameDelete",
    73  			strings.ToUpper("Delete"),
    74  			"/api/v1/devstate/command/{commandName}",
    75  			c.DevstateCommandCommandNameDelete,
    76  		},
    77  		{
    78  			"DevstateCommandCommandNameMovePost",
    79  			strings.ToUpper("Post"),
    80  			"/api/v1/devstate/command/{commandName}/move",
    81  			c.DevstateCommandCommandNameMovePost,
    82  		},
    83  		{
    84  			"DevstateCommandCommandNameSetDefaultPost",
    85  			strings.ToUpper("Post"),
    86  			"/api/v1/devstate/command/{commandName}/setDefault",
    87  			c.DevstateCommandCommandNameSetDefaultPost,
    88  		},
    89  		{
    90  			"DevstateCommandCommandNameUnsetDefaultPost",
    91  			strings.ToUpper("Post"),
    92  			"/api/v1/devstate/command/{commandName}/unsetDefault",
    93  			c.DevstateCommandCommandNameUnsetDefaultPost,
    94  		},
    95  		{
    96  			"DevstateCompositeCommandCommandNamePatch",
    97  			strings.ToUpper("Patch"),
    98  			"/api/v1/devstate/compositeCommand/{commandName}",
    99  			c.DevstateCompositeCommandCommandNamePatch,
   100  		},
   101  		{
   102  			"DevstateCompositeCommandPost",
   103  			strings.ToUpper("Post"),
   104  			"/api/v1/devstate/compositeCommand",
   105  			c.DevstateCompositeCommandPost,
   106  		},
   107  		{
   108  			"DevstateContainerContainerNameDelete",
   109  			strings.ToUpper("Delete"),
   110  			"/api/v1/devstate/container/{containerName}",
   111  			c.DevstateContainerContainerNameDelete,
   112  		},
   113  		{
   114  			"DevstateContainerContainerNamePatch",
   115  			strings.ToUpper("Patch"),
   116  			"/api/v1/devstate/container/{containerName}",
   117  			c.DevstateContainerContainerNamePatch,
   118  		},
   119  		{
   120  			"DevstateContainerPost",
   121  			strings.ToUpper("Post"),
   122  			"/api/v1/devstate/container",
   123  			c.DevstateContainerPost,
   124  		},
   125  		{
   126  			"DevstateDevfileDelete",
   127  			strings.ToUpper("Delete"),
   128  			"/api/v1/devstate/devfile",
   129  			c.DevstateDevfileDelete,
   130  		},
   131  		{
   132  			"DevstateDevfileGet",
   133  			strings.ToUpper("Get"),
   134  			"/api/v1/devstate/devfile",
   135  			c.DevstateDevfileGet,
   136  		},
   137  		{
   138  			"DevstateDevfilePut",
   139  			strings.ToUpper("Put"),
   140  			"/api/v1/devstate/devfile",
   141  			c.DevstateDevfilePut,
   142  		},
   143  		{
   144  			"DevstateEventsPut",
   145  			strings.ToUpper("Put"),
   146  			"/api/v1/devstate/events",
   147  			c.DevstateEventsPut,
   148  		},
   149  		{
   150  			"DevstateExecCommandCommandNamePatch",
   151  			strings.ToUpper("Patch"),
   152  			"/api/v1/devstate/execCommand/{commandName}",
   153  			c.DevstateExecCommandCommandNamePatch,
   154  		},
   155  		{
   156  			"DevstateExecCommandPost",
   157  			strings.ToUpper("Post"),
   158  			"/api/v1/devstate/execCommand",
   159  			c.DevstateExecCommandPost,
   160  		},
   161  		{
   162  			"DevstateImageImageNameDelete",
   163  			strings.ToUpper("Delete"),
   164  			"/api/v1/devstate/image/{imageName}",
   165  			c.DevstateImageImageNameDelete,
   166  		},
   167  		{
   168  			"DevstateImageImageNamePatch",
   169  			strings.ToUpper("Patch"),
   170  			"/api/v1/devstate/image/{imageName}",
   171  			c.DevstateImageImageNamePatch,
   172  		},
   173  		{
   174  			"DevstateImagePost",
   175  			strings.ToUpper("Post"),
   176  			"/api/v1/devstate/image",
   177  			c.DevstateImagePost,
   178  		},
   179  		{
   180  			"DevstateMetadataPut",
   181  			strings.ToUpper("Put"),
   182  			"/api/v1/devstate/metadata",
   183  			c.DevstateMetadataPut,
   184  		},
   185  		{
   186  			"DevstateQuantityValidPost",
   187  			strings.ToUpper("Post"),
   188  			"/api/v1/devstate/quantityValid",
   189  			c.DevstateQuantityValidPost,
   190  		},
   191  		{
   192  			"DevstateResourcePost",
   193  			strings.ToUpper("Post"),
   194  			"/api/v1/devstate/resource",
   195  			c.DevstateResourcePost,
   196  		},
   197  		{
   198  			"DevstateResourceResourceNameDelete",
   199  			strings.ToUpper("Delete"),
   200  			"/api/v1/devstate/resource/{resourceName}",
   201  			c.DevstateResourceResourceNameDelete,
   202  		},
   203  		{
   204  			"DevstateResourceResourceNamePatch",
   205  			strings.ToUpper("Patch"),
   206  			"/api/v1/devstate/resource/{resourceName}",
   207  			c.DevstateResourceResourceNamePatch,
   208  		},
   209  		{
   210  			"DevstateVolumePost",
   211  			strings.ToUpper("Post"),
   212  			"/api/v1/devstate/volume",
   213  			c.DevstateVolumePost,
   214  		},
   215  		{
   216  			"DevstateVolumeVolumeNameDelete",
   217  			strings.ToUpper("Delete"),
   218  			"/api/v1/devstate/volume/{volumeName}",
   219  			c.DevstateVolumeVolumeNameDelete,
   220  		},
   221  		{
   222  			"DevstateVolumeVolumeNamePatch",
   223  			strings.ToUpper("Patch"),
   224  			"/api/v1/devstate/volume/{volumeName}",
   225  			c.DevstateVolumeVolumeNamePatch,
   226  		},
   227  	}
   228  }
   229  
   230  // DevstateApplyCommandCommandNamePatch -
   231  func (c *DevstateApiController) DevstateApplyCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
   232  	params := mux.Vars(r)
   233  	commandNameParam := params["commandName"]
   234  	devstateApplyCommandCommandNamePatchRequestParam := DevstateApplyCommandCommandNamePatchRequest{}
   235  	d := json.NewDecoder(r.Body)
   236  	d.DisallowUnknownFields()
   237  	if err := d.Decode(&devstateApplyCommandCommandNamePatchRequestParam); err != nil {
   238  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   239  		return
   240  	}
   241  	if err := AssertDevstateApplyCommandCommandNamePatchRequestRequired(devstateApplyCommandCommandNamePatchRequestParam); err != nil {
   242  		c.errorHandler(w, r, err, nil)
   243  		return
   244  	}
   245  	result, err := c.service.DevstateApplyCommandCommandNamePatch(r.Context(), commandNameParam, devstateApplyCommandCommandNamePatchRequestParam)
   246  	// If an error occurred, encode the error with the status code
   247  	if err != nil {
   248  		c.errorHandler(w, r, err, &result)
   249  		return
   250  	}
   251  	// If no error, encode the body and the result code
   252  	EncodeJSONResponse(result.Body, &result.Code, w)
   253  
   254  }
   255  
   256  // DevstateApplyCommandPost -
   257  func (c *DevstateApiController) DevstateApplyCommandPost(w http.ResponseWriter, r *http.Request) {
   258  	devstateApplyCommandPostRequestParam := DevstateApplyCommandPostRequest{}
   259  	d := json.NewDecoder(r.Body)
   260  	d.DisallowUnknownFields()
   261  	if err := d.Decode(&devstateApplyCommandPostRequestParam); err != nil {
   262  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   263  		return
   264  	}
   265  	if err := AssertDevstateApplyCommandPostRequestRequired(devstateApplyCommandPostRequestParam); err != nil {
   266  		c.errorHandler(w, r, err, nil)
   267  		return
   268  	}
   269  	result, err := c.service.DevstateApplyCommandPost(r.Context(), devstateApplyCommandPostRequestParam)
   270  	// If an error occurred, encode the error with the status code
   271  	if err != nil {
   272  		c.errorHandler(w, r, err, &result)
   273  		return
   274  	}
   275  	// If no error, encode the body and the result code
   276  	EncodeJSONResponse(result.Body, &result.Code, w)
   277  
   278  }
   279  
   280  // DevstateChartGet -
   281  func (c *DevstateApiController) DevstateChartGet(w http.ResponseWriter, r *http.Request) {
   282  	result, err := c.service.DevstateChartGet(r.Context())
   283  	// If an error occurred, encode the error with the status code
   284  	if err != nil {
   285  		c.errorHandler(w, r, err, &result)
   286  		return
   287  	}
   288  	// If no error, encode the body and the result code
   289  	EncodeJSONResponse(result.Body, &result.Code, w)
   290  
   291  }
   292  
   293  // DevstateCommandCommandNameDelete -
   294  func (c *DevstateApiController) DevstateCommandCommandNameDelete(w http.ResponseWriter, r *http.Request) {
   295  	params := mux.Vars(r)
   296  	commandNameParam := params["commandName"]
   297  	result, err := c.service.DevstateCommandCommandNameDelete(r.Context(), commandNameParam)
   298  	// If an error occurred, encode the error with the status code
   299  	if err != nil {
   300  		c.errorHandler(w, r, err, &result)
   301  		return
   302  	}
   303  	// If no error, encode the body and the result code
   304  	EncodeJSONResponse(result.Body, &result.Code, w)
   305  
   306  }
   307  
   308  // DevstateCommandCommandNameMovePost -
   309  func (c *DevstateApiController) DevstateCommandCommandNameMovePost(w http.ResponseWriter, r *http.Request) {
   310  	params := mux.Vars(r)
   311  	commandNameParam := params["commandName"]
   312  	devstateCommandCommandNameMovePostRequestParam := DevstateCommandCommandNameMovePostRequest{}
   313  	d := json.NewDecoder(r.Body)
   314  	d.DisallowUnknownFields()
   315  	if err := d.Decode(&devstateCommandCommandNameMovePostRequestParam); err != nil {
   316  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   317  		return
   318  	}
   319  	if err := AssertDevstateCommandCommandNameMovePostRequestRequired(devstateCommandCommandNameMovePostRequestParam); err != nil {
   320  		c.errorHandler(w, r, err, nil)
   321  		return
   322  	}
   323  	result, err := c.service.DevstateCommandCommandNameMovePost(r.Context(), commandNameParam, devstateCommandCommandNameMovePostRequestParam)
   324  	// If an error occurred, encode the error with the status code
   325  	if err != nil {
   326  		c.errorHandler(w, r, err, &result)
   327  		return
   328  	}
   329  	// If no error, encode the body and the result code
   330  	EncodeJSONResponse(result.Body, &result.Code, w)
   331  
   332  }
   333  
   334  // DevstateCommandCommandNameSetDefaultPost -
   335  func (c *DevstateApiController) DevstateCommandCommandNameSetDefaultPost(w http.ResponseWriter, r *http.Request) {
   336  	params := mux.Vars(r)
   337  	commandNameParam := params["commandName"]
   338  	devstateCommandCommandNameSetDefaultPostRequestParam := DevstateCommandCommandNameSetDefaultPostRequest{}
   339  	d := json.NewDecoder(r.Body)
   340  	d.DisallowUnknownFields()
   341  	if err := d.Decode(&devstateCommandCommandNameSetDefaultPostRequestParam); err != nil {
   342  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   343  		return
   344  	}
   345  	if err := AssertDevstateCommandCommandNameSetDefaultPostRequestRequired(devstateCommandCommandNameSetDefaultPostRequestParam); err != nil {
   346  		c.errorHandler(w, r, err, nil)
   347  		return
   348  	}
   349  	result, err := c.service.DevstateCommandCommandNameSetDefaultPost(r.Context(), commandNameParam, devstateCommandCommandNameSetDefaultPostRequestParam)
   350  	// If an error occurred, encode the error with the status code
   351  	if err != nil {
   352  		c.errorHandler(w, r, err, &result)
   353  		return
   354  	}
   355  	// If no error, encode the body and the result code
   356  	EncodeJSONResponse(result.Body, &result.Code, w)
   357  
   358  }
   359  
   360  // DevstateCommandCommandNameUnsetDefaultPost -
   361  func (c *DevstateApiController) DevstateCommandCommandNameUnsetDefaultPost(w http.ResponseWriter, r *http.Request) {
   362  	params := mux.Vars(r)
   363  	commandNameParam := params["commandName"]
   364  	result, err := c.service.DevstateCommandCommandNameUnsetDefaultPost(r.Context(), commandNameParam)
   365  	// If an error occurred, encode the error with the status code
   366  	if err != nil {
   367  		c.errorHandler(w, r, err, &result)
   368  		return
   369  	}
   370  	// If no error, encode the body and the result code
   371  	EncodeJSONResponse(result.Body, &result.Code, w)
   372  
   373  }
   374  
   375  // DevstateCompositeCommandCommandNamePatch -
   376  func (c *DevstateApiController) DevstateCompositeCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
   377  	params := mux.Vars(r)
   378  	commandNameParam := params["commandName"]
   379  	devstateCompositeCommandCommandNamePatchRequestParam := DevstateCompositeCommandCommandNamePatchRequest{}
   380  	d := json.NewDecoder(r.Body)
   381  	d.DisallowUnknownFields()
   382  	if err := d.Decode(&devstateCompositeCommandCommandNamePatchRequestParam); err != nil {
   383  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   384  		return
   385  	}
   386  	if err := AssertDevstateCompositeCommandCommandNamePatchRequestRequired(devstateCompositeCommandCommandNamePatchRequestParam); err != nil {
   387  		c.errorHandler(w, r, err, nil)
   388  		return
   389  	}
   390  	result, err := c.service.DevstateCompositeCommandCommandNamePatch(r.Context(), commandNameParam, devstateCompositeCommandCommandNamePatchRequestParam)
   391  	// If an error occurred, encode the error with the status code
   392  	if err != nil {
   393  		c.errorHandler(w, r, err, &result)
   394  		return
   395  	}
   396  	// If no error, encode the body and the result code
   397  	EncodeJSONResponse(result.Body, &result.Code, w)
   398  
   399  }
   400  
   401  // DevstateCompositeCommandPost -
   402  func (c *DevstateApiController) DevstateCompositeCommandPost(w http.ResponseWriter, r *http.Request) {
   403  	devstateCompositeCommandPostRequestParam := DevstateCompositeCommandPostRequest{}
   404  	d := json.NewDecoder(r.Body)
   405  	d.DisallowUnknownFields()
   406  	if err := d.Decode(&devstateCompositeCommandPostRequestParam); err != nil {
   407  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   408  		return
   409  	}
   410  	if err := AssertDevstateCompositeCommandPostRequestRequired(devstateCompositeCommandPostRequestParam); err != nil {
   411  		c.errorHandler(w, r, err, nil)
   412  		return
   413  	}
   414  	result, err := c.service.DevstateCompositeCommandPost(r.Context(), devstateCompositeCommandPostRequestParam)
   415  	// If an error occurred, encode the error with the status code
   416  	if err != nil {
   417  		c.errorHandler(w, r, err, &result)
   418  		return
   419  	}
   420  	// If no error, encode the body and the result code
   421  	EncodeJSONResponse(result.Body, &result.Code, w)
   422  
   423  }
   424  
   425  // DevstateContainerContainerNameDelete -
   426  func (c *DevstateApiController) DevstateContainerContainerNameDelete(w http.ResponseWriter, r *http.Request) {
   427  	params := mux.Vars(r)
   428  	containerNameParam := params["containerName"]
   429  	result, err := c.service.DevstateContainerContainerNameDelete(r.Context(), containerNameParam)
   430  	// If an error occurred, encode the error with the status code
   431  	if err != nil {
   432  		c.errorHandler(w, r, err, &result)
   433  		return
   434  	}
   435  	// If no error, encode the body and the result code
   436  	EncodeJSONResponse(result.Body, &result.Code, w)
   437  
   438  }
   439  
   440  // DevstateContainerContainerNamePatch -
   441  func (c *DevstateApiController) DevstateContainerContainerNamePatch(w http.ResponseWriter, r *http.Request) {
   442  	params := mux.Vars(r)
   443  	containerNameParam := params["containerName"]
   444  	devstateContainerContainerNamePatchRequestParam := DevstateContainerContainerNamePatchRequest{}
   445  	d := json.NewDecoder(r.Body)
   446  	d.DisallowUnknownFields()
   447  	if err := d.Decode(&devstateContainerContainerNamePatchRequestParam); err != nil {
   448  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   449  		return
   450  	}
   451  	if err := AssertDevstateContainerContainerNamePatchRequestRequired(devstateContainerContainerNamePatchRequestParam); err != nil {
   452  		c.errorHandler(w, r, err, nil)
   453  		return
   454  	}
   455  	result, err := c.service.DevstateContainerContainerNamePatch(r.Context(), containerNameParam, devstateContainerContainerNamePatchRequestParam)
   456  	// If an error occurred, encode the error with the status code
   457  	if err != nil {
   458  		c.errorHandler(w, r, err, &result)
   459  		return
   460  	}
   461  	// If no error, encode the body and the result code
   462  	EncodeJSONResponse(result.Body, &result.Code, w)
   463  
   464  }
   465  
   466  // DevstateContainerPost -
   467  func (c *DevstateApiController) DevstateContainerPost(w http.ResponseWriter, r *http.Request) {
   468  	devstateContainerPostRequestParam := DevstateContainerPostRequest{}
   469  	d := json.NewDecoder(r.Body)
   470  	d.DisallowUnknownFields()
   471  	if err := d.Decode(&devstateContainerPostRequestParam); err != nil {
   472  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   473  		return
   474  	}
   475  	if err := AssertDevstateContainerPostRequestRequired(devstateContainerPostRequestParam); err != nil {
   476  		c.errorHandler(w, r, err, nil)
   477  		return
   478  	}
   479  	result, err := c.service.DevstateContainerPost(r.Context(), devstateContainerPostRequestParam)
   480  	// If an error occurred, encode the error with the status code
   481  	if err != nil {
   482  		c.errorHandler(w, r, err, &result)
   483  		return
   484  	}
   485  	// If no error, encode the body and the result code
   486  	EncodeJSONResponse(result.Body, &result.Code, w)
   487  
   488  }
   489  
   490  // DevstateDevfileDelete -
   491  func (c *DevstateApiController) DevstateDevfileDelete(w http.ResponseWriter, r *http.Request) {
   492  	result, err := c.service.DevstateDevfileDelete(r.Context())
   493  	// If an error occurred, encode the error with the status code
   494  	if err != nil {
   495  		c.errorHandler(w, r, err, &result)
   496  		return
   497  	}
   498  	// If no error, encode the body and the result code
   499  	EncodeJSONResponse(result.Body, &result.Code, w)
   500  
   501  }
   502  
   503  // DevstateDevfileGet -
   504  func (c *DevstateApiController) DevstateDevfileGet(w http.ResponseWriter, r *http.Request) {
   505  	result, err := c.service.DevstateDevfileGet(r.Context())
   506  	// If an error occurred, encode the error with the status code
   507  	if err != nil {
   508  		c.errorHandler(w, r, err, &result)
   509  		return
   510  	}
   511  	// If no error, encode the body and the result code
   512  	EncodeJSONResponse(result.Body, &result.Code, w)
   513  
   514  }
   515  
   516  // DevstateDevfilePut -
   517  func (c *DevstateApiController) DevstateDevfilePut(w http.ResponseWriter, r *http.Request) {
   518  	devstateDevfilePutRequestParam := DevstateDevfilePutRequest{}
   519  	d := json.NewDecoder(r.Body)
   520  	d.DisallowUnknownFields()
   521  	if err := d.Decode(&devstateDevfilePutRequestParam); err != nil {
   522  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   523  		return
   524  	}
   525  	if err := AssertDevstateDevfilePutRequestRequired(devstateDevfilePutRequestParam); err != nil {
   526  		c.errorHandler(w, r, err, nil)
   527  		return
   528  	}
   529  	result, err := c.service.DevstateDevfilePut(r.Context(), devstateDevfilePutRequestParam)
   530  	// If an error occurred, encode the error with the status code
   531  	if err != nil {
   532  		c.errorHandler(w, r, err, &result)
   533  		return
   534  	}
   535  	// If no error, encode the body and the result code
   536  	EncodeJSONResponse(result.Body, &result.Code, w)
   537  
   538  }
   539  
   540  // DevstateEventsPut -
   541  func (c *DevstateApiController) DevstateEventsPut(w http.ResponseWriter, r *http.Request) {
   542  	devstateEventsPutRequestParam := DevstateEventsPutRequest{}
   543  	d := json.NewDecoder(r.Body)
   544  	d.DisallowUnknownFields()
   545  	if err := d.Decode(&devstateEventsPutRequestParam); err != nil {
   546  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   547  		return
   548  	}
   549  	if err := AssertDevstateEventsPutRequestRequired(devstateEventsPutRequestParam); err != nil {
   550  		c.errorHandler(w, r, err, nil)
   551  		return
   552  	}
   553  	result, err := c.service.DevstateEventsPut(r.Context(), devstateEventsPutRequestParam)
   554  	// If an error occurred, encode the error with the status code
   555  	if err != nil {
   556  		c.errorHandler(w, r, err, &result)
   557  		return
   558  	}
   559  	// If no error, encode the body and the result code
   560  	EncodeJSONResponse(result.Body, &result.Code, w)
   561  
   562  }
   563  
   564  // DevstateExecCommandCommandNamePatch -
   565  func (c *DevstateApiController) DevstateExecCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
   566  	params := mux.Vars(r)
   567  	commandNameParam := params["commandName"]
   568  	devstateExecCommandCommandNamePatchRequestParam := DevstateExecCommandCommandNamePatchRequest{}
   569  	d := json.NewDecoder(r.Body)
   570  	d.DisallowUnknownFields()
   571  	if err := d.Decode(&devstateExecCommandCommandNamePatchRequestParam); err != nil {
   572  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   573  		return
   574  	}
   575  	if err := AssertDevstateExecCommandCommandNamePatchRequestRequired(devstateExecCommandCommandNamePatchRequestParam); err != nil {
   576  		c.errorHandler(w, r, err, nil)
   577  		return
   578  	}
   579  	result, err := c.service.DevstateExecCommandCommandNamePatch(r.Context(), commandNameParam, devstateExecCommandCommandNamePatchRequestParam)
   580  	// If an error occurred, encode the error with the status code
   581  	if err != nil {
   582  		c.errorHandler(w, r, err, &result)
   583  		return
   584  	}
   585  	// If no error, encode the body and the result code
   586  	EncodeJSONResponse(result.Body, &result.Code, w)
   587  
   588  }
   589  
   590  // DevstateExecCommandPost -
   591  func (c *DevstateApiController) DevstateExecCommandPost(w http.ResponseWriter, r *http.Request) {
   592  	devstateExecCommandPostRequestParam := DevstateExecCommandPostRequest{}
   593  	d := json.NewDecoder(r.Body)
   594  	d.DisallowUnknownFields()
   595  	if err := d.Decode(&devstateExecCommandPostRequestParam); err != nil {
   596  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   597  		return
   598  	}
   599  	if err := AssertDevstateExecCommandPostRequestRequired(devstateExecCommandPostRequestParam); err != nil {
   600  		c.errorHandler(w, r, err, nil)
   601  		return
   602  	}
   603  	result, err := c.service.DevstateExecCommandPost(r.Context(), devstateExecCommandPostRequestParam)
   604  	// If an error occurred, encode the error with the status code
   605  	if err != nil {
   606  		c.errorHandler(w, r, err, &result)
   607  		return
   608  	}
   609  	// If no error, encode the body and the result code
   610  	EncodeJSONResponse(result.Body, &result.Code, w)
   611  
   612  }
   613  
   614  // DevstateImageImageNameDelete -
   615  func (c *DevstateApiController) DevstateImageImageNameDelete(w http.ResponseWriter, r *http.Request) {
   616  	params := mux.Vars(r)
   617  	imageNameParam := params["imageName"]
   618  	result, err := c.service.DevstateImageImageNameDelete(r.Context(), imageNameParam)
   619  	// If an error occurred, encode the error with the status code
   620  	if err != nil {
   621  		c.errorHandler(w, r, err, &result)
   622  		return
   623  	}
   624  	// If no error, encode the body and the result code
   625  	EncodeJSONResponse(result.Body, &result.Code, w)
   626  
   627  }
   628  
   629  // DevstateImageImageNamePatch -
   630  func (c *DevstateApiController) DevstateImageImageNamePatch(w http.ResponseWriter, r *http.Request) {
   631  	params := mux.Vars(r)
   632  	imageNameParam := params["imageName"]
   633  	devstateImageImageNamePatchRequestParam := DevstateImageImageNamePatchRequest{}
   634  	d := json.NewDecoder(r.Body)
   635  	d.DisallowUnknownFields()
   636  	if err := d.Decode(&devstateImageImageNamePatchRequestParam); err != nil {
   637  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   638  		return
   639  	}
   640  	if err := AssertDevstateImageImageNamePatchRequestRequired(devstateImageImageNamePatchRequestParam); err != nil {
   641  		c.errorHandler(w, r, err, nil)
   642  		return
   643  	}
   644  	result, err := c.service.DevstateImageImageNamePatch(r.Context(), imageNameParam, devstateImageImageNamePatchRequestParam)
   645  	// If an error occurred, encode the error with the status code
   646  	if err != nil {
   647  		c.errorHandler(w, r, err, &result)
   648  		return
   649  	}
   650  	// If no error, encode the body and the result code
   651  	EncodeJSONResponse(result.Body, &result.Code, w)
   652  
   653  }
   654  
   655  // DevstateImagePost -
   656  func (c *DevstateApiController) DevstateImagePost(w http.ResponseWriter, r *http.Request) {
   657  	devstateImagePostRequestParam := DevstateImagePostRequest{}
   658  	d := json.NewDecoder(r.Body)
   659  	d.DisallowUnknownFields()
   660  	if err := d.Decode(&devstateImagePostRequestParam); err != nil {
   661  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   662  		return
   663  	}
   664  	if err := AssertDevstateImagePostRequestRequired(devstateImagePostRequestParam); err != nil {
   665  		c.errorHandler(w, r, err, nil)
   666  		return
   667  	}
   668  	result, err := c.service.DevstateImagePost(r.Context(), devstateImagePostRequestParam)
   669  	// If an error occurred, encode the error with the status code
   670  	if err != nil {
   671  		c.errorHandler(w, r, err, &result)
   672  		return
   673  	}
   674  	// If no error, encode the body and the result code
   675  	EncodeJSONResponse(result.Body, &result.Code, w)
   676  
   677  }
   678  
   679  // DevstateMetadataPut -
   680  func (c *DevstateApiController) DevstateMetadataPut(w http.ResponseWriter, r *http.Request) {
   681  	metadataRequestParam := MetadataRequest{}
   682  	d := json.NewDecoder(r.Body)
   683  	d.DisallowUnknownFields()
   684  	if err := d.Decode(&metadataRequestParam); err != nil {
   685  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   686  		return
   687  	}
   688  	if err := AssertMetadataRequestRequired(metadataRequestParam); err != nil {
   689  		c.errorHandler(w, r, err, nil)
   690  		return
   691  	}
   692  	result, err := c.service.DevstateMetadataPut(r.Context(), metadataRequestParam)
   693  	// If an error occurred, encode the error with the status code
   694  	if err != nil {
   695  		c.errorHandler(w, r, err, &result)
   696  		return
   697  	}
   698  	// If no error, encode the body and the result code
   699  	EncodeJSONResponse(result.Body, &result.Code, w)
   700  
   701  }
   702  
   703  // DevstateQuantityValidPost -
   704  func (c *DevstateApiController) DevstateQuantityValidPost(w http.ResponseWriter, r *http.Request) {
   705  	devstateQuantityValidPostRequestParam := DevstateQuantityValidPostRequest{}
   706  	d := json.NewDecoder(r.Body)
   707  	d.DisallowUnknownFields()
   708  	if err := d.Decode(&devstateQuantityValidPostRequestParam); err != nil {
   709  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   710  		return
   711  	}
   712  	if err := AssertDevstateQuantityValidPostRequestRequired(devstateQuantityValidPostRequestParam); err != nil {
   713  		c.errorHandler(w, r, err, nil)
   714  		return
   715  	}
   716  	result, err := c.service.DevstateQuantityValidPost(r.Context(), devstateQuantityValidPostRequestParam)
   717  	// If an error occurred, encode the error with the status code
   718  	if err != nil {
   719  		c.errorHandler(w, r, err, &result)
   720  		return
   721  	}
   722  	// If no error, encode the body and the result code
   723  	EncodeJSONResponse(result.Body, &result.Code, w)
   724  
   725  }
   726  
   727  // DevstateResourcePost -
   728  func (c *DevstateApiController) DevstateResourcePost(w http.ResponseWriter, r *http.Request) {
   729  	devstateResourcePostRequestParam := DevstateResourcePostRequest{}
   730  	d := json.NewDecoder(r.Body)
   731  	d.DisallowUnknownFields()
   732  	if err := d.Decode(&devstateResourcePostRequestParam); err != nil {
   733  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   734  		return
   735  	}
   736  	if err := AssertDevstateResourcePostRequestRequired(devstateResourcePostRequestParam); err != nil {
   737  		c.errorHandler(w, r, err, nil)
   738  		return
   739  	}
   740  	result, err := c.service.DevstateResourcePost(r.Context(), devstateResourcePostRequestParam)
   741  	// If an error occurred, encode the error with the status code
   742  	if err != nil {
   743  		c.errorHandler(w, r, err, &result)
   744  		return
   745  	}
   746  	// If no error, encode the body and the result code
   747  	EncodeJSONResponse(result.Body, &result.Code, w)
   748  
   749  }
   750  
   751  // DevstateResourceResourceNameDelete -
   752  func (c *DevstateApiController) DevstateResourceResourceNameDelete(w http.ResponseWriter, r *http.Request) {
   753  	params := mux.Vars(r)
   754  	resourceNameParam := params["resourceName"]
   755  	result, err := c.service.DevstateResourceResourceNameDelete(r.Context(), resourceNameParam)
   756  	// If an error occurred, encode the error with the status code
   757  	if err != nil {
   758  		c.errorHandler(w, r, err, &result)
   759  		return
   760  	}
   761  	// If no error, encode the body and the result code
   762  	EncodeJSONResponse(result.Body, &result.Code, w)
   763  
   764  }
   765  
   766  // DevstateResourceResourceNamePatch -
   767  func (c *DevstateApiController) DevstateResourceResourceNamePatch(w http.ResponseWriter, r *http.Request) {
   768  	params := mux.Vars(r)
   769  	resourceNameParam := params["resourceName"]
   770  	devstateResourceResourceNamePatchRequestParam := DevstateResourceResourceNamePatchRequest{}
   771  	d := json.NewDecoder(r.Body)
   772  	d.DisallowUnknownFields()
   773  	if err := d.Decode(&devstateResourceResourceNamePatchRequestParam); err != nil {
   774  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   775  		return
   776  	}
   777  	if err := AssertDevstateResourceResourceNamePatchRequestRequired(devstateResourceResourceNamePatchRequestParam); err != nil {
   778  		c.errorHandler(w, r, err, nil)
   779  		return
   780  	}
   781  	result, err := c.service.DevstateResourceResourceNamePatch(r.Context(), resourceNameParam, devstateResourceResourceNamePatchRequestParam)
   782  	// If an error occurred, encode the error with the status code
   783  	if err != nil {
   784  		c.errorHandler(w, r, err, &result)
   785  		return
   786  	}
   787  	// If no error, encode the body and the result code
   788  	EncodeJSONResponse(result.Body, &result.Code, w)
   789  
   790  }
   791  
   792  // DevstateVolumePost -
   793  func (c *DevstateApiController) DevstateVolumePost(w http.ResponseWriter, r *http.Request) {
   794  	devstateVolumePostRequestParam := DevstateVolumePostRequest{}
   795  	d := json.NewDecoder(r.Body)
   796  	d.DisallowUnknownFields()
   797  	if err := d.Decode(&devstateVolumePostRequestParam); err != nil {
   798  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   799  		return
   800  	}
   801  	if err := AssertDevstateVolumePostRequestRequired(devstateVolumePostRequestParam); err != nil {
   802  		c.errorHandler(w, r, err, nil)
   803  		return
   804  	}
   805  	result, err := c.service.DevstateVolumePost(r.Context(), devstateVolumePostRequestParam)
   806  	// If an error occurred, encode the error with the status code
   807  	if err != nil {
   808  		c.errorHandler(w, r, err, &result)
   809  		return
   810  	}
   811  	// If no error, encode the body and the result code
   812  	EncodeJSONResponse(result.Body, &result.Code, w)
   813  
   814  }
   815  
   816  // DevstateVolumeVolumeNameDelete -
   817  func (c *DevstateApiController) DevstateVolumeVolumeNameDelete(w http.ResponseWriter, r *http.Request) {
   818  	params := mux.Vars(r)
   819  	volumeNameParam := params["volumeName"]
   820  	result, err := c.service.DevstateVolumeVolumeNameDelete(r.Context(), volumeNameParam)
   821  	// If an error occurred, encode the error with the status code
   822  	if err != nil {
   823  		c.errorHandler(w, r, err, &result)
   824  		return
   825  	}
   826  	// If no error, encode the body and the result code
   827  	EncodeJSONResponse(result.Body, &result.Code, w)
   828  
   829  }
   830  
   831  // DevstateVolumeVolumeNamePatch -
   832  func (c *DevstateApiController) DevstateVolumeVolumeNamePatch(w http.ResponseWriter, r *http.Request) {
   833  	params := mux.Vars(r)
   834  	volumeNameParam := params["volumeName"]
   835  	devstateVolumeVolumeNamePatchRequestParam := DevstateVolumeVolumeNamePatchRequest{}
   836  	d := json.NewDecoder(r.Body)
   837  	d.DisallowUnknownFields()
   838  	if err := d.Decode(&devstateVolumeVolumeNamePatchRequestParam); err != nil {
   839  		c.errorHandler(w, r, &ParsingError{Err: err}, nil)
   840  		return
   841  	}
   842  	if err := AssertDevstateVolumeVolumeNamePatchRequestRequired(devstateVolumeVolumeNamePatchRequestParam); err != nil {
   843  		c.errorHandler(w, r, err, nil)
   844  		return
   845  	}
   846  	result, err := c.service.DevstateVolumeVolumeNamePatch(r.Context(), volumeNameParam, devstateVolumeVolumeNamePatchRequestParam)
   847  	// If an error occurred, encode the error with the status code
   848  	if err != nil {
   849  		c.errorHandler(w, r, err, &result)
   850  		return
   851  	}
   852  	// If no error, encode the body and the result code
   853  	EncodeJSONResponse(result.Body, &result.Code, w)
   854  
   855  }
   856  

View as plain text