diff --git a/api/public_api.swagger.json b/api/public_api.swagger.json index 019eb65..799caa4 100644 --- a/api/public_api.swagger.json +++ b/api/public_api.swagger.json @@ -1521,6 +1521,32 @@ "tags": ["Wallets"] } }, + "/public/v1/submit/init_otp_auth": { + "post": { + "summary": "Init OTP auth", + "description": "Initiate an OTP auth activity", + "operationId": "InitOtpAuth", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ActivityResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/InitOtpAuthRequest" + } + } + ], + "tags": ["Users"] + } + }, "/public/v1/submit/init_user_email_recovery": { "post": { "summary": "Init Email Recovery", @@ -1573,6 +1599,32 @@ "tags": ["Users"] } }, + "/public/v1/submit/otp_auth": { + "post": { + "summary": "OTP auth", + "description": "Authenticate a user with an OTP code sent via email or SMS", + "operationId": "OtpAuth", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ActivityResponse" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/OtpAuthRequest" + } + } + ], + "tags": ["Users"] + } + }, "/public/v1/submit/recover_user": { "post": { "summary": "Recover a user", @@ -2131,7 +2183,10 @@ "ACTIVITY_TYPE_DELETE_PRIVATE_KEYS", "ACTIVITY_TYPE_DELETE_WALLETS", "ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION_V2", - "ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION" + "ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION", + "ACTIVITY_TYPE_INIT_OTP_AUTH", + "ACTIVITY_TYPE_OTP_AUTH", + "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7" ] }, "AddressFormat": { @@ -3478,12 +3533,55 @@ }, "required": ["subOrganizationName", "rootUsers", "rootQuorumThreshold"] }, + "CreateSubOrganizationIntentV7": { + "type": "object", + "properties": { + "subOrganizationName": { + "type": "string", + "description": "Name for this sub-organization" + }, + "rootUsers": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/RootUserParamsV4" + }, + "description": "Root users to create within this sub-organization" + }, + "rootQuorumThreshold": { + "type": "integer", + "format": "int32", + "description": "The threshold of unique approvals to reach root quorum. This value must be less than or equal to the number of root users" + }, + "wallet": { + "$ref": "#/definitions/WalletParams", + "description": "The wallet to create for the sub-organization" + }, + "disableEmailRecovery": { + "type": "boolean", + "description": "Disable email recovery for the sub-organization" + }, + "disableEmailAuth": { + "type": "boolean", + "description": "Disable email auth for the sub-organization" + }, + "disableSmsAuth": { + "type": "boolean", + "description": "Disable OTP SMS auth for the sub-organization" + }, + "disableOtpEmailAuth": { + "type": "boolean", + "description": "Disable OTP email auth for the sub-organization" + } + }, + "required": ["subOrganizationName", "rootUsers", "rootQuorumThreshold"] + }, "CreateSubOrganizationRequest": { "type": "object", "properties": { "type": { "type": "string", - "enum": ["ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6"] + "enum": ["ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7"] }, "timestampMs": { "type": "string", @@ -3494,7 +3592,7 @@ "description": "Unique identifier for a given Organization." }, "parameters": { - "$ref": "#/definitions/CreateSubOrganizationIntentV6" + "$ref": "#/definitions/CreateSubOrganizationIntentV7" } }, "required": ["type", "timestampMs", "organizationId", "parameters"] @@ -3591,6 +3689,24 @@ }, "required": ["subOrganizationId"] }, + "CreateSubOrganizationResultV7": { + "type": "object", + "properties": { + "subOrganizationId": { + "type": "string" + }, + "wallet": { + "$ref": "#/definitions/WalletResult" + }, + "rootUserIds": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["subOrganizationId"] + }, "CreateUserTagIntent": { "type": "object", "properties": { @@ -3838,7 +3954,8 @@ "CREDENTIAL_TYPE_RECOVER_USER_KEY_P256", "CREDENTIAL_TYPE_API_KEY_SECP256K1", "CREDENTIAL_TYPE_EMAIL_AUTH_KEY_P256", - "CREDENTIAL_TYPE_API_KEY_ED25519" + "CREDENTIAL_TYPE_API_KEY_ED25519", + "CREDENTIAL_TYPE_OTP_AUTH_KEY_P256" ] }, "Curve": { @@ -4730,7 +4847,9 @@ "FEATURE_NAME_WEBAUTHN_ORIGINS", "FEATURE_NAME_EMAIL_AUTH", "FEATURE_NAME_EMAIL_RECOVERY", - "FEATURE_NAME_WEBHOOK" + "FEATURE_NAME_WEBHOOK", + "FEATURE_NAME_SMS_AUTH", + "FEATURE_NAME_OTP_EMAIL_AUTH" ] }, "GetActivitiesRequest": { @@ -5461,6 +5580,55 @@ }, "required": ["importBundle"] }, + "InitOtpAuthIntent": { + "type": "object", + "properties": { + "otpType": { + "type": "string", + "description": "Enum to specifiy whether to send OTP via SMS or email" + }, + "contact": { + "type": "string", + "description": "Email or phone number to send the OTP code to" + }, + "emailCustomization": { + "$ref": "#/definitions/EmailCustomizationParams", + "description": "Optional parameters for customizing emails. If not provided, the default email will be used." + } + }, + "required": ["otpType", "contact"] + }, + "InitOtpAuthRequest": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["ACTIVITY_TYPE_INIT_OTP_AUTH"] + }, + "timestampMs": { + "type": "string", + "description": "Timestamp (in milliseconds) of the request, used to verify liveness of user requests." + }, + "organizationId": { + "type": "string", + "description": "Unique identifier for a given Organization." + }, + "parameters": { + "$ref": "#/definitions/InitOtpAuthIntent" + } + }, + "required": ["type", "timestampMs", "organizationId", "parameters"] + }, + "InitOtpAuthResult": { + "type": "object", + "properties": { + "otpId": { + "type": "string", + "description": "Unique identifier for an OTP authentication" + } + }, + "required": ["otpId"] + }, "InitUserEmailRecoveryIntent": { "type": "object", "properties": { @@ -5744,6 +5912,15 @@ }, "deleteSubOrganizationIntent": { "$ref": "#/definitions/DeleteSubOrganizationIntent" + }, + "initOtpAuthIntent": { + "$ref": "#/definitions/InitOtpAuthIntent" + }, + "otpAuthIntent": { + "$ref": "#/definitions/OtpAuthIntent" + }, + "createSubOrganizationIntentV7": { + "$ref": "#/definitions/CreateSubOrganizationIntentV7" } } }, @@ -5975,6 +6152,75 @@ "OPERATOR_CONTAINS_ALL" ] }, + "OtpAuthIntent": { + "type": "object", + "properties": { + "otpId": { + "type": "string", + "description": "ID representing the result of an init OTP activity." + }, + "otpCode": { + "type": "string", + "description": "6 digit OTP code sent out to a user's contact (email or SMS)" + }, + "targetPublicKey": { + "type": "string", + "description": "Client-side public key generated by the user, to which the OTP bundle (credentials) will be encrypted." + }, + "apiKeyName": { + "type": "string", + "description": "Optional human-readable name for an API Key. If none provided, default to OTP Auth - \u003cTimestamp\u003e" + }, + "expirationSeconds": { + "type": "string", + "description": "Expiration window (in seconds) indicating how long the API key is valid. If not provided, a default of 15 minutes will be used." + }, + "invalidateExisting": { + "type": "boolean", + "description": "Invalidate all other previously generated OTP Auth API keys" + } + }, + "required": ["otpId", "otpCode"] + }, + "OtpAuthRequest": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["ACTIVITY_TYPE_OTP_AUTH"] + }, + "timestampMs": { + "type": "string", + "description": "Timestamp (in milliseconds) of the request, used to verify liveness of user requests." + }, + "organizationId": { + "type": "string", + "description": "Unique identifier for a given Organization." + }, + "parameters": { + "$ref": "#/definitions/OtpAuthIntent" + } + }, + "required": ["type", "timestampMs", "organizationId", "parameters"] + }, + "OtpAuthResult": { + "type": "object", + "properties": { + "userId": { + "type": "string", + "description": "Unique identifier for the authenticating User." + }, + "apiKeyId": { + "type": "string", + "description": "Unique identifier for the created API key." + }, + "credentialBundle": { + "type": "string", + "description": "HPKE encrypted credential bundle" + } + }, + "required": ["userId"] + }, "Pagination": { "type": "object", "properties": { @@ -6494,6 +6740,15 @@ }, "deleteSubOrganizationResult": { "$ref": "#/definitions/DeleteSubOrganizationResult" + }, + "initOtpAuthResult": { + "$ref": "#/definitions/InitOtpAuthResult" + }, + "otpAuthResult": { + "$ref": "#/definitions/OtpAuthResult" + }, + "createSubOrganizationResultV7": { + "$ref": "#/definitions/CreateSubOrganizationResultV7" } } }, @@ -6603,6 +6858,48 @@ }, "required": ["userName", "apiKeys", "authenticators", "oauthProviders"] }, + "RootUserParamsV4": { + "type": "object", + "properties": { + "userName": { + "type": "string", + "description": "Human-readable name for a User." + }, + "userEmail": { + "type": "string", + "description": "The user's email address." + }, + "userPhoneNumber": { + "type": "string", + "description": "The user's phone number in E.164 format e.g. +13214567890" + }, + "apiKeys": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/ApiKeyParamsV2" + }, + "description": "A list of API Key parameters." + }, + "authenticators": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/AuthenticatorParamsV2" + }, + "description": "A list of Authenticator parameters." + }, + "oauthProviders": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/OauthProviderParams" + }, + "description": "A list of Oauth providers." + } + }, + "required": ["userName", "apiKeys", "authenticators", "oauthProviders"] + }, "Selector": { "type": "object", "properties": { @@ -7201,6 +7498,10 @@ "type": "string" }, "description": "An updated list of User Tags to apply to this User." + }, + "userPhoneNumber": { + "type": "string", + "description": "The user's phone number in E.164 format e.g. +13214567890" } }, "required": ["userId"] @@ -7310,6 +7611,10 @@ "type": "string", "description": "The user's email address." }, + "userPhoneNumber": { + "type": "string", + "description": "The user's phone number in E.164 format e.g. +13214567890" + }, "authenticators": { "type": "array", "items": { diff --git a/pkg/api/client/users/init_otp_auth_parameters.go b/pkg/api/client/users/init_otp_auth_parameters.go new file mode 100644 index 0000000..e66bc1c --- /dev/null +++ b/pkg/api/client/users/init_otp_auth_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package users + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/tkhq/go-sdk/pkg/api/models" +) + +// NewInitOtpAuthParams creates a new InitOtpAuthParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewInitOtpAuthParams() *InitOtpAuthParams { + return &InitOtpAuthParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewInitOtpAuthParamsWithTimeout creates a new InitOtpAuthParams object +// with the ability to set a timeout on a request. +func NewInitOtpAuthParamsWithTimeout(timeout time.Duration) *InitOtpAuthParams { + return &InitOtpAuthParams{ + timeout: timeout, + } +} + +// NewInitOtpAuthParamsWithContext creates a new InitOtpAuthParams object +// with the ability to set a context for a request. +func NewInitOtpAuthParamsWithContext(ctx context.Context) *InitOtpAuthParams { + return &InitOtpAuthParams{ + Context: ctx, + } +} + +// NewInitOtpAuthParamsWithHTTPClient creates a new InitOtpAuthParams object +// with the ability to set a custom HTTPClient for a request. +func NewInitOtpAuthParamsWithHTTPClient(client *http.Client) *InitOtpAuthParams { + return &InitOtpAuthParams{ + HTTPClient: client, + } +} + +/* +InitOtpAuthParams contains all the parameters to send to the API endpoint + + for the init otp auth operation. + + Typically these are written to a http.Request. +*/ +type InitOtpAuthParams struct { + + // Body. + Body *models.InitOtpAuthRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the init otp auth params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InitOtpAuthParams) WithDefaults() *InitOtpAuthParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the init otp auth params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *InitOtpAuthParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the init otp auth params +func (o *InitOtpAuthParams) WithTimeout(timeout time.Duration) *InitOtpAuthParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the init otp auth params +func (o *InitOtpAuthParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the init otp auth params +func (o *InitOtpAuthParams) WithContext(ctx context.Context) *InitOtpAuthParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the init otp auth params +func (o *InitOtpAuthParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the init otp auth params +func (o *InitOtpAuthParams) WithHTTPClient(client *http.Client) *InitOtpAuthParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the init otp auth params +func (o *InitOtpAuthParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the init otp auth params +func (o *InitOtpAuthParams) WithBody(body *models.InitOtpAuthRequest) *InitOtpAuthParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the init otp auth params +func (o *InitOtpAuthParams) SetBody(body *models.InitOtpAuthRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *InitOtpAuthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/api/client/users/init_otp_auth_responses.go b/pkg/api/client/users/init_otp_auth_responses.go new file mode 100644 index 0000000..e23a3af --- /dev/null +++ b/pkg/api/client/users/init_otp_auth_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package users + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/tkhq/go-sdk/pkg/api/models" +) + +// InitOtpAuthReader is a Reader for the InitOtpAuth structure. +type InitOtpAuthReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *InitOtpAuthReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewInitOtpAuthOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("[POST /public/v1/submit/init_otp_auth] InitOtpAuth", response, response.Code()) + } +} + +// NewInitOtpAuthOK creates a InitOtpAuthOK with default headers values +func NewInitOtpAuthOK() *InitOtpAuthOK { + return &InitOtpAuthOK{} +} + +/* +InitOtpAuthOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type InitOtpAuthOK struct { + Payload *models.ActivityResponse +} + +// IsSuccess returns true when this init otp auth o k response has a 2xx status code +func (o *InitOtpAuthOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this init otp auth o k response has a 3xx status code +func (o *InitOtpAuthOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this init otp auth o k response has a 4xx status code +func (o *InitOtpAuthOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this init otp auth o k response has a 5xx status code +func (o *InitOtpAuthOK) IsServerError() bool { + return false +} + +// IsCode returns true when this init otp auth o k response a status code equal to that given +func (o *InitOtpAuthOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the init otp auth o k response +func (o *InitOtpAuthOK) Code() int { + return 200 +} + +func (o *InitOtpAuthOK) Error() string { + return fmt.Sprintf("[POST /public/v1/submit/init_otp_auth][%d] initOtpAuthOK %+v", 200, o.Payload) +} + +func (o *InitOtpAuthOK) String() string { + return fmt.Sprintf("[POST /public/v1/submit/init_otp_auth][%d] initOtpAuthOK %+v", 200, o.Payload) +} + +func (o *InitOtpAuthOK) GetPayload() *models.ActivityResponse { + return o.Payload +} + +func (o *InitOtpAuthOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ActivityResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/api/client/users/otp_auth_parameters.go b/pkg/api/client/users/otp_auth_parameters.go new file mode 100644 index 0000000..94cba6f --- /dev/null +++ b/pkg/api/client/users/otp_auth_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package users + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/tkhq/go-sdk/pkg/api/models" +) + +// NewOtpAuthParams creates a new OtpAuthParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewOtpAuthParams() *OtpAuthParams { + return &OtpAuthParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewOtpAuthParamsWithTimeout creates a new OtpAuthParams object +// with the ability to set a timeout on a request. +func NewOtpAuthParamsWithTimeout(timeout time.Duration) *OtpAuthParams { + return &OtpAuthParams{ + timeout: timeout, + } +} + +// NewOtpAuthParamsWithContext creates a new OtpAuthParams object +// with the ability to set a context for a request. +func NewOtpAuthParamsWithContext(ctx context.Context) *OtpAuthParams { + return &OtpAuthParams{ + Context: ctx, + } +} + +// NewOtpAuthParamsWithHTTPClient creates a new OtpAuthParams object +// with the ability to set a custom HTTPClient for a request. +func NewOtpAuthParamsWithHTTPClient(client *http.Client) *OtpAuthParams { + return &OtpAuthParams{ + HTTPClient: client, + } +} + +/* +OtpAuthParams contains all the parameters to send to the API endpoint + + for the otp auth operation. + + Typically these are written to a http.Request. +*/ +type OtpAuthParams struct { + + // Body. + Body *models.OtpAuthRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the otp auth params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OtpAuthParams) WithDefaults() *OtpAuthParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the otp auth params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OtpAuthParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the otp auth params +func (o *OtpAuthParams) WithTimeout(timeout time.Duration) *OtpAuthParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the otp auth params +func (o *OtpAuthParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the otp auth params +func (o *OtpAuthParams) WithContext(ctx context.Context) *OtpAuthParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the otp auth params +func (o *OtpAuthParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the otp auth params +func (o *OtpAuthParams) WithHTTPClient(client *http.Client) *OtpAuthParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the otp auth params +func (o *OtpAuthParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the otp auth params +func (o *OtpAuthParams) WithBody(body *models.OtpAuthRequest) *OtpAuthParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the otp auth params +func (o *OtpAuthParams) SetBody(body *models.OtpAuthRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *OtpAuthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/api/client/users/otp_auth_responses.go b/pkg/api/client/users/otp_auth_responses.go new file mode 100644 index 0000000..82f52af --- /dev/null +++ b/pkg/api/client/users/otp_auth_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package users + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/tkhq/go-sdk/pkg/api/models" +) + +// OtpAuthReader is a Reader for the OtpAuth structure. +type OtpAuthReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *OtpAuthReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewOtpAuthOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("[POST /public/v1/submit/otp_auth] OtpAuth", response, response.Code()) + } +} + +// NewOtpAuthOK creates a OtpAuthOK with default headers values +func NewOtpAuthOK() *OtpAuthOK { + return &OtpAuthOK{} +} + +/* +OtpAuthOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type OtpAuthOK struct { + Payload *models.ActivityResponse +} + +// IsSuccess returns true when this otp auth o k response has a 2xx status code +func (o *OtpAuthOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this otp auth o k response has a 3xx status code +func (o *OtpAuthOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this otp auth o k response has a 4xx status code +func (o *OtpAuthOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this otp auth o k response has a 5xx status code +func (o *OtpAuthOK) IsServerError() bool { + return false +} + +// IsCode returns true when this otp auth o k response a status code equal to that given +func (o *OtpAuthOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the otp auth o k response +func (o *OtpAuthOK) Code() int { + return 200 +} + +func (o *OtpAuthOK) Error() string { + return fmt.Sprintf("[POST /public/v1/submit/otp_auth][%d] otpAuthOK %+v", 200, o.Payload) +} + +func (o *OtpAuthOK) String() string { + return fmt.Sprintf("[POST /public/v1/submit/otp_auth][%d] otpAuthOK %+v", 200, o.Payload) +} + +func (o *OtpAuthOK) GetPayload() *models.ActivityResponse { + return o.Payload +} + +func (o *OtpAuthOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ActivityResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/api/client/users/users_client.go b/pkg/api/client/users/users_client.go index d2a50da..eaa8373 100644 --- a/pkg/api/client/users/users_client.go +++ b/pkg/api/client/users/users_client.go @@ -44,8 +44,12 @@ type ClientService interface { GetUsers(params *GetUsersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetUsersOK, error) + InitOtpAuth(params *InitOtpAuthParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InitOtpAuthOK, error) + Oauth(params *OauthParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OauthOK, error) + OtpAuth(params *OtpAuthParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OtpAuthOK, error) + UpdateUser(params *UpdateUserParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateUserOK, error) SetTransport(transport runtime.ClientTransport) @@ -338,6 +342,47 @@ func (a *Client) GetUsers(params *GetUsersParams, authInfo runtime.ClientAuthInf panic(msg) } +/* +InitOtpAuth inits o t p auth + +Initiate an OTP auth activity +*/ +func (a *Client) InitOtpAuth(params *InitOtpAuthParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InitOtpAuthOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewInitOtpAuthParams() + } + op := &runtime.ClientOperation{ + ID: "InitOtpAuth", + Method: "POST", + PathPattern: "/public/v1/submit/init_otp_auth", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &InitOtpAuthReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*InitOtpAuthOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for InitOtpAuth: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* Oauth oauths @@ -379,6 +424,47 @@ func (a *Client) Oauth(params *OauthParams, authInfo runtime.ClientAuthInfoWrite panic(msg) } +/* +OtpAuth os t p auth + +Authenticate a user with an OTP code sent via email or SMS +*/ +func (a *Client) OtpAuth(params *OtpAuthParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OtpAuthOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewOtpAuthParams() + } + op := &runtime.ClientOperation{ + ID: "OtpAuth", + Method: "POST", + PathPattern: "/public/v1/submit/otp_auth", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &OtpAuthReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*OtpAuthOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for OtpAuth: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* UpdateUser updates user diff --git a/pkg/api/models/activity_type.go b/pkg/api/models/activity_type.go index cfea8bc..684e44b 100644 --- a/pkg/api/models/activity_type.go +++ b/pkg/api/models/activity_type.go @@ -257,6 +257,15 @@ const ( // ActivityTypeDeleteSubOrganization captures enum value "ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION" ActivityTypeDeleteSubOrganization ActivityType = "ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION" + + // ActivityTypeInitOtpAuth captures enum value "ACTIVITY_TYPE_INIT_OTP_AUTH" + ActivityTypeInitOtpAuth ActivityType = "ACTIVITY_TYPE_INIT_OTP_AUTH" + + // ActivityTypeOtpAuth captures enum value "ACTIVITY_TYPE_OTP_AUTH" + ActivityTypeOtpAuth ActivityType = "ACTIVITY_TYPE_OTP_AUTH" + + // ActivityTypeCreateSubOrganizationV7 captures enum value "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7" + ActivityTypeCreateSubOrganizationV7 ActivityType = "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7" ) // for schema @@ -264,7 +273,7 @@ var ActivityTypeEnum []ActivityType func init() { var res []ActivityType - if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_CREATE_API_KEYS","ACTIVITY_TYPE_CREATE_USERS","ACTIVITY_TYPE_CREATE_PRIVATE_KEYS","ACTIVITY_TYPE_SIGN_RAW_PAYLOAD","ACTIVITY_TYPE_CREATE_INVITATIONS","ACTIVITY_TYPE_ACCEPT_INVITATION","ACTIVITY_TYPE_CREATE_POLICY","ACTIVITY_TYPE_DISABLE_PRIVATE_KEY","ACTIVITY_TYPE_DELETE_USERS","ACTIVITY_TYPE_DELETE_API_KEYS","ACTIVITY_TYPE_DELETE_INVITATION","ACTIVITY_TYPE_DELETE_ORGANIZATION","ACTIVITY_TYPE_DELETE_POLICY","ACTIVITY_TYPE_CREATE_USER_TAG","ACTIVITY_TYPE_DELETE_USER_TAGS","ACTIVITY_TYPE_CREATE_ORGANIZATION","ACTIVITY_TYPE_SIGN_TRANSACTION","ACTIVITY_TYPE_APPROVE_ACTIVITY","ACTIVITY_TYPE_REJECT_ACTIVITY","ACTIVITY_TYPE_DELETE_AUTHENTICATORS","ACTIVITY_TYPE_CREATE_AUTHENTICATORS","ACTIVITY_TYPE_CREATE_PRIVATE_KEY_TAG","ACTIVITY_TYPE_DELETE_PRIVATE_KEY_TAGS","ACTIVITY_TYPE_SET_PAYMENT_METHOD","ACTIVITY_TYPE_ACTIVATE_BILLING_TIER","ACTIVITY_TYPE_DELETE_PAYMENT_METHOD","ACTIVITY_TYPE_CREATE_POLICY_V2","ACTIVITY_TYPE_CREATE_POLICY_V3","ACTIVITY_TYPE_CREATE_API_ONLY_USERS","ACTIVITY_TYPE_UPDATE_ROOT_QUORUM","ACTIVITY_TYPE_UPDATE_USER_TAG","ACTIVITY_TYPE_UPDATE_PRIVATE_KEY_TAG","ACTIVITY_TYPE_CREATE_AUTHENTICATORS_V2","ACTIVITY_TYPE_CREATE_ORGANIZATION_V2","ACTIVITY_TYPE_CREATE_USERS_V2","ACTIVITY_TYPE_ACCEPT_INVITATION_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V2","ACTIVITY_TYPE_UPDATE_ALLOWED_ORIGINS","ACTIVITY_TYPE_CREATE_PRIVATE_KEYS_V2","ACTIVITY_TYPE_UPDATE_USER","ACTIVITY_TYPE_UPDATE_POLICY","ACTIVITY_TYPE_SET_PAYMENT_METHOD_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V3","ACTIVITY_TYPE_CREATE_WALLET","ACTIVITY_TYPE_CREATE_WALLET_ACCOUNTS","ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY","ACTIVITY_TYPE_RECOVER_USER","ACTIVITY_TYPE_SET_ORGANIZATION_FEATURE","ACTIVITY_TYPE_REMOVE_ORGANIZATION_FEATURE","ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2","ACTIVITY_TYPE_SIGN_TRANSACTION_V2","ACTIVITY_TYPE_EXPORT_PRIVATE_KEY","ACTIVITY_TYPE_EXPORT_WALLET","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V4","ACTIVITY_TYPE_EMAIL_AUTH","ACTIVITY_TYPE_EXPORT_WALLET_ACCOUNT","ACTIVITY_TYPE_INIT_IMPORT_WALLET","ACTIVITY_TYPE_IMPORT_WALLET","ACTIVITY_TYPE_INIT_IMPORT_PRIVATE_KEY","ACTIVITY_TYPE_IMPORT_PRIVATE_KEY","ACTIVITY_TYPE_CREATE_POLICIES","ACTIVITY_TYPE_SIGN_RAW_PAYLOADS","ACTIVITY_TYPE_CREATE_READ_ONLY_SESSION","ACTIVITY_TYPE_CREATE_OAUTH_PROVIDERS","ACTIVITY_TYPE_DELETE_OAUTH_PROVIDERS","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V5","ACTIVITY_TYPE_OAUTH","ACTIVITY_TYPE_CREATE_API_KEYS_V2","ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION","ACTIVITY_TYPE_EMAIL_AUTH_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6","ACTIVITY_TYPE_DELETE_PRIVATE_KEYS","ACTIVITY_TYPE_DELETE_WALLETS","ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION_V2","ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_CREATE_API_KEYS","ACTIVITY_TYPE_CREATE_USERS","ACTIVITY_TYPE_CREATE_PRIVATE_KEYS","ACTIVITY_TYPE_SIGN_RAW_PAYLOAD","ACTIVITY_TYPE_CREATE_INVITATIONS","ACTIVITY_TYPE_ACCEPT_INVITATION","ACTIVITY_TYPE_CREATE_POLICY","ACTIVITY_TYPE_DISABLE_PRIVATE_KEY","ACTIVITY_TYPE_DELETE_USERS","ACTIVITY_TYPE_DELETE_API_KEYS","ACTIVITY_TYPE_DELETE_INVITATION","ACTIVITY_TYPE_DELETE_ORGANIZATION","ACTIVITY_TYPE_DELETE_POLICY","ACTIVITY_TYPE_CREATE_USER_TAG","ACTIVITY_TYPE_DELETE_USER_TAGS","ACTIVITY_TYPE_CREATE_ORGANIZATION","ACTIVITY_TYPE_SIGN_TRANSACTION","ACTIVITY_TYPE_APPROVE_ACTIVITY","ACTIVITY_TYPE_REJECT_ACTIVITY","ACTIVITY_TYPE_DELETE_AUTHENTICATORS","ACTIVITY_TYPE_CREATE_AUTHENTICATORS","ACTIVITY_TYPE_CREATE_PRIVATE_KEY_TAG","ACTIVITY_TYPE_DELETE_PRIVATE_KEY_TAGS","ACTIVITY_TYPE_SET_PAYMENT_METHOD","ACTIVITY_TYPE_ACTIVATE_BILLING_TIER","ACTIVITY_TYPE_DELETE_PAYMENT_METHOD","ACTIVITY_TYPE_CREATE_POLICY_V2","ACTIVITY_TYPE_CREATE_POLICY_V3","ACTIVITY_TYPE_CREATE_API_ONLY_USERS","ACTIVITY_TYPE_UPDATE_ROOT_QUORUM","ACTIVITY_TYPE_UPDATE_USER_TAG","ACTIVITY_TYPE_UPDATE_PRIVATE_KEY_TAG","ACTIVITY_TYPE_CREATE_AUTHENTICATORS_V2","ACTIVITY_TYPE_CREATE_ORGANIZATION_V2","ACTIVITY_TYPE_CREATE_USERS_V2","ACTIVITY_TYPE_ACCEPT_INVITATION_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V2","ACTIVITY_TYPE_UPDATE_ALLOWED_ORIGINS","ACTIVITY_TYPE_CREATE_PRIVATE_KEYS_V2","ACTIVITY_TYPE_UPDATE_USER","ACTIVITY_TYPE_UPDATE_POLICY","ACTIVITY_TYPE_SET_PAYMENT_METHOD_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V3","ACTIVITY_TYPE_CREATE_WALLET","ACTIVITY_TYPE_CREATE_WALLET_ACCOUNTS","ACTIVITY_TYPE_INIT_USER_EMAIL_RECOVERY","ACTIVITY_TYPE_RECOVER_USER","ACTIVITY_TYPE_SET_ORGANIZATION_FEATURE","ACTIVITY_TYPE_REMOVE_ORGANIZATION_FEATURE","ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2","ACTIVITY_TYPE_SIGN_TRANSACTION_V2","ACTIVITY_TYPE_EXPORT_PRIVATE_KEY","ACTIVITY_TYPE_EXPORT_WALLET","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V4","ACTIVITY_TYPE_EMAIL_AUTH","ACTIVITY_TYPE_EXPORT_WALLET_ACCOUNT","ACTIVITY_TYPE_INIT_IMPORT_WALLET","ACTIVITY_TYPE_IMPORT_WALLET","ACTIVITY_TYPE_INIT_IMPORT_PRIVATE_KEY","ACTIVITY_TYPE_IMPORT_PRIVATE_KEY","ACTIVITY_TYPE_CREATE_POLICIES","ACTIVITY_TYPE_SIGN_RAW_PAYLOADS","ACTIVITY_TYPE_CREATE_READ_ONLY_SESSION","ACTIVITY_TYPE_CREATE_OAUTH_PROVIDERS","ACTIVITY_TYPE_DELETE_OAUTH_PROVIDERS","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V5","ACTIVITY_TYPE_OAUTH","ACTIVITY_TYPE_CREATE_API_KEYS_V2","ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION","ACTIVITY_TYPE_EMAIL_AUTH_V2","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6","ACTIVITY_TYPE_DELETE_PRIVATE_KEYS","ACTIVITY_TYPE_DELETE_WALLETS","ACTIVITY_TYPE_CREATE_READ_WRITE_SESSION_V2","ACTIVITY_TYPE_DELETE_SUB_ORGANIZATION","ACTIVITY_TYPE_INIT_OTP_AUTH","ACTIVITY_TYPE_OTP_AUTH","ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/api/models/create_sub_organization_intent_v7.go b/pkg/api/models/create_sub_organization_intent_v7.go new file mode 100644 index 0000000..4efe975 --- /dev/null +++ b/pkg/api/models/create_sub_organization_intent_v7.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateSubOrganizationIntentV7 create sub organization intent v7 +// +// swagger:model CreateSubOrganizationIntentV7 +type CreateSubOrganizationIntentV7 struct { + + // Disable email auth for the sub-organization + DisableEmailAuth bool `json:"disableEmailAuth,omitempty"` + + // Disable email recovery for the sub-organization + DisableEmailRecovery bool `json:"disableEmailRecovery,omitempty"` + + // Disable OTP email auth for the sub-organization + DisableOtpEmailAuth bool `json:"disableOtpEmailAuth,omitempty"` + + // Disable OTP SMS auth for the sub-organization + DisableSmsAuth bool `json:"disableSmsAuth,omitempty"` + + // The threshold of unique approvals to reach root quorum. This value must be less than or equal to the number of root users + // Required: true + RootQuorumThreshold *int32 `json:"rootQuorumThreshold"` + + // Root users to create within this sub-organization + // Required: true + RootUsers []*RootUserParamsV4 `json:"rootUsers"` + + // Name for this sub-organization + // Required: true + SubOrganizationName *string `json:"subOrganizationName"` + + // The wallet to create for the sub-organization + Wallet *WalletParams `json:"wallet,omitempty"` +} + +// Validate validates this create sub organization intent v7 +func (m *CreateSubOrganizationIntentV7) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRootQuorumThreshold(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRootUsers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubOrganizationName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWallet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateSubOrganizationIntentV7) validateRootQuorumThreshold(formats strfmt.Registry) error { + + if err := validate.Required("rootQuorumThreshold", "body", m.RootQuorumThreshold); err != nil { + return err + } + + return nil +} + +func (m *CreateSubOrganizationIntentV7) validateRootUsers(formats strfmt.Registry) error { + + if err := validate.Required("rootUsers", "body", m.RootUsers); err != nil { + return err + } + + for i := 0; i < len(m.RootUsers); i++ { + if swag.IsZero(m.RootUsers[i]) { // not required + continue + } + + if m.RootUsers[i] != nil { + if err := m.RootUsers[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rootUsers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rootUsers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CreateSubOrganizationIntentV7) validateSubOrganizationName(formats strfmt.Registry) error { + + if err := validate.Required("subOrganizationName", "body", m.SubOrganizationName); err != nil { + return err + } + + return nil +} + +func (m *CreateSubOrganizationIntentV7) validateWallet(formats strfmt.Registry) error { + if swag.IsZero(m.Wallet) { // not required + return nil + } + + if m.Wallet != nil { + if err := m.Wallet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wallet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("wallet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create sub organization intent v7 based on the context it is used +func (m *CreateSubOrganizationIntentV7) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRootUsers(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateWallet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateSubOrganizationIntentV7) contextValidateRootUsers(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.RootUsers); i++ { + + if m.RootUsers[i] != nil { + + if swag.IsZero(m.RootUsers[i]) { // not required + return nil + } + + if err := m.RootUsers[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rootUsers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("rootUsers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CreateSubOrganizationIntentV7) contextValidateWallet(ctx context.Context, formats strfmt.Registry) error { + + if m.Wallet != nil { + + if swag.IsZero(m.Wallet) { // not required + return nil + } + + if err := m.Wallet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wallet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("wallet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateSubOrganizationIntentV7) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateSubOrganizationIntentV7) UnmarshalBinary(b []byte) error { + var res CreateSubOrganizationIntentV7 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/create_sub_organization_request.go b/pkg/api/models/create_sub_organization_request.go index b61c6c5..48426fd 100644 --- a/pkg/api/models/create_sub_organization_request.go +++ b/pkg/api/models/create_sub_organization_request.go @@ -26,7 +26,7 @@ type CreateSubOrganizationRequest struct { // parameters // Required: true - Parameters *CreateSubOrganizationIntentV6 `json:"parameters"` + Parameters *CreateSubOrganizationIntentV7 `json:"parameters"` // Timestamp (in milliseconds) of the request, used to verify liveness of user requests. // Required: true @@ -34,7 +34,7 @@ type CreateSubOrganizationRequest struct { // type // Required: true - // Enum: [ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6] + // Enum: [ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7] Type *string `json:"type"` } @@ -106,7 +106,7 @@ var createSubOrganizationRequestTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -116,8 +116,8 @@ func init() { const ( - // CreateSubOrganizationRequestTypeACTIVITYTYPECREATESUBORGANIZATIONV6 captures enum value "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6" - CreateSubOrganizationRequestTypeACTIVITYTYPECREATESUBORGANIZATIONV6 string = "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V6" + // CreateSubOrganizationRequestTypeACTIVITYTYPECREATESUBORGANIZATIONV7 captures enum value "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7" + CreateSubOrganizationRequestTypeACTIVITYTYPECREATESUBORGANIZATIONV7 string = "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7" ) // prop value enum diff --git a/pkg/api/models/create_sub_organization_result_v7.go b/pkg/api/models/create_sub_organization_result_v7.go new file mode 100644 index 0000000..c7af031 --- /dev/null +++ b/pkg/api/models/create_sub_organization_result_v7.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateSubOrganizationResultV7 create sub organization result v7 +// +// swagger:model CreateSubOrganizationResultV7 +type CreateSubOrganizationResultV7 struct { + + // root user ids + RootUserIds []string `json:"rootUserIds"` + + // sub organization Id + // Required: true + SubOrganizationID *string `json:"subOrganizationId"` + + // wallet + Wallet *WalletResult `json:"wallet,omitempty"` +} + +// Validate validates this create sub organization result v7 +func (m *CreateSubOrganizationResultV7) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSubOrganizationID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWallet(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateSubOrganizationResultV7) validateSubOrganizationID(formats strfmt.Registry) error { + + if err := validate.Required("subOrganizationId", "body", m.SubOrganizationID); err != nil { + return err + } + + return nil +} + +func (m *CreateSubOrganizationResultV7) validateWallet(formats strfmt.Registry) error { + if swag.IsZero(m.Wallet) { // not required + return nil + } + + if m.Wallet != nil { + if err := m.Wallet.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wallet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("wallet") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create sub organization result v7 based on the context it is used +func (m *CreateSubOrganizationResultV7) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateWallet(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateSubOrganizationResultV7) contextValidateWallet(ctx context.Context, formats strfmt.Registry) error { + + if m.Wallet != nil { + + if swag.IsZero(m.Wallet) { // not required + return nil + } + + if err := m.Wallet.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wallet") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("wallet") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateSubOrganizationResultV7) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateSubOrganizationResultV7) UnmarshalBinary(b []byte) error { + var res CreateSubOrganizationResultV7 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/credential_type.go b/pkg/api/models/credential_type.go index a82c948..df28c84 100644 --- a/pkg/api/models/credential_type.go +++ b/pkg/api/models/credential_type.go @@ -47,6 +47,9 @@ const ( // CredentialTypeAPIKeyEd25519 captures enum value "CREDENTIAL_TYPE_API_KEY_ED25519" CredentialTypeAPIKeyEd25519 CredentialType = "CREDENTIAL_TYPE_API_KEY_ED25519" + + // CredentialTypeOtpAuthKeyP256 captures enum value "CREDENTIAL_TYPE_OTP_AUTH_KEY_P256" + CredentialTypeOtpAuthKeyP256 CredentialType = "CREDENTIAL_TYPE_OTP_AUTH_KEY_P256" ) // for schema @@ -54,7 +57,7 @@ var CredentialTypeEnum []CredentialType func init() { var res []CredentialType - if err := json.Unmarshal([]byte(`["CREDENTIAL_TYPE_WEBAUTHN_AUTHENTICATOR","CREDENTIAL_TYPE_API_KEY_P256","CREDENTIAL_TYPE_RECOVER_USER_KEY_P256","CREDENTIAL_TYPE_API_KEY_SECP256K1","CREDENTIAL_TYPE_EMAIL_AUTH_KEY_P256","CREDENTIAL_TYPE_API_KEY_ED25519"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["CREDENTIAL_TYPE_WEBAUTHN_AUTHENTICATOR","CREDENTIAL_TYPE_API_KEY_P256","CREDENTIAL_TYPE_RECOVER_USER_KEY_P256","CREDENTIAL_TYPE_API_KEY_SECP256K1","CREDENTIAL_TYPE_EMAIL_AUTH_KEY_P256","CREDENTIAL_TYPE_API_KEY_ED25519","CREDENTIAL_TYPE_OTP_AUTH_KEY_P256"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/api/models/feature_name.go b/pkg/api/models/feature_name.go index 0104a5a..7657723 100644 --- a/pkg/api/models/feature_name.go +++ b/pkg/api/models/feature_name.go @@ -44,6 +44,12 @@ const ( // FeatureNameWebhook captures enum value "FEATURE_NAME_WEBHOOK" FeatureNameWebhook FeatureName = "FEATURE_NAME_WEBHOOK" + + // FeatureNameSmsAuth captures enum value "FEATURE_NAME_SMS_AUTH" + FeatureNameSmsAuth FeatureName = "FEATURE_NAME_SMS_AUTH" + + // FeatureNameOtpEmailAuth captures enum value "FEATURE_NAME_OTP_EMAIL_AUTH" + FeatureNameOtpEmailAuth FeatureName = "FEATURE_NAME_OTP_EMAIL_AUTH" ) // for schema @@ -51,7 +57,7 @@ var FeatureNameEnum []FeatureName func init() { var res []FeatureName - if err := json.Unmarshal([]byte(`["FEATURE_NAME_ROOT_USER_EMAIL_RECOVERY","FEATURE_NAME_WEBAUTHN_ORIGINS","FEATURE_NAME_EMAIL_AUTH","FEATURE_NAME_EMAIL_RECOVERY","FEATURE_NAME_WEBHOOK"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["FEATURE_NAME_ROOT_USER_EMAIL_RECOVERY","FEATURE_NAME_WEBAUTHN_ORIGINS","FEATURE_NAME_EMAIL_AUTH","FEATURE_NAME_EMAIL_RECOVERY","FEATURE_NAME_WEBHOOK","FEATURE_NAME_SMS_AUTH","FEATURE_NAME_OTP_EMAIL_AUTH"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/api/models/init_otp_auth_intent.go b/pkg/api/models/init_otp_auth_intent.go new file mode 100644 index 0000000..4e184cf --- /dev/null +++ b/pkg/api/models/init_otp_auth_intent.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// InitOtpAuthIntent init otp auth intent +// +// swagger:model InitOtpAuthIntent +type InitOtpAuthIntent struct { + + // Email or phone number to send the OTP code to + // Required: true + Contact *string `json:"contact"` + + // Optional parameters for customizing emails. If not provided, the default email will be used. + EmailCustomization *EmailCustomizationParams `json:"emailCustomization,omitempty"` + + // Enum to specifiy whether to send OTP via SMS or email + // Required: true + OtpType *string `json:"otpType"` +} + +// Validate validates this init otp auth intent +func (m *InitOtpAuthIntent) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateContact(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEmailCustomization(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOtpType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InitOtpAuthIntent) validateContact(formats strfmt.Registry) error { + + if err := validate.Required("contact", "body", m.Contact); err != nil { + return err + } + + return nil +} + +func (m *InitOtpAuthIntent) validateEmailCustomization(formats strfmt.Registry) error { + if swag.IsZero(m.EmailCustomization) { // not required + return nil + } + + if m.EmailCustomization != nil { + if err := m.EmailCustomization.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("emailCustomization") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emailCustomization") + } + return err + } + } + + return nil +} + +func (m *InitOtpAuthIntent) validateOtpType(formats strfmt.Registry) error { + + if err := validate.Required("otpType", "body", m.OtpType); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this init otp auth intent based on the context it is used +func (m *InitOtpAuthIntent) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEmailCustomization(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InitOtpAuthIntent) contextValidateEmailCustomization(ctx context.Context, formats strfmt.Registry) error { + + if m.EmailCustomization != nil { + + if swag.IsZero(m.EmailCustomization) { // not required + return nil + } + + if err := m.EmailCustomization.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("emailCustomization") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("emailCustomization") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *InitOtpAuthIntent) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InitOtpAuthIntent) UnmarshalBinary(b []byte) error { + var res InitOtpAuthIntent + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/init_otp_auth_request.go b/pkg/api/models/init_otp_auth_request.go new file mode 100644 index 0000000..6dc5fb0 --- /dev/null +++ b/pkg/api/models/init_otp_auth_request.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// InitOtpAuthRequest init otp auth request +// +// swagger:model InitOtpAuthRequest +type InitOtpAuthRequest struct { + + // Unique identifier for a given Organization. + // Required: true + OrganizationID *string `json:"organizationId"` + + // parameters + // Required: true + Parameters *InitOtpAuthIntent `json:"parameters"` + + // Timestamp (in milliseconds) of the request, used to verify liveness of user requests. + // Required: true + TimestampMs *string `json:"timestampMs"` + + // type + // Required: true + // Enum: [ACTIVITY_TYPE_INIT_OTP_AUTH] + Type *string `json:"type"` +} + +// Validate validates this init otp auth request +func (m *InitOtpAuthRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOrganizationID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateParameters(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTimestampMs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InitOtpAuthRequest) validateOrganizationID(formats strfmt.Registry) error { + + if err := validate.Required("organizationId", "body", m.OrganizationID); err != nil { + return err + } + + return nil +} + +func (m *InitOtpAuthRequest) validateParameters(formats strfmt.Registry) error { + + if err := validate.Required("parameters", "body", m.Parameters); err != nil { + return err + } + + if m.Parameters != nil { + if err := m.Parameters.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("parameters") + } + return err + } + } + + return nil +} + +func (m *InitOtpAuthRequest) validateTimestampMs(formats strfmt.Registry) error { + + if err := validate.Required("timestampMs", "body", m.TimestampMs); err != nil { + return err + } + + return nil +} + +var initOtpAuthRequestTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_INIT_OTP_AUTH"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + initOtpAuthRequestTypeTypePropEnum = append(initOtpAuthRequestTypeTypePropEnum, v) + } +} + +const ( + + // InitOtpAuthRequestTypeACTIVITYTYPEINITOTPAUTH captures enum value "ACTIVITY_TYPE_INIT_OTP_AUTH" + InitOtpAuthRequestTypeACTIVITYTYPEINITOTPAUTH string = "ACTIVITY_TYPE_INIT_OTP_AUTH" +) + +// prop value enum +func (m *InitOtpAuthRequest) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, initOtpAuthRequestTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *InitOtpAuthRequest) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this init otp auth request based on the context it is used +func (m *InitOtpAuthRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateParameters(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InitOtpAuthRequest) contextValidateParameters(ctx context.Context, formats strfmt.Registry) error { + + if m.Parameters != nil { + + if err := m.Parameters.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("parameters") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *InitOtpAuthRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InitOtpAuthRequest) UnmarshalBinary(b []byte) error { + var res InitOtpAuthRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/init_otp_auth_result.go b/pkg/api/models/init_otp_auth_result.go new file mode 100644 index 0000000..edfd775 --- /dev/null +++ b/pkg/api/models/init_otp_auth_result.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// InitOtpAuthResult init otp auth result +// +// swagger:model InitOtpAuthResult +type InitOtpAuthResult struct { + + // Unique identifier for an OTP authentication + // Required: true + OtpID *string `json:"otpId"` +} + +// Validate validates this init otp auth result +func (m *InitOtpAuthResult) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOtpID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InitOtpAuthResult) validateOtpID(formats strfmt.Registry) error { + + if err := validate.Required("otpId", "body", m.OtpID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this init otp auth result based on context it is used +func (m *InitOtpAuthResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *InitOtpAuthResult) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InitOtpAuthResult) UnmarshalBinary(b []byte) error { + var res InitOtpAuthResult + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/intent.go b/pkg/api/models/intent.go index 42baa8f..473c4a4 100644 --- a/pkg/api/models/intent.go +++ b/pkg/api/models/intent.go @@ -105,6 +105,9 @@ type Intent struct { // create sub organization intent v6 CreateSubOrganizationIntentV6 *CreateSubOrganizationIntentV6 `json:"createSubOrganizationIntentV6,omitempty"` + // create sub organization intent v7 + CreateSubOrganizationIntentV7 *CreateSubOrganizationIntentV7 `json:"createSubOrganizationIntentV7,omitempty"` + // create user tag intent CreateUserTagIntent *CreateUserTagIntent `json:"createUserTagIntent,omitempty"` @@ -189,12 +192,18 @@ type Intent struct { // init import wallet intent InitImportWalletIntent *InitImportWalletIntent `json:"initImportWalletIntent,omitempty"` + // init otp auth intent + InitOtpAuthIntent *InitOtpAuthIntent `json:"initOtpAuthIntent,omitempty"` + // init user email recovery intent InitUserEmailRecoveryIntent *InitUserEmailRecoveryIntent `json:"initUserEmailRecoveryIntent,omitempty"` // oauth intent OauthIntent *OauthIntent `json:"oauthIntent,omitempty"` + // otp auth intent + OtpAuthIntent *OtpAuthIntent `json:"otpAuthIntent,omitempty"` + // recover user intent RecoverUserIntent *RecoverUserIntent `json:"recoverUserIntent,omitempty"` @@ -363,6 +372,10 @@ func (m *Intent) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCreateSubOrganizationIntentV7(formats); err != nil { + res = append(res, err) + } + if err := m.validateCreateUserTagIntent(formats); err != nil { res = append(res, err) } @@ -475,6 +488,10 @@ func (m *Intent) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateInitOtpAuthIntent(formats); err != nil { + res = append(res, err) + } + if err := m.validateInitUserEmailRecoveryIntent(formats); err != nil { res = append(res, err) } @@ -483,6 +500,10 @@ func (m *Intent) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateOtpAuthIntent(formats); err != nil { + res = append(res, err) + } + if err := m.validateRecoverUserIntent(formats); err != nil { res = append(res, err) } @@ -1089,6 +1110,25 @@ func (m *Intent) validateCreateSubOrganizationIntentV6(formats strfmt.Registry) return nil } +func (m *Intent) validateCreateSubOrganizationIntentV7(formats strfmt.Registry) error { + if swag.IsZero(m.CreateSubOrganizationIntentV7) { // not required + return nil + } + + if m.CreateSubOrganizationIntentV7 != nil { + if err := m.CreateSubOrganizationIntentV7.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createSubOrganizationIntentV7") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createSubOrganizationIntentV7") + } + return err + } + } + + return nil +} + func (m *Intent) validateCreateUserTagIntent(formats strfmt.Registry) error { if swag.IsZero(m.CreateUserTagIntent) { // not required return nil @@ -1621,6 +1661,25 @@ func (m *Intent) validateInitImportWalletIntent(formats strfmt.Registry) error { return nil } +func (m *Intent) validateInitOtpAuthIntent(formats strfmt.Registry) error { + if swag.IsZero(m.InitOtpAuthIntent) { // not required + return nil + } + + if m.InitOtpAuthIntent != nil { + if err := m.InitOtpAuthIntent.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("initOtpAuthIntent") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("initOtpAuthIntent") + } + return err + } + } + + return nil +} + func (m *Intent) validateInitUserEmailRecoveryIntent(formats strfmt.Registry) error { if swag.IsZero(m.InitUserEmailRecoveryIntent) { // not required return nil @@ -1659,6 +1718,25 @@ func (m *Intent) validateOauthIntent(formats strfmt.Registry) error { return nil } +func (m *Intent) validateOtpAuthIntent(formats strfmt.Registry) error { + if swag.IsZero(m.OtpAuthIntent) { // not required + return nil + } + + if m.OtpAuthIntent != nil { + if err := m.OtpAuthIntent.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("otpAuthIntent") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("otpAuthIntent") + } + return err + } + } + + return nil +} + func (m *Intent) validateRecoverUserIntent(formats strfmt.Registry) error { if swag.IsZero(m.RecoverUserIntent) { // not required return nil @@ -2098,6 +2176,10 @@ func (m *Intent) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateCreateSubOrganizationIntentV7(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateCreateUserTagIntent(ctx, formats); err != nil { res = append(res, err) } @@ -2210,6 +2292,10 @@ func (m *Intent) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateInitOtpAuthIntent(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateInitUserEmailRecoveryIntent(ctx, formats); err != nil { res = append(res, err) } @@ -2218,6 +2304,10 @@ func (m *Intent) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateOtpAuthIntent(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateRecoverUserIntent(ctx, formats); err != nil { res = append(res, err) } @@ -2880,6 +2970,27 @@ func (m *Intent) contextValidateCreateSubOrganizationIntentV6(ctx context.Contex return nil } +func (m *Intent) contextValidateCreateSubOrganizationIntentV7(ctx context.Context, formats strfmt.Registry) error { + + if m.CreateSubOrganizationIntentV7 != nil { + + if swag.IsZero(m.CreateSubOrganizationIntentV7) { // not required + return nil + } + + if err := m.CreateSubOrganizationIntentV7.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createSubOrganizationIntentV7") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createSubOrganizationIntentV7") + } + return err + } + } + + return nil +} + func (m *Intent) contextValidateCreateUserTagIntent(ctx context.Context, formats strfmt.Registry) error { if m.CreateUserTagIntent != nil { @@ -3468,6 +3579,27 @@ func (m *Intent) contextValidateInitImportWalletIntent(ctx context.Context, form return nil } +func (m *Intent) contextValidateInitOtpAuthIntent(ctx context.Context, formats strfmt.Registry) error { + + if m.InitOtpAuthIntent != nil { + + if swag.IsZero(m.InitOtpAuthIntent) { // not required + return nil + } + + if err := m.InitOtpAuthIntent.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("initOtpAuthIntent") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("initOtpAuthIntent") + } + return err + } + } + + return nil +} + func (m *Intent) contextValidateInitUserEmailRecoveryIntent(ctx context.Context, formats strfmt.Registry) error { if m.InitUserEmailRecoveryIntent != nil { @@ -3510,6 +3642,27 @@ func (m *Intent) contextValidateOauthIntent(ctx context.Context, formats strfmt. return nil } +func (m *Intent) contextValidateOtpAuthIntent(ctx context.Context, formats strfmt.Registry) error { + + if m.OtpAuthIntent != nil { + + if swag.IsZero(m.OtpAuthIntent) { // not required + return nil + } + + if err := m.OtpAuthIntent.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("otpAuthIntent") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("otpAuthIntent") + } + return err + } + } + + return nil +} + func (m *Intent) contextValidateRecoverUserIntent(ctx context.Context, formats strfmt.Registry) error { if m.RecoverUserIntent != nil { diff --git a/pkg/api/models/otp_auth_intent.go b/pkg/api/models/otp_auth_intent.go new file mode 100644 index 0000000..d5deb00 --- /dev/null +++ b/pkg/api/models/otp_auth_intent.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OtpAuthIntent otp auth intent +// +// swagger:model OtpAuthIntent +type OtpAuthIntent struct { + + // Optional human-readable name for an API Key. If none provided, default to OTP Auth - + APIKeyName string `json:"apiKeyName,omitempty"` + + // Expiration window (in seconds) indicating how long the API key is valid. If not provided, a default of 15 minutes will be used. + ExpirationSeconds string `json:"expirationSeconds,omitempty"` + + // Invalidate all other previously generated OTP Auth API keys + InvalidateExisting bool `json:"invalidateExisting,omitempty"` + + // 6 digit OTP code sent out to a user's contact (email or SMS) + // Required: true + OtpCode *string `json:"otpCode"` + + // ID representing the result of an init OTP activity. + // Required: true + OtpID *string `json:"otpId"` + + // Client-side public key generated by the user, to which the OTP bundle (credentials) will be encrypted. + TargetPublicKey string `json:"targetPublicKey,omitempty"` +} + +// Validate validates this otp auth intent +func (m *OtpAuthIntent) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOtpCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOtpID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OtpAuthIntent) validateOtpCode(formats strfmt.Registry) error { + + if err := validate.Required("otpCode", "body", m.OtpCode); err != nil { + return err + } + + return nil +} + +func (m *OtpAuthIntent) validateOtpID(formats strfmt.Registry) error { + + if err := validate.Required("otpId", "body", m.OtpID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this otp auth intent based on context it is used +func (m *OtpAuthIntent) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OtpAuthIntent) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OtpAuthIntent) UnmarshalBinary(b []byte) error { + var res OtpAuthIntent + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/otp_auth_request.go b/pkg/api/models/otp_auth_request.go new file mode 100644 index 0000000..9083e86 --- /dev/null +++ b/pkg/api/models/otp_auth_request.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OtpAuthRequest otp auth request +// +// swagger:model OtpAuthRequest +type OtpAuthRequest struct { + + // Unique identifier for a given Organization. + // Required: true + OrganizationID *string `json:"organizationId"` + + // parameters + // Required: true + Parameters *OtpAuthIntent `json:"parameters"` + + // Timestamp (in milliseconds) of the request, used to verify liveness of user requests. + // Required: true + TimestampMs *string `json:"timestampMs"` + + // type + // Required: true + // Enum: [ACTIVITY_TYPE_OTP_AUTH] + Type *string `json:"type"` +} + +// Validate validates this otp auth request +func (m *OtpAuthRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateOrganizationID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateParameters(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTimestampMs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OtpAuthRequest) validateOrganizationID(formats strfmt.Registry) error { + + if err := validate.Required("organizationId", "body", m.OrganizationID); err != nil { + return err + } + + return nil +} + +func (m *OtpAuthRequest) validateParameters(formats strfmt.Registry) error { + + if err := validate.Required("parameters", "body", m.Parameters); err != nil { + return err + } + + if m.Parameters != nil { + if err := m.Parameters.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("parameters") + } + return err + } + } + + return nil +} + +func (m *OtpAuthRequest) validateTimestampMs(formats strfmt.Registry) error { + + if err := validate.Required("timestampMs", "body", m.TimestampMs); err != nil { + return err + } + + return nil +} + +var otpAuthRequestTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["ACTIVITY_TYPE_OTP_AUTH"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + otpAuthRequestTypeTypePropEnum = append(otpAuthRequestTypeTypePropEnum, v) + } +} + +const ( + + // OtpAuthRequestTypeACTIVITYTYPEOTPAUTH captures enum value "ACTIVITY_TYPE_OTP_AUTH" + OtpAuthRequestTypeACTIVITYTYPEOTPAUTH string = "ACTIVITY_TYPE_OTP_AUTH" +) + +// prop value enum +func (m *OtpAuthRequest) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, otpAuthRequestTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *OtpAuthRequest) validateType(formats strfmt.Registry) error { + + if err := validate.Required("type", "body", m.Type); err != nil { + return err + } + + // value enum + if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this otp auth request based on the context it is used +func (m *OtpAuthRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateParameters(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OtpAuthRequest) contextValidateParameters(ctx context.Context, formats strfmt.Registry) error { + + if m.Parameters != nil { + + if err := m.Parameters.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("parameters") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OtpAuthRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OtpAuthRequest) UnmarshalBinary(b []byte) error { + var res OtpAuthRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/otp_auth_result.go b/pkg/api/models/otp_auth_result.go new file mode 100644 index 0000000..b175bd6 --- /dev/null +++ b/pkg/api/models/otp_auth_result.go @@ -0,0 +1,77 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OtpAuthResult otp auth result +// +// swagger:model OtpAuthResult +type OtpAuthResult struct { + + // Unique identifier for the created API key. + APIKeyID string `json:"apiKeyId,omitempty"` + + // HPKE encrypted credential bundle + CredentialBundle string `json:"credentialBundle,omitempty"` + + // Unique identifier for the authenticating User. + // Required: true + UserID *string `json:"userId"` +} + +// Validate validates this otp auth result +func (m *OtpAuthResult) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateUserID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OtpAuthResult) validateUserID(formats strfmt.Registry) error { + + if err := validate.Required("userId", "body", m.UserID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this otp auth result based on context it is used +func (m *OtpAuthResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OtpAuthResult) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OtpAuthResult) UnmarshalBinary(b []byte) error { + var res OtpAuthResult + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/result.go b/pkg/api/models/result.go index 712dbb9..1476bf0 100644 --- a/pkg/api/models/result.go +++ b/pkg/api/models/result.go @@ -81,6 +81,9 @@ type Result struct { // create sub organization result v6 CreateSubOrganizationResultV6 *CreateSubOrganizationResultV6 `json:"createSubOrganizationResultV6,omitempty"` + // create sub organization result v7 + CreateSubOrganizationResultV7 *CreateSubOrganizationResultV7 `json:"createSubOrganizationResultV7,omitempty"` + // create user tag result CreateUserTagResult *CreateUserTagResult `json:"createUserTagResult,omitempty"` @@ -159,12 +162,18 @@ type Result struct { // init import wallet result InitImportWalletResult *InitImportWalletResult `json:"initImportWalletResult,omitempty"` + // init otp auth result + InitOtpAuthResult *InitOtpAuthResult `json:"initOtpAuthResult,omitempty"` + // init user email recovery result InitUserEmailRecoveryResult *InitUserEmailRecoveryResult `json:"initUserEmailRecoveryResult,omitempty"` // oauth result OauthResult *OauthResult `json:"oauthResult,omitempty"` + // otp auth result + OtpAuthResult *OtpAuthResult `json:"otpAuthResult,omitempty"` + // recover user result RecoverUserResult *RecoverUserResult `json:"recoverUserResult,omitempty"` @@ -293,6 +302,10 @@ func (m *Result) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCreateSubOrganizationResultV7(formats); err != nil { + res = append(res, err) + } + if err := m.validateCreateUserTagResult(formats); err != nil { res = append(res, err) } @@ -397,6 +410,10 @@ func (m *Result) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateInitOtpAuthResult(formats); err != nil { + res = append(res, err) + } + if err := m.validateInitUserEmailRecoveryResult(formats); err != nil { res = append(res, err) } @@ -405,6 +422,10 @@ func (m *Result) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateOtpAuthResult(formats); err != nil { + res = append(res, err) + } + if err := m.validateRecoverUserResult(formats); err != nil { res = append(res, err) } @@ -854,6 +875,25 @@ func (m *Result) validateCreateSubOrganizationResultV6(formats strfmt.Registry) return nil } +func (m *Result) validateCreateSubOrganizationResultV7(formats strfmt.Registry) error { + if swag.IsZero(m.CreateSubOrganizationResultV7) { // not required + return nil + } + + if m.CreateSubOrganizationResultV7 != nil { + if err := m.CreateSubOrganizationResultV7.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createSubOrganizationResultV7") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createSubOrganizationResultV7") + } + return err + } + } + + return nil +} + func (m *Result) validateCreateUserTagResult(formats strfmt.Registry) error { if swag.IsZero(m.CreateUserTagResult) { // not required return nil @@ -1348,6 +1388,25 @@ func (m *Result) validateInitImportWalletResult(formats strfmt.Registry) error { return nil } +func (m *Result) validateInitOtpAuthResult(formats strfmt.Registry) error { + if swag.IsZero(m.InitOtpAuthResult) { // not required + return nil + } + + if m.InitOtpAuthResult != nil { + if err := m.InitOtpAuthResult.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("initOtpAuthResult") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("initOtpAuthResult") + } + return err + } + } + + return nil +} + func (m *Result) validateInitUserEmailRecoveryResult(formats strfmt.Registry) error { if swag.IsZero(m.InitUserEmailRecoveryResult) { // not required return nil @@ -1386,6 +1445,25 @@ func (m *Result) validateOauthResult(formats strfmt.Registry) error { return nil } +func (m *Result) validateOtpAuthResult(formats strfmt.Registry) error { + if swag.IsZero(m.OtpAuthResult) { // not required + return nil + } + + if m.OtpAuthResult != nil { + if err := m.OtpAuthResult.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("otpAuthResult") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("otpAuthResult") + } + return err + } + } + + return nil +} + func (m *Result) validateRecoverUserResult(formats strfmt.Registry) error { if swag.IsZero(m.RecoverUserResult) { // not required return nil @@ -1683,6 +1761,10 @@ func (m *Result) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateCreateSubOrganizationResultV7(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateCreateUserTagResult(ctx, formats); err != nil { res = append(res, err) } @@ -1787,6 +1869,10 @@ func (m *Result) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateInitOtpAuthResult(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateInitUserEmailRecoveryResult(ctx, formats); err != nil { res = append(res, err) } @@ -1795,6 +1881,10 @@ func (m *Result) ContextValidate(ctx context.Context, formats strfmt.Registry) e res = append(res, err) } + if err := m.contextValidateOtpAuthResult(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateRecoverUserResult(ctx, formats); err != nil { res = append(res, err) } @@ -2286,6 +2376,27 @@ func (m *Result) contextValidateCreateSubOrganizationResultV6(ctx context.Contex return nil } +func (m *Result) contextValidateCreateSubOrganizationResultV7(ctx context.Context, formats strfmt.Registry) error { + + if m.CreateSubOrganizationResultV7 != nil { + + if swag.IsZero(m.CreateSubOrganizationResultV7) { // not required + return nil + } + + if err := m.CreateSubOrganizationResultV7.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("createSubOrganizationResultV7") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("createSubOrganizationResultV7") + } + return err + } + } + + return nil +} + func (m *Result) contextValidateCreateUserTagResult(ctx context.Context, formats strfmt.Registry) error { if m.CreateUserTagResult != nil { @@ -2832,6 +2943,27 @@ func (m *Result) contextValidateInitImportWalletResult(ctx context.Context, form return nil } +func (m *Result) contextValidateInitOtpAuthResult(ctx context.Context, formats strfmt.Registry) error { + + if m.InitOtpAuthResult != nil { + + if swag.IsZero(m.InitOtpAuthResult) { // not required + return nil + } + + if err := m.InitOtpAuthResult.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("initOtpAuthResult") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("initOtpAuthResult") + } + return err + } + } + + return nil +} + func (m *Result) contextValidateInitUserEmailRecoveryResult(ctx context.Context, formats strfmt.Registry) error { if m.InitUserEmailRecoveryResult != nil { @@ -2874,6 +3006,27 @@ func (m *Result) contextValidateOauthResult(ctx context.Context, formats strfmt. return nil } +func (m *Result) contextValidateOtpAuthResult(ctx context.Context, formats strfmt.Registry) error { + + if m.OtpAuthResult != nil { + + if swag.IsZero(m.OtpAuthResult) { // not required + return nil + } + + if err := m.OtpAuthResult.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("otpAuthResult") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("otpAuthResult") + } + return err + } + } + + return nil +} + func (m *Result) contextValidateRecoverUserResult(ctx context.Context, formats strfmt.Registry) error { if m.RecoverUserResult != nil { diff --git a/pkg/api/models/root_user_params_v4.go b/pkg/api/models/root_user_params_v4.go new file mode 100644 index 0000000..fd71b28 --- /dev/null +++ b/pkg/api/models/root_user_params_v4.go @@ -0,0 +1,275 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RootUserParamsV4 root user params v4 +// +// swagger:model RootUserParamsV4 +type RootUserParamsV4 struct { + + // A list of API Key parameters. + // Required: true + APIKeys []*APIKeyParamsV2 `json:"apiKeys"` + + // A list of Authenticator parameters. + // Required: true + Authenticators []*AuthenticatorParamsV2 `json:"authenticators"` + + // A list of Oauth providers. + // Required: true + OauthProviders []*OauthProviderParams `json:"oauthProviders"` + + // The user's email address. + UserEmail string `json:"userEmail,omitempty"` + + // Human-readable name for a User. + // Required: true + UserName *string `json:"userName"` + + // The user's phone number in E.164 format e.g. +13214567890 + UserPhoneNumber string `json:"userPhoneNumber,omitempty"` +} + +// Validate validates this root user params v4 +func (m *RootUserParamsV4) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAPIKeys(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAuthenticators(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOauthProviders(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUserName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RootUserParamsV4) validateAPIKeys(formats strfmt.Registry) error { + + if err := validate.Required("apiKeys", "body", m.APIKeys); err != nil { + return err + } + + for i := 0; i < len(m.APIKeys); i++ { + if swag.IsZero(m.APIKeys[i]) { // not required + continue + } + + if m.APIKeys[i] != nil { + if err := m.APIKeys[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("apiKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("apiKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RootUserParamsV4) validateAuthenticators(formats strfmt.Registry) error { + + if err := validate.Required("authenticators", "body", m.Authenticators); err != nil { + return err + } + + for i := 0; i < len(m.Authenticators); i++ { + if swag.IsZero(m.Authenticators[i]) { // not required + continue + } + + if m.Authenticators[i] != nil { + if err := m.Authenticators[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authenticators" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authenticators" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RootUserParamsV4) validateOauthProviders(formats strfmt.Registry) error { + + if err := validate.Required("oauthProviders", "body", m.OauthProviders); err != nil { + return err + } + + for i := 0; i < len(m.OauthProviders); i++ { + if swag.IsZero(m.OauthProviders[i]) { // not required + continue + } + + if m.OauthProviders[i] != nil { + if err := m.OauthProviders[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oauthProviders" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oauthProviders" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RootUserParamsV4) validateUserName(formats strfmt.Registry) error { + + if err := validate.Required("userName", "body", m.UserName); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this root user params v4 based on the context it is used +func (m *RootUserParamsV4) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAPIKeys(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateAuthenticators(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOauthProviders(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RootUserParamsV4) contextValidateAPIKeys(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.APIKeys); i++ { + + if m.APIKeys[i] != nil { + + if swag.IsZero(m.APIKeys[i]) { // not required + return nil + } + + if err := m.APIKeys[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("apiKeys" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("apiKeys" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RootUserParamsV4) contextValidateAuthenticators(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Authenticators); i++ { + + if m.Authenticators[i] != nil { + + if swag.IsZero(m.Authenticators[i]) { // not required + return nil + } + + if err := m.Authenticators[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authenticators" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("authenticators" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *RootUserParamsV4) contextValidateOauthProviders(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.OauthProviders); i++ { + + if m.OauthProviders[i] != nil { + + if swag.IsZero(m.OauthProviders[i]) { // not required + return nil + } + + if err := m.OauthProviders[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oauthProviders" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oauthProviders" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RootUserParamsV4) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RootUserParamsV4) UnmarshalBinary(b []byte) error { + var res RootUserParamsV4 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/update_user_intent.go b/pkg/api/models/update_user_intent.go index dfc4087..9b403f2 100644 --- a/pkg/api/models/update_user_intent.go +++ b/pkg/api/models/update_user_intent.go @@ -29,6 +29,9 @@ type UpdateUserIntent struct { // Human-readable name for a User. UserName string `json:"userName,omitempty"` + // The user's phone number in E.164 format e.g. +13214567890 + UserPhoneNumber string `json:"userPhoneNumber,omitempty"` + // An updated list of User Tags to apply to this User. UserTagIds []string `json:"userTagIds"` } diff --git a/pkg/api/models/user.go b/pkg/api/models/user.go index 5ed7215..4347bbb 100644 --- a/pkg/api/models/user.go +++ b/pkg/api/models/user.go @@ -51,6 +51,9 @@ type User struct { // Required: true UserName *string `json:"userName"` + // The user's phone number in E.164 format e.g. +13214567890 + UserPhoneNumber string `json:"userPhoneNumber,omitempty"` + // A list of User Tag IDs. // Required: true UserTags []string `json:"userTags"`