diff --git a/services/metalv1/README.md b/services/metalv1/README.md index c4598f57..de56ce1f 100644 --- a/services/metalv1/README.md +++ b/services/metalv1/README.md @@ -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 @@ -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) diff --git a/services/metalv1/api_otps.go b/services/metalv1/api_otps.go index d0456492..940292f1 100644 --- a/services/metalv1/api_otps.go +++ b/services/metalv1/api_otps.go @@ -586,3 +586,160 @@ func (a *OTPsApiService) RegenerateCodesExecute(r ApiRegenerateCodesRequest) (*R return localVarReturnValue, localVarHTTPResponse, nil } + +type ApiSeedAppRequest struct { + ctx context.Context + ApiService *OTPsApiService +} + +func (r ApiSeedAppRequest) Execute() (*OtpSeed, *http.Response, error) { + return r.ApiService.SeedAppExecute(r) +} + +/* +SeedApp Issue OTP seeds + +Issues OTP seeds for the user to upload to their 2FA app + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiSeedAppRequest +*/ +func (a *OTPsApiService) SeedApp(ctx context.Context) ApiSeedAppRequest { + return ApiSeedAppRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return OtpSeed +func (a *OTPsApiService) SeedAppExecute(r ApiSeedAppRequest) (*OtpSeed, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *OtpSeed + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OTPsApiService.SeedApp") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/user/otp/app/receive" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["x_auth_token"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["X-Auth-Token"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 422 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/services/metalv1/api_two_factor_auth.go b/services/metalv1/api_two_factor_auth.go index bbe38581..e728c58f 100644 --- a/services/metalv1/api_two_factor_auth.go +++ b/services/metalv1/api_two_factor_auth.go @@ -25,6 +25,12 @@ type TwoFactorAuthApiService service type ApiDisableTfaAppRequest struct { ctx context.Context ApiService *TwoFactorAuthApiService + xOtpToken *string +} + +func (r ApiDisableTfaAppRequest) XOtpToken(xOtpToken string) ApiDisableTfaAppRequest { + r.xOtpToken = &xOtpToken + return r } func (r ApiDisableTfaAppRequest) Execute() (*http.Response, error) { @@ -64,6 +70,9 @@ func (a *TwoFactorAuthApiService) DisableTfaAppExecute(r ApiDisableTfaAppRequest localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.xOtpToken == nil { + return nil, reportError("xOtpToken is required and must be specified") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -82,6 +91,7 @@ func (a *TwoFactorAuthApiService) DisableTfaAppExecute(r ApiDisableTfaAppRequest if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + parameterAddToHeaderOrQuery(localVarHeaderParams, "x-otp-token", r.xOtpToken, "") if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { @@ -148,6 +158,12 @@ func (a *TwoFactorAuthApiService) DisableTfaAppExecute(r ApiDisableTfaAppRequest type ApiDisableTfaSmsRequest struct { ctx context.Context ApiService *TwoFactorAuthApiService + xOtpToken *string +} + +func (r ApiDisableTfaSmsRequest) XOtpToken(xOtpToken string) ApiDisableTfaSmsRequest { + r.xOtpToken = &xOtpToken + return r } func (r ApiDisableTfaSmsRequest) Execute() (*http.Response, error) { @@ -187,6 +203,9 @@ func (a *TwoFactorAuthApiService) DisableTfaSmsExecute(r ApiDisableTfaSmsRequest localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.xOtpToken == nil { + return nil, reportError("xOtpToken is required and must be specified") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -205,6 +224,7 @@ func (a *TwoFactorAuthApiService) DisableTfaSmsExecute(r ApiDisableTfaSmsRequest if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + parameterAddToHeaderOrQuery(localVarHeaderParams, "x-otp-token", r.xOtpToken, "") if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { @@ -271,6 +291,12 @@ func (a *TwoFactorAuthApiService) DisableTfaSmsExecute(r ApiDisableTfaSmsRequest type ApiEnableTfaAppRequest struct { ctx context.Context ApiService *TwoFactorAuthApiService + xOtpToken *string +} + +func (r ApiEnableTfaAppRequest) XOtpToken(xOtpToken string) ApiEnableTfaAppRequest { + r.xOtpToken = &xOtpToken + return r } func (r ApiEnableTfaAppRequest) Execute() (*http.Response, error) { @@ -310,6 +336,9 @@ func (a *TwoFactorAuthApiService) EnableTfaAppExecute(r ApiEnableTfaAppRequest) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.xOtpToken == nil { + return nil, reportError("xOtpToken is required and must be specified") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -328,6 +357,7 @@ func (a *TwoFactorAuthApiService) EnableTfaAppExecute(r ApiEnableTfaAppRequest) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + parameterAddToHeaderOrQuery(localVarHeaderParams, "x-otp-token", r.xOtpToken, "") if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { @@ -383,6 +413,12 @@ func (a *TwoFactorAuthApiService) EnableTfaAppExecute(r ApiEnableTfaAppRequest) type ApiEnableTfaSmsRequest struct { ctx context.Context ApiService *TwoFactorAuthApiService + xOtpToken *string +} + +func (r ApiEnableTfaSmsRequest) XOtpToken(xOtpToken string) ApiEnableTfaSmsRequest { + r.xOtpToken = &xOtpToken + return r } func (r ApiEnableTfaSmsRequest) Execute() (*http.Response, error) { @@ -422,6 +458,9 @@ func (a *TwoFactorAuthApiService) EnableTfaSmsExecute(r ApiEnableTfaSmsRequest) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.xOtpToken == nil { + return nil, reportError("xOtpToken is required and must be specified") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -440,6 +479,7 @@ func (a *TwoFactorAuthApiService) EnableTfaSmsExecute(r ApiEnableTfaSmsRequest) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + parameterAddToHeaderOrQuery(localVarHeaderParams, "x-otp-token", r.xOtpToken, "") if r.ctx != nil { // API Key Authentication if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { diff --git a/services/metalv1/docs/OTPsApi.md b/services/metalv1/docs/OTPsApi.md index 645252c1..0c00e34f 100644 --- a/services/metalv1/docs/OTPsApi.md +++ b/services/metalv1/docs/OTPsApi.md @@ -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 @@ -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) + diff --git a/services/metalv1/docs/OtpSeed.md b/services/metalv1/docs/OtpSeed.md new file mode 100644 index 00000000..84401c5b --- /dev/null +++ b/services/metalv1/docs/OtpSeed.md @@ -0,0 +1,56 @@ +# OtpSeed + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**OtpUri** | Pointer to **string** | The URI to use in your MFA app | [optional] + +## Methods + +### NewOtpSeed + +`func NewOtpSeed() *OtpSeed` + +NewOtpSeed instantiates a new OtpSeed 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 + +### NewOtpSeedWithDefaults + +`func NewOtpSeedWithDefaults() *OtpSeed` + +NewOtpSeedWithDefaults instantiates a new OtpSeed 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 + +### GetOtpUri + +`func (o *OtpSeed) GetOtpUri() string` + +GetOtpUri returns the OtpUri field if non-nil, zero value otherwise. + +### GetOtpUriOk + +`func (o *OtpSeed) GetOtpUriOk() (*string, bool)` + +GetOtpUriOk returns a tuple with the OtpUri field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOtpUri + +`func (o *OtpSeed) SetOtpUri(v string)` + +SetOtpUri sets OtpUri field to given value. + +### HasOtpUri + +`func (o *OtpSeed) HasOtpUri() bool` + +HasOtpUri 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/services/metalv1/docs/TwoFactorAuthApi.md b/services/metalv1/docs/TwoFactorAuthApi.md index def60ffd..93734735 100644 --- a/services/metalv1/docs/TwoFactorAuthApi.md +++ b/services/metalv1/docs/TwoFactorAuthApi.md @@ -13,7 +13,7 @@ Method | HTTP request | Description ## DisableTfaApp -> DisableTfaApp(ctx).Execute() +> DisableTfaApp(ctx).XOtpToken(xOtpToken).Execute() Disable two factor authentication @@ -32,10 +32,11 @@ import ( ) func main() { + xOtpToken := "xOtpToken_example" // string | configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - r, err := apiClient.TwoFactorAuthApi.DisableTfaApp(context.Background()).Execute() + r, err := apiClient.TwoFactorAuthApi.DisableTfaApp(context.Background()).XOtpToken(xOtpToken).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `TwoFactorAuthApi.DisableTfaApp``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -45,13 +46,17 @@ func main() { ### Path Parameters -This endpoint does not need any parameter. + ### Other Parameters Other parameters are passed through a pointer to a apiDisableTfaAppRequest struct via the builder pattern +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xOtpToken** | **string** | | + ### Return type (empty response body) @@ -72,7 +77,7 @@ Other parameters are passed through a pointer to a apiDisableTfaAppRequest struc ## DisableTfaSms -> DisableTfaSms(ctx).Execute() +> DisableTfaSms(ctx).XOtpToken(xOtpToken).Execute() Disable two factor authentication @@ -91,10 +96,11 @@ import ( ) func main() { + xOtpToken := "xOtpToken_example" // string | configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - r, err := apiClient.TwoFactorAuthApi.DisableTfaSms(context.Background()).Execute() + r, err := apiClient.TwoFactorAuthApi.DisableTfaSms(context.Background()).XOtpToken(xOtpToken).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `TwoFactorAuthApi.DisableTfaSms``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -104,13 +110,17 @@ func main() { ### Path Parameters -This endpoint does not need any parameter. + ### Other Parameters Other parameters are passed through a pointer to a apiDisableTfaSmsRequest struct via the builder pattern +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xOtpToken** | **string** | | + ### Return type (empty response body) @@ -131,7 +141,7 @@ Other parameters are passed through a pointer to a apiDisableTfaSmsRequest struc ## EnableTfaApp -> EnableTfaApp(ctx).Execute() +> EnableTfaApp(ctx).XOtpToken(xOtpToken).Execute() Enable two factor auth using app @@ -150,10 +160,11 @@ import ( ) func main() { + xOtpToken := "xOtpToken_example" // string | configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - r, err := apiClient.TwoFactorAuthApi.EnableTfaApp(context.Background()).Execute() + r, err := apiClient.TwoFactorAuthApi.EnableTfaApp(context.Background()).XOtpToken(xOtpToken).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `TwoFactorAuthApi.EnableTfaApp``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -163,13 +174,17 @@ func main() { ### Path Parameters -This endpoint does not need any parameter. + ### Other Parameters Other parameters are passed through a pointer to a apiEnableTfaAppRequest struct via the builder pattern +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xOtpToken** | **string** | | + ### Return type (empty response body) @@ -190,7 +205,7 @@ Other parameters are passed through a pointer to a apiEnableTfaAppRequest struct ## EnableTfaSms -> EnableTfaSms(ctx).Execute() +> EnableTfaSms(ctx).XOtpToken(xOtpToken).Execute() Enable two factor auth using sms @@ -209,10 +224,11 @@ import ( ) func main() { + xOtpToken := "xOtpToken_example" // string | configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - r, err := apiClient.TwoFactorAuthApi.EnableTfaSms(context.Background()).Execute() + r, err := apiClient.TwoFactorAuthApi.EnableTfaSms(context.Background()).XOtpToken(xOtpToken).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `TwoFactorAuthApi.EnableTfaSms``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -222,13 +238,17 @@ func main() { ### Path Parameters -This endpoint does not need any parameter. + ### Other Parameters Other parameters are passed through a pointer to a apiEnableTfaSmsRequest struct via the builder pattern +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xOtpToken** | **string** | | + ### Return type (empty response body) diff --git a/services/metalv1/model_otp_seed.go b/services/metalv1/model_otp_seed.go new file mode 100644 index 00000000..c955cb1b --- /dev/null +++ b/services/metalv1/model_otp_seed.go @@ -0,0 +1,155 @@ +/* +Metal API + +# Introduction Equinix Metal provides a RESTful HTTP API which can be reached at . This document describes the API and how to use it. The API allows you to programmatically interact with all of your Equinix Metal resources, including devices, networks, addresses, organizations, projects, and your user account. Every feature of the Equinix Metal web interface is accessible through the API. The API docs are generated from the Equinix Metal OpenAPI specification and are officially hosted at . # Common Parameters The Equinix Metal API uses a few methods to minimize network traffic and improve throughput. These parameters are not used in all API calls, but are used often enough to warrant their own section. Look for these parameters in the documentation for the API calls that support them. ## Pagination Pagination is used to limit the number of results returned in a single request. The API will return a maximum of 100 results per page. To retrieve additional results, you can use the `page` and `per_page` query parameters. The `page` parameter is used to specify the page number. The first page is `1`. The `per_page` parameter is used to specify the number of results per page. The maximum number of results differs by resource type. ## Sorting Where offered, the API allows you to sort results by a specific field. To sort results use the `sort_by` query parameter with the root level field name as the value. The `sort_direction` parameter is used to specify the sort direction, either either `asc` (ascending) or `desc` (descending). ## Filtering Filtering is used to limit the results returned in a single request. The API supports filtering by certain fields in the response. To filter results, you can use the field as a query parameter. For example, to filter the IP list to only return public IPv4 addresses, you can filter by the `type` field, as in the following request: ```sh curl -H 'X-Auth-Token: my_authentication_token' \\ https://api.equinix.com/metal/v1/projects/id/ips?type=public_ipv4 ``` Only IP addresses with the `type` field set to `public_ipv4` will be returned. ## Searching Searching is used to find matching resources using multiple field comparissons. The API supports searching in resources that define this behavior. Currently the search parameter is only available on devices, ssh_keys, api_keys and memberships endpoints. To search resources you can use the `search` query parameter. ## Include and Exclude For resources that contain references to other resources, sucha as a Device that refers to the Project it resides in, the Equinix Metal API will returns `href` values (API links) to the associated resource. ```json { ... \"project\": { \"href\": \"/metal/v1/projects/f3f131c8-f302-49ef-8c44-9405022dc6dd\" } } ``` If you're going need the project details, you can avoid a second API request. Specify the contained `href` resources and collections that you'd like to have included in the response using the `include` query parameter. For example: ```sh curl -H 'X-Auth-Token: my_authentication_token' \\ https://api.equinix.com/metal/v1/user?include=projects ``` The `include` parameter is generally accepted in `GET`, `POST`, `PUT`, and `PATCH` requests where `href` resources are presented. To have multiple resources include, use a comma-separated list (e.g. `?include=emails,projects,memberships`). ```sh curl -H 'X-Auth-Token: my_authentication_token' \\ https://api.equinix.com/metal/v1/user?include=emails,projects,memberships ``` You may also include nested associations up to three levels deep using dot notation (`?include=memberships.projects`): ```sh curl -H 'X-Auth-Token: my_authentication_token' \\ https://api.equinix.com/metal/v1/user?include=memberships.projects ``` To exclude resources, and optimize response delivery, use the `exclude` query parameter. The `exclude` parameter is generally accepted in `GET`, `POST`, `PUT`, and `PATCH` requests for fields with nested object responses. When excluded, these fields will be replaced with an object that contains only an `href` field. + +API version: 1.0.0 +Contact: support@equinixmetal.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package metalv1 + +import ( + "encoding/json" +) + +// checks if the OtpSeed type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &OtpSeed{} + +// OtpSeed Details for configuring your MFA app +type OtpSeed struct { + // The URI to use in your MFA app + OtpUri *string `json:"otp_uri,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _OtpSeed OtpSeed + +// NewOtpSeed instantiates a new OtpSeed 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 NewOtpSeed() *OtpSeed { + this := OtpSeed{} + return &this +} + +// NewOtpSeedWithDefaults instantiates a new OtpSeed 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 NewOtpSeedWithDefaults() *OtpSeed { + this := OtpSeed{} + return &this +} + +// GetOtpUri returns the OtpUri field value if set, zero value otherwise. +func (o *OtpSeed) GetOtpUri() string { + if o == nil || IsNil(o.OtpUri) { + var ret string + return ret + } + return *o.OtpUri +} + +// GetOtpUriOk returns a tuple with the OtpUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OtpSeed) GetOtpUriOk() (*string, bool) { + if o == nil || IsNil(o.OtpUri) { + return nil, false + } + return o.OtpUri, true +} + +// HasOtpUri returns a boolean if a field has been set. +func (o *OtpSeed) HasOtpUri() bool { + if o != nil && !IsNil(o.OtpUri) { + return true + } + + return false +} + +// SetOtpUri gets a reference to the given string and assigns it to the OtpUri field. +func (o *OtpSeed) SetOtpUri(v string) { + o.OtpUri = &v +} + +func (o OtpSeed) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o OtpSeed) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.OtpUri) { + toSerialize["otp_uri"] = o.OtpUri + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *OtpSeed) UnmarshalJSON(bytes []byte) (err error) { + varOtpSeed := _OtpSeed{} + + err = json.Unmarshal(bytes, &varOtpSeed) + + if err != nil { + return err + } + + *o = OtpSeed(varOtpSeed) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "otp_uri") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableOtpSeed struct { + value *OtpSeed + isSet bool +} + +func (v NullableOtpSeed) Get() *OtpSeed { + return v.value +} + +func (v *NullableOtpSeed) Set(val *OtpSeed) { + v.value = val + v.isSet = true +} + +func (v NullableOtpSeed) IsSet() bool { + return v.isSet +} + +func (v *NullableOtpSeed) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableOtpSeed(val *OtpSeed) *NullableOtpSeed { + return &NullableOtpSeed{value: val, isSet: true} +} + +func (v NullableOtpSeed) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableOtpSeed) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/metalv1/test/api_otps_test.go b/services/metalv1/test/api_otps_test.go index e40c20c0..c0861c52 100644 --- a/services/metalv1/test/api_otps_test.go +++ b/services/metalv1/test/api_otps_test.go @@ -61,4 +61,14 @@ func Test_metalv1_OTPsApiService(t *testing.T) { require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) }) + + t.Run("Test OTPsApiService SeedApp", func(t *testing.T) { + t.Skip("skip test") // remove to run test + + resp, httpRes, err := apiClient.OTPsApi.SeedApp(context.Background()).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + }) } diff --git a/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml b/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml new file mode 100644 index 00000000..6f52cd67 --- /dev/null +++ b/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml @@ -0,0 +1,5 @@ +in: header +name: x-otp-token +schema: + type: string +required: true diff --git a/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml b/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml new file mode 100644 index 00000000..f558bde0 --- /dev/null +++ b/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml @@ -0,0 +1,6 @@ +description: Details for configuring your MFA app +properties: + otp_uri: + description: The URI to use in your MFA app + type: string +type: object diff --git a/spec/services/metalv1/oas3.patched/openapi3.yaml b/spec/services/metalv1/oas3.patched/openapi3.yaml index 9822cd39..036e2ef1 100644 --- a/spec/services/metalv1/oas3.patched/openapi3.yaml +++ b/spec/services/metalv1/oas3.patched/openapi3.yaml @@ -776,6 +776,8 @@ paths: $ref: ./paths/user/api-keys/id.yaml /user/otp/app: $ref: ./paths/user/otp/app.yaml + /user/otp/app/receive: + $ref: ./paths/user/otp/app/receive.yaml /user/otp/recovery-codes: $ref: ./paths/user/otp/recovery-codes.yaml /user/otp/sms: diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml index ac3f4be6..ba0b39e4 100644 --- a/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml +++ b/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml @@ -1,6 +1,8 @@ delete: description: Disables two factor authentication. operationId: disableTfaApp + parameters: + - $ref: '../../../components/parameters/XOtpToken.yaml' responses: "204": description: no content @@ -22,6 +24,8 @@ delete: post: description: Enables two factor authentication using authenticator app. operationId: enableTfaApp + parameters: + - $ref: '../../../components/parameters/XOtpToken.yaml' responses: "200": description: ok diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml new file mode 100644 index 00000000..b336234c --- /dev/null +++ b/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml @@ -0,0 +1,36 @@ +post: + description: Issues OTP seeds for the user to upload to their 2FA app + operationId: seedApp + responses: + "204": + content: + application/json: + schema: + $ref: '../../../../components/schemas/OtpSeed.yaml' + "400": + content: + application/json: + schema: + $ref: '../../../../components/schemas/Error.yaml' + description: bad request + "401": + content: + application/json: + schema: + $ref: '../../../../components/schemas/Error.yaml' + description: unauthorized + "422": + content: + application/json: + schema: + $ref: '../../../../components/schemas/Error.yaml' + description: unprocessable entity + "500": + content: + application/json: + schema: + $ref: '../../../../components/schemas/Error.yaml' + description: internal server error + summary: Issue OTP seeds + tags: + - OTPs diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml index d7b17f74..496105e2 100644 --- a/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml +++ b/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml @@ -1,6 +1,8 @@ delete: description: Disables two factor authentication. operationId: disableTfaSms + parameters: + - $ref: '../../../components/parameters/XOtpToken.yaml' responses: "204": description: no content @@ -22,6 +24,8 @@ delete: post: description: Enables two factor authentication with sms. operationId: enableTfaSms + parameters: + - $ref: '../../../components/parameters/XOtpToken.yaml' responses: "200": description: ok diff --git a/spec/services/metalv1/patches/20240122-fix-otp-token.patch b/spec/services/metalv1/patches/20240122-fix-otp-token.patch new file mode 100644 index 00000000..8d6849d2 --- /dev/null +++ b/spec/services/metalv1/patches/20240122-fix-otp-token.patch @@ -0,0 +1,122 @@ +diff --git a/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml b/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml +new file mode 100644 +index 0000000..6f52cd6 +--- /dev/null ++++ b/spec/services/metalv1/oas3.patched/components/parameters/XOtpToken.yaml +@@ -0,0 +1,5 @@ ++in: header ++name: x-otp-token ++schema: ++ type: string ++required: true +diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml +index ac3f4be..8d636d0 100644 +--- a/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml ++++ b/spec/services/metalv1/oas3.patched/paths/user/otp/app.yaml +@@ -1,6 +1,8 @@ + delete: + description: Disables two factor authentication. + operationId: disableTfaApp ++ parameters: ++ - $ref: '../../../components/parameters/XOtpToken.yaml' + responses: + "204": + description: no content +@@ -22,6 +24,8 @@ delete: + post: + description: Enables two factor authentication using authenticator app. + operationId: enableTfaApp ++ parameters: ++ - $ref: '../../../components/parameters/XOtpToken.yaml' + responses: + "200": + description: ok +diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml +index d7b17f7..6bb6bb3 100644 +--- a/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml ++++ b/spec/services/metalv1/oas3.patched/paths/user/otp/sms.yaml +@@ -1,6 +1,8 @@ + delete: + description: Disables two factor authentication. + operationId: disableTfaSms ++ parameters: ++ - $ref: '../../../components/parameters/XOtpToken.yaml' + responses: + "204": + description: no content +@@ -22,6 +24,8 @@ delete: + post: + description: Enables two factor authentication with sms. + operationId: enableTfaSms ++ parameters: ++ - $ref: '../../../components/parameters/XOtpToken.yaml' + responses: + "200": + description: ok +diff --git a/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml b/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml +new file mode 100644 +index 0000000..f558bde +--- /dev/null ++++ b/spec/services/metalv1/oas3.patched/components/schemas/OtpSeed.yaml +@@ -0,0 +1,6 @@ ++description: Details for configuring your MFA app ++properties: ++ otp_uri: ++ description: The URI to use in your MFA app ++ type: string ++type: object +diff --git a/spec/services/metalv1/oas3.patched/openapi3.yaml b/spec/services/metalv1/oas3.patched/openapi3.yaml +index 9822cd3..036e2ef 100644 +--- a/spec/services/metalv1/oas3.patched/openapi3.yaml ++++ b/spec/services/metalv1/oas3.patched/openapi3.yaml +@@ -776,6 +776,8 @@ paths: + $ref: ./paths/user/api-keys/id.yaml + /user/otp/app: + $ref: ./paths/user/otp/app.yaml ++ /user/otp/app/receive: ++ $ref: ./paths/user/otp/app/receive.yaml + /user/otp/recovery-codes: + $ref: ./paths/user/otp/recovery-codes.yaml + /user/otp/sms: +diff --git a/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml b/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml +new file mode 100644 +index 0000000..b5ae8b7 +--- /dev/null ++++ b/spec/services/metalv1/oas3.patched/paths/user/otp/app/receive.yaml +@@ -0,0 +1,36 @@ ++post: ++ description: Issues OTP seeds for the user to upload to their 2FA app ++ operationId: seedApp ++ responses: ++ "204": ++ content: ++ application/json: ++ schema: ++ $ref: '../../../../components/schemas/OtpSeed.yaml' ++ "400": ++ content: ++ application/json: ++ schema: ++ $ref: '../../../../components/schemas/Error.yaml' ++ description: bad request ++ "401": ++ content: ++ application/json: ++ schema: ++ $ref: '../../../../components/schemas/Error.yaml' ++ description: unauthorized ++ "422": ++ content: ++ application/json: ++ schema: ++ $ref: '../../../../components/schemas/Error.yaml' ++ description: unprocessable entity ++ "500": ++ content: ++ application/json: ++ schema: ++ $ref: '../../../../components/schemas/Error.yaml' ++ description: internal server error ++ summary: Issue OTP seeds ++ tags: ++ - OTPs