Skip to content

Commit

Permalink
feat: fill in spec for MFA endpoints based on packngo implementation (#…
Browse files Browse the repository at this point in the history
…25)

Conversion of [`metal-cli` 2-factor auth
subcommands](equinix/metal-cli#353) from
`packngo` to `equinix-sdk-go` is blocked because the Equinix Metal
OpenAPI spec is missing many details for MFA setup and validation.

This works around the API issue by patching the local SDK spec to fill
in the missing MFA details. These patches were written based on the
[`packngo` MFA
implementation](https://github.com/packethost/packngo/blob/f8b3f36ba929a29d4f1d29480e0f47c7f85790e4/two_factor_auth.go).
  • Loading branch information
displague committed Jan 22, 2024
2 parents 4cff3b0 + 6b3cbf3 commit 19f2982
Show file tree
Hide file tree
Showing 15 changed files with 693 additions and 12 deletions.
2 changes: 2 additions & 0 deletions services/metalv1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ Class | Method | HTTP request | Description
*OTPsApi* | [**FindRecoveryCodes**](docs/OTPsApi.md#findrecoverycodes) | **Get** /user/otp/recovery-codes | Retrieve my recovery codes
*OTPsApi* | [**ReceiveCodes**](docs/OTPsApi.md#receivecodes) | **Post** /user/otp/sms/receive | Receive an OTP per sms
*OTPsApi* | [**RegenerateCodes**](docs/OTPsApi.md#regeneratecodes) | **Post** /user/otp/recovery-codes | Generate new recovery codes
*OTPsApi* | [**SeedApp**](docs/OTPsApi.md#seedapp) | **Post** /user/otp/app/receive | Issue OTP seeds
*OperatingSystemsApi* | [**FindOperatingSystemVersion**](docs/OperatingSystemsApi.md#findoperatingsystemversion) | **Get** /operating-system-versions | Retrieve all operating system versions
*OperatingSystemsApi* | [**FindOperatingSystems**](docs/OperatingSystemsApi.md#findoperatingsystems) | **Get** /operating-systems | Retrieve all operating systems
*OrganizationsApi* | [**CreateOrganization**](docs/OrganizationsApi.md#createorganization) | **Post** /organizations | Create an organization
Expand Down Expand Up @@ -554,6 +555,7 @@ Class | Method | HTTP request | Description
- [Organization](docs/Organization.md)
- [OrganizationInput](docs/OrganizationInput.md)
- [OrganizationList](docs/OrganizationList.md)
- [OtpSeed](docs/OtpSeed.md)
- [ParentBlock](docs/ParentBlock.md)
- [Partition](docs/Partition.md)
- [PaymentMethod](docs/PaymentMethod.md)
Expand Down
157 changes: 157 additions & 0 deletions services/metalv1/api_otps.go

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

40 changes: 40 additions & 0 deletions services/metalv1/api_two_factor_auth.go

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

62 changes: 62 additions & 0 deletions services/metalv1/docs/OTPsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Method | HTTP request | Description
[**FindRecoveryCodes**](OTPsApi.md#FindRecoveryCodes) | **Get** /user/otp/recovery-codes | Retrieve my recovery codes
[**ReceiveCodes**](OTPsApi.md#ReceiveCodes) | **Post** /user/otp/sms/receive | Receive an OTP per sms
[**RegenerateCodes**](OTPsApi.md#RegenerateCodes) | **Post** /user/otp/recovery-codes | Generate new recovery codes
[**SeedApp**](OTPsApi.md#SeedApp) | **Post** /user/otp/app/receive | Issue OTP seeds



Expand Down Expand Up @@ -259,3 +260,64 @@ Other parameters are passed through a pointer to a apiRegenerateCodesRequest str
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## SeedApp

> OtpSeed SeedApp(ctx).Execute()
Issue OTP seeds



### Example

```go
package main

import (
"context"
"fmt"
"os"
openapiclient "github.com/equinix/equinix-sdk-go/services/metalv1"
)

func main() {

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

### Path Parameters

This endpoint does not need any parameter.

### Other Parameters

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


### Return type

[**OtpSeed**](OtpSeed.md)

### Authorization

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

### 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)

Loading

0 comments on commit 19f2982

Please sign in to comment.