From 470a7752c62db055c8d9cd148e9c4775feca8b62 Mon Sep 17 00:00:00 2001 From: James Gu Date: Thu, 25 Aug 2022 19:08:52 +0000 Subject: [PATCH] Add iDrac reset api Change-Id: Iec4e59341fd8a976b6aeda30d0671839643b04bf --- client/.openapi-generator/FILES | 4 + client/README.md | 3 + client/api/openapi.yaml | 29 ++++++ client/api_default.go | 107 +++++++++++++++++++++ client/docs/DefaultApi.md | 63 +++++++++++++ client/docs/IDRACResetRequestBody.md | 56 +++++++++++ client/docs/IDRACResetType.md | 11 +++ client/model_idrac_reset_request_body.go | 115 +++++++++++++++++++++++ client/model_idrac_reset_type.go | 83 ++++++++++++++++ spec/openapi.yaml | 29 ++++++ 10 files changed, 500 insertions(+) create mode 100644 client/docs/IDRACResetRequestBody.md create mode 100644 client/docs/IDRACResetType.md create mode 100644 client/model_idrac_reset_request_body.go create mode 100644 client/model_idrac_reset_type.go diff --git a/client/.openapi-generator/FILES b/client/.openapi-generator/FILES index 401cdfa..1a1f414 100644 --- a/client/.openapi-generator/FILES +++ b/client/.openapi-generator/FILES @@ -18,6 +18,8 @@ docs/CreateVirtualDiskRequestBody.md docs/DefaultApi.md docs/FirmwareInventory.md docs/Health.md +docs/IDRACResetRequestBody.md +docs/IDRACResetType.md docs/IdRef.md docs/IndicatorLED.md docs/InlineObject.md @@ -65,6 +67,8 @@ model_create_virtual_disk_request_body.go model_firmware_inventory.go model_health.go model_id_ref.go +model_idrac_reset_request_body.go +model_idrac_reset_type.go model_indicator_led.go model_inline_object.go model_insert_media_request_body.go diff --git a/client/README.md b/client/README.md index 93a56aa..a3917b2 100644 --- a/client/README.md +++ b/client/README.md @@ -95,6 +95,7 @@ Class | Method | HTTP request | Description *DefaultApi* | [**ListManagerVirtualMedia**](docs/DefaultApi.md#listmanagervirtualmedia) | **Get** /redfish/v1/Managers/{managerId}/VirtualMedia | *DefaultApi* | [**ListManagers**](docs/DefaultApi.md#listmanagers) | **Get** /redfish/v1/Managers | *DefaultApi* | [**ListSystems**](docs/DefaultApi.md#listsystems) | **Get** /redfish/v1/Systems | +*DefaultApi* | [**ResetIdrac**](docs/DefaultApi.md#resetidrac) | **Post** /redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset | *DefaultApi* | [**ResetSystem**](docs/DefaultApi.md#resetsystem) | **Post** /redfish/v1/Systems/{ComputerSystemId}/Actions/ComputerSystem.Reset | *DefaultApi* | [**SetSystem**](docs/DefaultApi.md#setsystem) | **Patch** /redfish/v1/Systems/{systemId} | *DefaultApi* | [**UpdateService**](docs/DefaultApi.md#updateservice) | **Get** /redfish/v1/UpdateService | @@ -114,6 +115,8 @@ Class | Method | HTTP request | Description - [CreateVirtualDiskRequestBody](docs/CreateVirtualDiskRequestBody.md) - [FirmwareInventory](docs/FirmwareInventory.md) - [Health](docs/Health.md) + - [IDRACResetRequestBody](docs/IDRACResetRequestBody.md) + - [IDRACResetType](docs/IDRACResetType.md) - [IdRef](docs/IdRef.md) - [IndicatorLED](docs/IndicatorLED.md) - [InlineObject](docs/InlineObject.md) diff --git a/client/api/openapi.yaml b/client/api/openapi.yaml index 2d4a3e4..94ba6f2 100644 --- a/client/api/openapi.yaml +++ b/client/api/openapi.yaml @@ -525,6 +525,24 @@ paths: schema: $ref: '#/components/schemas/RedfishError' description: Error condition + /redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset: + post: + operationId: reset_idrac + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IDRACResetRequestBody' + required: true + responses: + "204": + description: Success, but no response data + default: + content: + application/json: + schema: + $ref: '#/components/schemas/RedfishError' + description: Error condition components: requestBodies: inline_object: @@ -598,6 +616,10 @@ components: - PushPowerButton - PowerCycle type: string + IDRACResetType: + enum: + - GracefulRestart + type: string IndicatorLED: enum: - Unknown @@ -1007,6 +1029,13 @@ components: ResetType: $ref: '#/components/schemas/ResetType' type: object + IDRACResetRequestBody: + additionalProperties: false + example: {} + properties: + ResetType: + $ref: '#/components/schemas/IDRACResetType' + type: object ComputerSystem: additionalProperties: false description: Root redfish path. diff --git a/client/api_default.go b/client/api_default.go index d6fc1fd..fa8f8ae 100644 --- a/client/api_default.go +++ b/client/api_default.go @@ -1932,6 +1932,113 @@ func (a *DefaultApiService) ListSystemsExecute(r ApiListSystemsRequest) (Collect return localVarReturnValue, localVarHTTPResponse, nil } +type ApiResetIdracRequest struct { + ctx _context.Context + ApiService *DefaultApiService + iDRACResetRequestBody *IDRACResetRequestBody +} + +func (r ApiResetIdracRequest) IDRACResetRequestBody(iDRACResetRequestBody IDRACResetRequestBody) ApiResetIdracRequest { + r.iDRACResetRequestBody = &iDRACResetRequestBody + return r +} + +func (r ApiResetIdracRequest) Execute() (*_nethttp.Response, error) { + return r.ApiService.ResetIdracExecute(r) +} + +/* + * ResetIdrac Method for ResetIdrac + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiResetIdracRequest + */ +func (a *DefaultApiService) ResetIdrac(ctx _context.Context) ApiResetIdracRequest { + return ApiResetIdracRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + */ +func (a *DefaultApiService) ResetIdracExecute(r ApiResetIdracRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ResetIdrac") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.iDRACResetRequestBody == nil { + return nil, reportError("iDRACResetRequestBody is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.iDRACResetRequestBody + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v RedfishError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.model = v + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + type ApiResetSystemRequest struct { ctx _context.Context ApiService *DefaultApiService diff --git a/client/docs/DefaultApi.md b/client/docs/DefaultApi.md index 09ada52..e71f59f 100644 --- a/client/docs/DefaultApi.md +++ b/client/docs/DefaultApi.md @@ -21,6 +21,7 @@ Method | HTTP request | Description [**ListManagerVirtualMedia**](DefaultApi.md#ListManagerVirtualMedia) | **Get** /redfish/v1/Managers/{managerId}/VirtualMedia | [**ListManagers**](DefaultApi.md#ListManagers) | **Get** /redfish/v1/Managers | [**ListSystems**](DefaultApi.md#ListSystems) | **Get** /redfish/v1/Systems | +[**ResetIdrac**](DefaultApi.md#ResetIdrac) | **Post** /redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset | [**ResetSystem**](DefaultApi.md#ResetSystem) | **Post** /redfish/v1/Systems/{ComputerSystemId}/Actions/ComputerSystem.Reset | [**SetSystem**](DefaultApi.md#SetSystem) | **Patch** /redfish/v1/Systems/{systemId} | [**UpdateService**](DefaultApi.md#UpdateService) | **Get** /redfish/v1/UpdateService | @@ -1157,6 +1158,68 @@ No authorization required [[Back to README]](../README.md) +## ResetIdrac + +> ResetIdrac(ctx).IDRACResetRequestBody(iDRACResetRequestBody).Execute() + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + iDRACResetRequestBody := *openapiclient.NewIDRACResetRequestBody() // IDRACResetRequestBody | + + configuration := openapiclient.NewConfiguration() + api_client := openapiclient.NewAPIClient(configuration) + resp, r, err := api_client.DefaultApi.ResetIdrac(context.Background()).IDRACResetRequestBody(iDRACResetRequestBody).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.ResetIdrac``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiResetIdracRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **iDRACResetRequestBody** | [**IDRACResetRequestBody**](IDRACResetRequestBody.md) | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## ResetSystem > RedfishError ResetSystem(ctx, computerSystemId).ResetRequestBody(resetRequestBody).Execute() diff --git a/client/docs/IDRACResetRequestBody.md b/client/docs/IDRACResetRequestBody.md new file mode 100644 index 0000000..61b86a7 --- /dev/null +++ b/client/docs/IDRACResetRequestBody.md @@ -0,0 +1,56 @@ +# IDRACResetRequestBody + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ResetType** | Pointer to [**IDRACResetType**](IDRACResetType.md) | | [optional] + +## Methods + +### NewIDRACResetRequestBody + +`func NewIDRACResetRequestBody() *IDRACResetRequestBody` + +NewIDRACResetRequestBody instantiates a new IDRACResetRequestBody object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewIDRACResetRequestBodyWithDefaults + +`func NewIDRACResetRequestBodyWithDefaults() *IDRACResetRequestBody` + +NewIDRACResetRequestBodyWithDefaults instantiates a new IDRACResetRequestBody object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetResetType + +`func (o *IDRACResetRequestBody) GetResetType() IDRACResetType` + +GetResetType returns the ResetType field if non-nil, zero value otherwise. + +### GetResetTypeOk + +`func (o *IDRACResetRequestBody) GetResetTypeOk() (*IDRACResetType, bool)` + +GetResetTypeOk returns a tuple with the ResetType field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetResetType + +`func (o *IDRACResetRequestBody) SetResetType(v IDRACResetType)` + +SetResetType sets ResetType field to given value. + +### HasResetType + +`func (o *IDRACResetRequestBody) HasResetType() bool` + +HasResetType returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client/docs/IDRACResetType.md b/client/docs/IDRACResetType.md new file mode 100644 index 0000000..5e82cfe --- /dev/null +++ b/client/docs/IDRACResetType.md @@ -0,0 +1,11 @@ +# IDRACResetType + +## Enum + + +* `GRACEFUL_RESTART` (value: `"GracefulRestart"`) + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client/model_idrac_reset_request_body.go b/client/model_idrac_reset_request_body.go new file mode 100644 index 0000000..ed855e4 --- /dev/null +++ b/client/model_idrac_reset_request_body.go @@ -0,0 +1,115 @@ +/* + * Redfish OAPI specification + * + * Partial Redfish OAPI specification for a limited client + * + * API version: 0.0.1 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" +) + +// IDRACResetRequestBody struct for IDRACResetRequestBody +type IDRACResetRequestBody struct { + ResetType *IDRACResetType `json:"ResetType,omitempty"` +} + +// NewIDRACResetRequestBody instantiates a new IDRACResetRequestBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewIDRACResetRequestBody() *IDRACResetRequestBody { + this := IDRACResetRequestBody{} + return &this +} + +// NewIDRACResetRequestBodyWithDefaults instantiates a new IDRACResetRequestBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewIDRACResetRequestBodyWithDefaults() *IDRACResetRequestBody { + this := IDRACResetRequestBody{} + return &this +} + +// GetResetType returns the ResetType field value if set, zero value otherwise. +func (o *IDRACResetRequestBody) GetResetType() IDRACResetType { + if o == nil || o.ResetType == nil { + var ret IDRACResetType + return ret + } + return *o.ResetType +} + +// GetResetTypeOk returns a tuple with the ResetType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IDRACResetRequestBody) GetResetTypeOk() (*IDRACResetType, bool) { + if o == nil || o.ResetType == nil { + return nil, false + } + return o.ResetType, true +} + +// HasResetType returns a boolean if a field has been set. +func (o *IDRACResetRequestBody) HasResetType() bool { + if o != nil && o.ResetType != nil { + return true + } + + return false +} + +// SetResetType gets a reference to the given IDRACResetType and assigns it to the ResetType field. +func (o *IDRACResetRequestBody) SetResetType(v IDRACResetType) { + o.ResetType = &v +} + +func (o IDRACResetRequestBody) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.ResetType != nil { + toSerialize["ResetType"] = o.ResetType + } + return json.Marshal(toSerialize) +} + +type NullableIDRACResetRequestBody struct { + value *IDRACResetRequestBody + isSet bool +} + +func (v NullableIDRACResetRequestBody) Get() *IDRACResetRequestBody { + return v.value +} + +func (v *NullableIDRACResetRequestBody) Set(val *IDRACResetRequestBody) { + v.value = val + v.isSet = true +} + +func (v NullableIDRACResetRequestBody) IsSet() bool { + return v.isSet +} + +func (v *NullableIDRACResetRequestBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIDRACResetRequestBody(val *IDRACResetRequestBody) *NullableIDRACResetRequestBody { + return &NullableIDRACResetRequestBody{value: val, isSet: true} +} + +func (v NullableIDRACResetRequestBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIDRACResetRequestBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/client/model_idrac_reset_type.go b/client/model_idrac_reset_type.go new file mode 100644 index 0000000..65b88e7 --- /dev/null +++ b/client/model_idrac_reset_type.go @@ -0,0 +1,83 @@ +/* + * Redfish OAPI specification + * + * Partial Redfish OAPI specification for a limited client + * + * API version: 0.0.1 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" + "fmt" +) + +// IDRACResetType the model 'IDRACResetType' +type IDRACResetType string + +// List of IDRACResetType +const ( + IDRACRESETTYPE_GRACEFUL_RESTART IDRACResetType = "GracefulRestart" +) + +func (v *IDRACResetType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := IDRACResetType(value) + for _, existing := range []IDRACResetType{ "GracefulRestart", } { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid IDRACResetType", value) +} + +// Ptr returns reference to IDRACResetType value +func (v IDRACResetType) Ptr() *IDRACResetType { + return &v +} + +type NullableIDRACResetType struct { + value *IDRACResetType + isSet bool +} + +func (v NullableIDRACResetType) Get() *IDRACResetType { + return v.value +} + +func (v *NullableIDRACResetType) Set(val *IDRACResetType) { + v.value = val + v.isSet = true +} + +func (v NullableIDRACResetType) IsSet() bool { + return v.isSet +} + +func (v *NullableIDRACResetType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIDRACResetType(val *IDRACResetType) *NullableIDRACResetType { + return &NullableIDRACResetType{value: val, isSet: true} +} + +func (v NullableIDRACResetType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIDRACResetType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + diff --git a/spec/openapi.yaml b/spec/openapi.yaml index 2ff6bf1..06ac013 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -524,6 +524,24 @@ paths: schema: $ref: '#/components/schemas/RedfishError' description: Error condition + /redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset: + post: + operationId: reset_idrac + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IDRACResetRequestBody' + required: true + responses: + 204: + description: Success, but no response data + default: + content: + application/json: + schema: + $ref: '#/components/schemas/RedfishError' + description: Error condition components: schemas: BootSource: @@ -590,6 +608,10 @@ components: - PushPowerButton - PowerCycle type: string + IDRACResetType: + enum: + - GracefulRestart + type: string IndicatorLED: enum: - Unknown @@ -999,6 +1021,13 @@ components: ResetType: $ref: '#/components/schemas/ResetType' type: object + IDRACResetRequestBody: + additionalProperties: false + example: {} + properties: + ResetType: + $ref: '#/components/schemas/IDRACResetType' + type: object ComputerSystem: additionalProperties: false description: Root redfish path.