Skip to content

Commit

Permalink
feat: Add support for 'show controller-date' and use it for session v…
Browse files Browse the repository at this point in the history
…alidation

Use show controller-date for session validity check. Also marks SessionValid
as a deprecated function call with the expectation that it will be made
redundant through future addition of retry logic
  • Loading branch information
David-T-White committed Jan 19, 2024
1 parent 37d0fcd commit 0a088ba
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ The following table provides a list of all possible MC API commands and which on
| `show ciphers` | | not supported |
| `show cli-parameters` | | not supported |
| `show configuration` | | not supported |
| `show controller-date` | | not supported |
| `show controller-date` | | supported |
| `show controller-statistics` | | not supported |
| `show controllers` | supported | |
| `show debug-log-parameters` | | not supported |
Expand Down
18 changes: 18 additions & 0 deletions api/mc-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/statusObject'
# /show/controller-date
/show/controller-date:
get:
description: Execute /show/controller-date command
operationId: ShowController-DateGet
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/statusObject'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/statusObject'
# /show/volumes
/show/volumes/{namesOption}:
get:
Expand Down
5 changes: 5 additions & 0 deletions internal/generator/mc-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ commands:
meta: fan
include:
- status

- command: /show/controller-date
meta: status
include:
- status

- command: /show/volumes
meta: volumes
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/mcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func (client *Client) Logout() error {
}

// SessionValid : Determine if a session is valid, if not a login is required
// Makes the 'show controller-date' API call to validate the session is still valid
//
// Deprecated: This function will be made redundant by retry logic in a future update
func (client *Client) SessionValid(addr, username string) bool {
if client.Ctx == nil {
return false
Expand All @@ -108,7 +111,7 @@ func (client *Client) SessionValid(addr, username string) bool {
}

//run an API call to test that the session is still valid
_, _, err := client.apiClient.DefaultApi.ShowSystemGet(client.Ctx).Execute()
_, _, err := client.apiClient.DefaultApi.ShowControllerDateGet(client.Ctx).Execute()
return err == nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description
*DefaultApi* | [**ShowAdvancedSettingsGet**](docs/DefaultApi.md#showadvancedsettingsget) | **Get** /show/advanced-settings |
*DefaultApi* | [**ShowCacheParametersGet**](docs/DefaultApi.md#showcacheparametersget) | **Get** /show/cache-parameters |
*DefaultApi* | [**ShowCertificateGet**](docs/DefaultApi.md#showcertificateget) | **Get** /show/certificate |
*DefaultApi* | [**ShowControllerDateGet**](docs/DefaultApi.md#showcontrollerdateget) | **Get** /show/controller-date |
*DefaultApi* | [**ShowControllersGet**](docs/DefaultApi.md#showcontrollersget) | **Get** /show/controllers |
*DefaultApi* | [**ShowDiskGroupsGet**](docs/DefaultApi.md#showdiskgroupsget) | **Get** /show/disk-groups |
*DefaultApi* | [**ShowDisksGet**](docs/DefaultApi.md#showdisksget) | **Get** /show/disks |
Expand Down
17 changes: 17 additions & 0 deletions pkg/client/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ paths:
schema:
$ref: '#/components/schemas/statusObject'
description: Unauthorized
/show/controller-date:
get:
description: Execute /show/controller-date command
operationId: ShowController-DateGet
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/statusObject'
description: OK
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/statusObject'
description: Unauthorized
/show/volumes/{namesOption}:
get:
description: Execute /show/volumes command
Expand Down
110 changes: 110 additions & 0 deletions pkg/client/api_default.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions pkg/client/docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Method | HTTP request | Description
[**ShowAdvancedSettingsGet**](DefaultApi.md#ShowAdvancedSettingsGet) | **Get** /show/advanced-settings |
[**ShowCacheParametersGet**](DefaultApi.md#ShowCacheParametersGet) | **Get** /show/cache-parameters |
[**ShowCertificateGet**](DefaultApi.md#ShowCertificateGet) | **Get** /show/certificate |
[**ShowControllerDateGet**](DefaultApi.md#ShowControllerDateGet) | **Get** /show/controller-date |
[**ShowControllersGet**](DefaultApi.md#ShowControllersGet) | **Get** /show/controllers |
[**ShowDiskGroupsGet**](DefaultApi.md#ShowDiskGroupsGet) | **Get** /show/disk-groups |
[**ShowDisksGet**](DefaultApi.md#ShowDisksGet) | **Get** /show/disks |
Expand Down Expand Up @@ -1154,6 +1155,67 @@ Other parameters are passed through a pointer to a apiShowCertificateGetRequest
[[Back to README]](../README.md)


## ShowControllerDateGet

> StatusObject ShowControllerDateGet(ctx).Execute()




### Example

```go
package main

import (
"context"
"fmt"
"os"
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
)

func main() {

configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.DefaultApi.ShowControllerDateGet(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.ShowControllerDateGet``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `ShowControllerDateGet`: StatusObject
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.ShowControllerDateGet`: %v\n", resp)
}
```

### Path Parameters

This endpoint does not need any parameter.

### Other Parameters

Other parameters are passed through a pointer to a apiShowControllerDateGetRequest struct via the builder pattern


### Return type

[**StatusObject**](StatusObject.md)

### Authorization

[basicAuth](../README.md#basicAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **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)


## ShowControllersGet

> ControllersObject ShowControllersGet(ctx).Execute()
Expand Down
12 changes: 12 additions & 0 deletions pkg/client/test/api_default_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/regression/v2_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = DescribeRegression("Login Testing (v2)", func(tc *TestContext) {
It("should be able to log out of the storage controller", func() {
err := client.Logout()
logger := klog.FromContext(tc.Config.Ctx)
logger.V(3).Info("Login", "ip", client.Addr, "username", client.Username, "err", err)
logger.V(3).Info("Logout", "ip", client.Addr, "username", client.Username, "err", err)
Expect(err).To(BeNil())
})

Expand Down

0 comments on commit 0a088ba

Please sign in to comment.