mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
770 lines
28 KiB
Go
770 lines
28 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// NotifyAPIService NotifyAPI service
|
|
type NotifyAPIService service
|
|
|
|
type NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
provider string
|
|
key string
|
|
}
|
|
|
|
func (r NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.DeleteNotifyCredentialsByProviderByKeyExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteNotifyCredentialsByProviderByKey Removes one of your org's notify provider credentials.
|
|
|
|
Removes one of your org's notify provider credentials.
|
|
|
|
The value is forgotten in KMS. A provider missing a key it cannot send
|
|
without is no longer picked for its channel, and a send that pins it fails
|
|
with the key it lacks. Removing a key that is not set succeeds, since what was
|
|
asked for is already true. Org admin only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param provider Provider is the delivery provider the credential is for.
|
|
@param key Key is the credential's name within that provider.
|
|
@return NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest
|
|
*/
|
|
func (a *NotifyAPIService) DeleteNotifyCredentialsByProviderByKey(ctx context.Context, provider string, key string) NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest {
|
|
return NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
provider: provider,
|
|
key: key,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *NotifyAPIService) DeleteNotifyCredentialsByProviderByKeyExecute(r NotifyAPIDeleteNotifyCredentialsByProviderByKeyRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.DeleteNotifyCredentialsByProviderByKey")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/credentials/{provider}/{key}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"provider"+"}", url.PathEscape(parameterValueToString(r.provider, "provider")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"key"+"}", url.PathEscape(parameterValueToString(r.key, "key")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type NotifyAPIGetNotifyHealthRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
}
|
|
|
|
func (r NotifyAPIGetNotifyHealthRequest) Execute() (*NotifyNotifyHealth, *http.Response, error) {
|
|
return r.ApiService.GetNotifyHealthExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetNotifyHealth Reports that the notify send surface is mounted.
|
|
|
|
Reports that the notify send surface is mounted.
|
|
|
|
It is a pure liveness probe: it answers 200 whenever this subsystem is mounted
|
|
and checks nothing downstream, so an "ok" here says the routes are reachable, not
|
|
that any provider credential is configured. The body is notifyd's verbatim, so
|
|
probes and clients that keyed on the standalone service keep working unchanged.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return NotifyAPIGetNotifyHealthRequest
|
|
*/
|
|
func (a *NotifyAPIService) GetNotifyHealth(ctx context.Context) NotifyAPIGetNotifyHealthRequest {
|
|
return NotifyAPIGetNotifyHealthRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return NotifyNotifyHealth
|
|
func (a *NotifyAPIService) GetNotifyHealthExecute(r NotifyAPIGetNotifyHealthRequest) (*NotifyNotifyHealth, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *NotifyNotifyHealth
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.GetNotifyHealth")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/health"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type NotifyAPIPostNotifySendRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
notifyNotifySend *NotifyNotifySend
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendRequest) NotifyNotifySend(notifyNotifySend NotifyNotifySend) NotifyAPIPostNotifySendRequest {
|
|
r.notifyNotifySend = ¬ifyNotifySend
|
|
return r
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendRequest) Execute() (interface{}, *http.Response, error) {
|
|
return r.ApiService.PostNotifySendExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostNotifySend Delivers one transactional message by email or SMS through the caller org's own provider credential.
|
|
|
|
Delivers one transactional message by email or SMS through the caller
|
|
org's own provider credential.
|
|
|
|
The channel comes from the body — sms or email — and the provider credential is
|
|
read from KMS at orgs/<org>/notify/<service>/<key>, never from the environment.
|
|
The org is the validated principal's, never a client-supplied value, so a caller
|
|
can only ever send as their own tenant; an unauthenticated caller gets 401.
|
|
Naming no provider picks the one whose credentials are actually configured
|
|
(Twilio, then Plivo for SMS; Twilio Email, then SMTP for email) and fails closed
|
|
when none is. Delivery is synchronous and per recipient: one recipient answers
|
|
the bare {message_id,status} outcome, several answer the {items:[…]} envelope. A
|
|
terminal provider failure is a 200 whose status is failed with the reason in
|
|
error, never a transport error. sync=true is REQUIRED — an async dispatch
|
|
answers 503, because the queue plane that would run it is owned elsewhere. The
|
|
message body wins verbatim when present; otherwise template_id (or the event
|
|
name) selects a built-in template rendered against template_vars.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return NotifyAPIPostNotifySendRequest
|
|
*/
|
|
func (a *NotifyAPIService) PostNotifySend(ctx context.Context) NotifyAPIPostNotifySendRequest {
|
|
return NotifyAPIPostNotifySendRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return interface{}
|
|
func (a *NotifyAPIService) PostNotifySendExecute(r NotifyAPIPostNotifySendRequest) (interface{}, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue interface{}
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.PostNotifySend")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/send"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.notifyNotifySend == nil {
|
|
return localVarReturnValue, nil, reportError("notifyNotifySend is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.notifyNotifySend
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type NotifyAPIPostNotifySendEmailRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
notifyNotifySend *NotifyNotifySend
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendEmailRequest) NotifyNotifySend(notifyNotifySend NotifyNotifySend) NotifyAPIPostNotifySendEmailRequest {
|
|
r.notifyNotifySend = ¬ifyNotifySend
|
|
return r
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendEmailRequest) Execute() (interface{}, *http.Response, error) {
|
|
return r.ApiService.PostNotifySendEmailExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostNotifySendEmail Delivers one transactional email through the caller org's own provider credential.
|
|
|
|
Delivers one transactional email through the caller org's own
|
|
provider credential.
|
|
|
|
It is the channel-pinned form of the generic send: identical in every respect
|
|
except that the channel is fixed to email, OVERRIDING whatever the body names —
|
|
so a body that says sms still goes out as mail. The provider is the org's own
|
|
email credential from KMS (Twilio Email, then SMTP), resolved for the validated
|
|
principal's org; an unauthenticated caller gets 401. Subject is carried on the
|
|
email channel only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return NotifyAPIPostNotifySendEmailRequest
|
|
*/
|
|
func (a *NotifyAPIService) PostNotifySendEmail(ctx context.Context) NotifyAPIPostNotifySendEmailRequest {
|
|
return NotifyAPIPostNotifySendEmailRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return interface{}
|
|
func (a *NotifyAPIService) PostNotifySendEmailExecute(r NotifyAPIPostNotifySendEmailRequest) (interface{}, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue interface{}
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.PostNotifySendEmail")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/send/email"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.notifyNotifySend == nil {
|
|
return localVarReturnValue, nil, reportError("notifyNotifySend is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.notifyNotifySend
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type NotifyAPIPostNotifySendSmsRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
notifyNotifySend *NotifyNotifySend
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendSmsRequest) NotifyNotifySend(notifyNotifySend NotifyNotifySend) NotifyAPIPostNotifySendSmsRequest {
|
|
r.notifyNotifySend = ¬ifyNotifySend
|
|
return r
|
|
}
|
|
|
|
func (r NotifyAPIPostNotifySendSmsRequest) Execute() (interface{}, *http.Response, error) {
|
|
return r.ApiService.PostNotifySendSmsExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostNotifySendSms Delivers one transactional SMS through the caller org's own provider credential.
|
|
|
|
Delivers one transactional SMS through the caller org's own provider
|
|
credential.
|
|
|
|
It is the channel-pinned form of the generic send: identical in every respect
|
|
except that the channel is fixed to sms, OVERRIDING whatever the body names —
|
|
so a body that says email still goes out as a text message. The provider is the
|
|
org's own SMS credential from KMS (Twilio, then Plivo), resolved for the
|
|
validated principal's org; an unauthenticated caller gets 401.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return NotifyAPIPostNotifySendSmsRequest
|
|
*/
|
|
func (a *NotifyAPIService) PostNotifySendSms(ctx context.Context) NotifyAPIPostNotifySendSmsRequest {
|
|
return NotifyAPIPostNotifySendSmsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return interface{}
|
|
func (a *NotifyAPIService) PostNotifySendSmsExecute(r NotifyAPIPostNotifySendSmsRequest) (interface{}, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue interface{}
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.PostNotifySendSms")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/send/sms"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.notifyNotifySend == nil {
|
|
return localVarReturnValue, nil, reportError("notifyNotifySend is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.notifyNotifySend
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type NotifyAPIPutNotifyCredentialsByProviderByKeyRequest struct {
|
|
ctx context.Context
|
|
ApiService *NotifyAPIService
|
|
provider string
|
|
key string
|
|
notifyNotifyCredential *NotifyNotifyCredential
|
|
}
|
|
|
|
func (r NotifyAPIPutNotifyCredentialsByProviderByKeyRequest) NotifyNotifyCredential(notifyNotifyCredential NotifyNotifyCredential) NotifyAPIPutNotifyCredentialsByProviderByKeyRequest {
|
|
r.notifyNotifyCredential = ¬ifyNotifyCredential
|
|
return r
|
|
}
|
|
|
|
func (r NotifyAPIPutNotifyCredentialsByProviderByKeyRequest) Execute() (*NotifyNotifyStored, *http.Response, error) {
|
|
return r.ApiService.PutNotifyCredentialsByProviderByKeyExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutNotifyCredentialsByProviderByKey Sets one of your org's notify provider credentials.
|
|
|
|
Sets one of your org's notify provider credentials.
|
|
|
|
The value is sealed in KMS under your org and read by notify alone, at the
|
|
moment it sends; no route answers it back, this one included. Setting a key
|
|
that is already set replaces it, which is how a credential is rotated, and the
|
|
next send uses the new value. The key must be one the provider reads — Twilio's
|
|
account-sid, auth-token and from-number, say — and anything else is a 400
|
|
naming the keys it does read. An unknown provider is a 404.
|
|
|
|
Org admin only: a credential set here is what every message the org sends
|
|
goes out with.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param provider Provider is the delivery provider the credential is for: twilio, plivo, twilio_email or mail.
|
|
@param key Key is one of the credentials that provider reads, such as auth-token or smtp-host. A key the provider does not read is refused.
|
|
@return NotifyAPIPutNotifyCredentialsByProviderByKeyRequest
|
|
*/
|
|
func (a *NotifyAPIService) PutNotifyCredentialsByProviderByKey(ctx context.Context, provider string, key string) NotifyAPIPutNotifyCredentialsByProviderByKeyRequest {
|
|
return NotifyAPIPutNotifyCredentialsByProviderByKeyRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
provider: provider,
|
|
key: key,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return NotifyNotifyStored
|
|
func (a *NotifyAPIService) PutNotifyCredentialsByProviderByKeyExecute(r NotifyAPIPutNotifyCredentialsByProviderByKeyRequest) (*NotifyNotifyStored, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *NotifyNotifyStored
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "NotifyAPIService.PutNotifyCredentialsByProviderByKey")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/notify/credentials/{provider}/{key}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"provider"+"}", url.PathEscape(parameterValueToString(r.provider, "provider")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"key"+"}", url.PathEscape(parameterValueToString(r.key, "key")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.notifyNotifyCredential == nil {
|
|
return localVarReturnValue, nil, reportError("notifyNotifyCredential is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.notifyNotifyCredential
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|