feat: generating code

This commit is contained in:
Marcel_Henselin 2026-01-21 09:07:29 +01:00
parent c329d58970
commit 51663cd8d0
1221 changed files with 271709 additions and 2444 deletions

View file

@ -217,7 +217,7 @@ type DefaultApi interface {
@param region The region which should be addressed
@return ApiGetFlavorsRequestRequest
*/
GetFlavorsRequest(ctx context.Context, projectId string, region string, page, size *int64, sort *FlavorSort) ApiGetFlavorsRequestRequest
GetFlavorsRequest(ctx context.Context, projectId string, region string) ApiGetFlavorsRequestRequest
/*
GetFlavorsRequestExecute executes the request
@ -227,7 +227,7 @@ type DefaultApi interface {
@return GetFlavorsResponse
*/
GetFlavorsRequestExecute(ctx context.Context, projectId string, region string, page, size *int64, sort *FlavorSort) (*GetFlavorsResponse, error)
GetFlavorsRequestExecute(ctx context.Context, projectId string, region string) (*GetFlavorsResponse, error)
/*
GetInstanceRequest Get Specific Instance
Get information about a specific available instance
@ -514,6 +514,25 @@ type DefaultApi interface {
*/
ResetUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) (*ResetUserResponse, error)
/*
RestoreDatabaseFromBackup Create a Restore Operation
Triggers a new restore operation for the specified instance.
The request body defines the source
(e.g., internal backup, external S3) and the target database.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId The STACKIT project ID.
@param region The region which should be addressed
@param instanceId The ID of the instance.
@return ApiRestoreDatabaseFromBackupRequest
*/
RestoreDatabaseFromBackup(ctx context.Context, projectId string, region string, instanceId string) ApiRestoreDatabaseFromBackupRequest
/*
RestoreDatabaseFromBackupExecute executes the request
*/
RestoreDatabaseFromBackupExecute(ctx context.Context, projectId string, region string, instanceId string) error
/*
TriggerBackupRequest Trigger backup for a specific Database
Trigger backup for a specific database
@ -718,6 +737,12 @@ type ApiResetUserRequestRequest interface {
Execute() (*ResetUserResponse, error)
}
type ApiRestoreDatabaseFromBackupRequest interface {
// The restore operation payload.
RestoreDatabaseFromBackupPayload(restoreDatabaseFromBackupPayload RestoreDatabaseFromBackupPayload) ApiRestoreDatabaseFromBackupRequest
Execute() error
}
type ApiTriggerBackupRequestRequest interface {
Execute() error
}
@ -2700,27 +2725,21 @@ Get all available flavors for a project.
@param region The region which should be addressed
@return ApiGetFlavorsRequestRequest
*/
func (a *APIClient) GetFlavorsRequest(ctx context.Context, projectId string, region string, page, size *int64, sort *FlavorSort) ApiGetFlavorsRequestRequest {
func (a *APIClient) GetFlavorsRequest(ctx context.Context, projectId string, region string) ApiGetFlavorsRequestRequest {
return GetFlavorsRequestRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
page: page,
size: size,
sort: sort,
}
}
func (a *APIClient) GetFlavorsRequestExecute(ctx context.Context, projectId string, region string, page, size *int64, sort *FlavorSort) (*GetFlavorsResponse, error) {
func (a *APIClient) GetFlavorsRequestExecute(ctx context.Context, projectId string, region string) (*GetFlavorsResponse, error) {
r := GetFlavorsRequestRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
page: page,
size: size,
sort: sort,
}
return r.Execute()
}
@ -5363,6 +5382,206 @@ func (a *APIClient) ResetUserRequestExecute(ctx context.Context, projectId strin
return r.Execute()
}
type RestoreDatabaseFromBackupRequest struct {
ctx context.Context
apiService *DefaultApiService
projectId string
region string
instanceId string
restoreDatabaseFromBackupPayload *RestoreDatabaseFromBackupPayload
}
// The restore operation payload.
func (r RestoreDatabaseFromBackupRequest) RestoreDatabaseFromBackupPayload(restoreDatabaseFromBackupPayload RestoreDatabaseFromBackupPayload) ApiRestoreDatabaseFromBackupRequest {
r.restoreDatabaseFromBackupPayload = &restoreDatabaseFromBackupPayload
return r
}
func (r RestoreDatabaseFromBackupRequest) Execute() error {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
a := r.apiService
client, ok := a.client.(*APIClient)
if !ok {
return fmt.Errorf("could not parse client to type APIClient")
}
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.RestoreDatabaseFromBackup")
if err != nil {
return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
}
localVarPath := localBasePath + "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/restores"
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.restoreDatabaseFromBackupPayload == nil {
return fmt.Errorf("restoreDatabaseFromBackupPayload 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"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.restoreDatabaseFromBackupPayload
req, err := client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return err
}
contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request)
if ok {
*contextHTTPRequest = req
}
localVarHTTPResponse, err := client.callAPI(req)
contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response)
if ok {
*contextHTTPResponse = localVarHTTPResponse
}
if err != nil || localVarHTTPResponse == nil {
return err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &oapierror.GenericOpenAPIError{
StatusCode: localVarHTTPResponse.StatusCode,
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
return newErr
}
if localVarHTTPResponse.StatusCode == 501 {
var v Error
err = client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return newErr
}
newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.Model = v
}
return newErr
}
return nil
}
/*
RestoreDatabaseFromBackup: Create a Restore Operation
Triggers a new restore operation for the specified instance.
The request body defines the source
(e.g., internal backup, external S3) and the target database.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param projectId The STACKIT project ID.
@param region The region which should be addressed
@param instanceId The ID of the instance.
@return ApiRestoreDatabaseFromBackupRequest
*/
func (a *APIClient) RestoreDatabaseFromBackup(ctx context.Context, projectId string, region string, instanceId string) ApiRestoreDatabaseFromBackupRequest {
return RestoreDatabaseFromBackupRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
instanceId: instanceId,
}
}
func (a *APIClient) RestoreDatabaseFromBackupExecute(ctx context.Context, projectId string, region string, instanceId string) error {
r := RestoreDatabaseFromBackupRequest{
apiService: a.defaultApi,
ctx: ctx,
projectId: projectId,
region: region,
instanceId: instanceId,
}
return r.Execute()
}
type TriggerBackupRequestRequest struct {
ctx context.Context
apiService *DefaultApiService

View file

@ -26,20 +26,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService CreateDatabaseRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := CreateDatabaseResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -88,18 +85,15 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService CreateInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := CreateInstanceResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -147,20 +141,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService CreateUserRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := CreateUserResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -209,13 +200,13 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService DeleteDatabaseRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
databaseNameValue := "databaseName-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -264,11 +255,11 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService DeleteInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -316,13 +307,13 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService DeleteUserRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -371,22 +362,19 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetBackupRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
backupIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetBackupResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -435,20 +423,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetCollationsRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/collations"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetCollationsResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -496,22 +481,19 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetDatabaseRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseName}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
databaseNameValue := "databaseName-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetDatabaseResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -560,18 +542,15 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetFlavorsRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/flavors"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetFlavorsResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -605,10 +584,7 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
projectId := projectIdValue
region := regionValue
page := int64(1)
size := int64(10)
sort := FLAVORSORT_ID_DESC
resp, reqErr := apiClient.GetFlavorsRequest(context.Background(), projectId, region, &page, &size, &sort).Execute()
resp, reqErr := apiClient.GetFlavorsRequest(context.Background(), projectId, region).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
@ -621,20 +597,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetInstanceResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -682,20 +655,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetStoragesRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/storages/{flavorId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
flavorIdValue := "flavorId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"flavorId"+"}", url.PathEscape(ParameterValueToString(flavorIdValue, "flavorId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"flavorId"+"}", url.PathEscape(ParameterValueToString(flavorIdValue, "flavorId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetStoragesResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -743,22 +713,19 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetUserRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetUserResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -807,18 +774,15 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService GetVersionsRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/versions"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := GetVersionsResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -865,20 +829,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListBackupsRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListBackupResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -926,20 +887,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListCompatibilitiesRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/compatibility"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListCompatibilityResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -987,20 +945,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListCurrentRunningRestoreJobs", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/restore-jobs"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListCurrentRunningRestoreJobs{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1048,20 +1003,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListDatabasesRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListDatabasesResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1109,18 +1061,15 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListInstancesRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListInstancesResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1167,20 +1116,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListRolesRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/roles"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListRolesResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1228,20 +1174,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ListUsersRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ListUserResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1289,20 +1232,17 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ProtectInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/protections"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ProtectInstanceResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1351,22 +1291,19 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService ResetUserRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/users/{userId}/reset"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"userId"+"}", url.PathEscape(ParameterValueToString(userIdValue, "userId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := ResetUserResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
json.NewEncoder(w).Encode(data)
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
@ -1412,16 +1349,69 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
}
})
t.Run("Test DefaultApiService RestoreDatabaseFromBackup", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/restores"
projectIdValue := "projectId-value"
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
})
testServer := httptest.NewServer(testDefaultApiServeMux)
defer testServer.Close()
configuration := &config.Configuration{
DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/1.0.0/go",
Debug: false,
Region: "test_region",
Servers: config.ServerConfigurations{
{
URL: testServer.URL,
Description: "Localhost for sqlserverflexalpha_DefaultApi",
Variables: map[string]config.ServerVariable{
"region": {
DefaultValue: "test_region.",
EnumValues: []string{
"test_region.",
},
},
},
},
},
OperationServers: map[string]config.ServerConfigurations{},
}
apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication())
if err != nil {
t.Fatalf("creating API client: %v", err)
}
projectId := projectIdValue
region := regionValue
instanceId := instanceIdValue
restoreDatabaseFromBackupPayload := RestoreDatabaseFromBackupPayload{}
reqErr := apiClient.RestoreDatabaseFromBackup(context.Background(), projectId, region, instanceId).RestoreDatabaseFromBackupPayload(restoreDatabaseFromBackupPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
})
t.Run("Test DefaultApiService TriggerBackupRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
databaseNameValue := "databaseName-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -1470,13 +1460,13 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService TriggerRestoreRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/databases/{databaseName}/restores"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
databaseNameValue := "databaseName-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"databaseName"+"}", url.PathEscape(ParameterValueToString(databaseNameValue, "databaseName")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -1525,11 +1515,11 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService UpdateInstancePartiallyRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
@ -1578,11 +1568,11 @@ func Test_sqlserverflexalpha_DefaultApiService(t *testing.T) {
t.Run("Test DefaultApiService UpdateInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(regionValue, "region")), -1)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")))
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {

View file

@ -0,0 +1,261 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
)
// checks if the ExternalS3 type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ExternalS3{}
/*
types and functions for s3_access_key
*/
// isNotNullableString
type ExternalS3GetS3AccessKeyAttributeType = *string
func getExternalS3GetS3AccessKeyAttributeTypeOk(arg ExternalS3GetS3AccessKeyAttributeType) (ret ExternalS3GetS3AccessKeyRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setExternalS3GetS3AccessKeyAttributeType(arg *ExternalS3GetS3AccessKeyAttributeType, val ExternalS3GetS3AccessKeyRetType) {
*arg = &val
}
type ExternalS3GetS3AccessKeyArgType = string
type ExternalS3GetS3AccessKeyRetType = string
/*
types and functions for s3_access_secret
*/
// isNotNullableString
type ExternalS3GetS3AccessSecretAttributeType = *string
func getExternalS3GetS3AccessSecretAttributeTypeOk(arg ExternalS3GetS3AccessSecretAttributeType) (ret ExternalS3GetS3AccessSecretRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setExternalS3GetS3AccessSecretAttributeType(arg *ExternalS3GetS3AccessSecretAttributeType, val ExternalS3GetS3AccessSecretRetType) {
*arg = &val
}
type ExternalS3GetS3AccessSecretArgType = string
type ExternalS3GetS3AccessSecretRetType = string
/*
types and functions for s3_bucket
*/
// isNotNullableString
type ExternalS3GetS3BucketAttributeType = *string
func getExternalS3GetS3BucketAttributeTypeOk(arg ExternalS3GetS3BucketAttributeType) (ret ExternalS3GetS3BucketRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setExternalS3GetS3BucketAttributeType(arg *ExternalS3GetS3BucketAttributeType, val ExternalS3GetS3BucketRetType) {
*arg = &val
}
type ExternalS3GetS3BucketArgType = string
type ExternalS3GetS3BucketRetType = string
/*
types and functions for s3_files
*/
// isArray
type ExternalS3GetS3FilesAttributeType = *[]S3fileInfo
type ExternalS3GetS3FilesArgType = []S3fileInfo
type ExternalS3GetS3FilesRetType = []S3fileInfo
func getExternalS3GetS3FilesAttributeTypeOk(arg ExternalS3GetS3FilesAttributeType) (ret ExternalS3GetS3FilesRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setExternalS3GetS3FilesAttributeType(arg *ExternalS3GetS3FilesAttributeType, val ExternalS3GetS3FilesRetType) {
*arg = &val
}
// ExternalS3 The external S3 information
type ExternalS3 struct {
// The s3 access key id
// REQUIRED
S3AccessKey ExternalS3GetS3AccessKeyAttributeType `json:"s3_access_key" required:"true"`
// The s3 access secret
// REQUIRED
S3AccessSecret ExternalS3GetS3AccessSecretAttributeType `json:"s3_access_secret" required:"true"`
// The s3 bucket address
// REQUIRED
S3Bucket ExternalS3GetS3BucketAttributeType `json:"s3_bucket" required:"true"`
// The backup files from which the database should be restored
// REQUIRED
S3Files ExternalS3GetS3FilesAttributeType `json:"s3_files" required:"true"`
}
type _ExternalS3 ExternalS3
// NewExternalS3 instantiates a new ExternalS3 object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewExternalS3(s3AccessKey ExternalS3GetS3AccessKeyArgType, s3AccessSecret ExternalS3GetS3AccessSecretArgType, s3Bucket ExternalS3GetS3BucketArgType, s3Files ExternalS3GetS3FilesArgType) *ExternalS3 {
this := ExternalS3{}
setExternalS3GetS3AccessKeyAttributeType(&this.S3AccessKey, s3AccessKey)
setExternalS3GetS3AccessSecretAttributeType(&this.S3AccessSecret, s3AccessSecret)
setExternalS3GetS3BucketAttributeType(&this.S3Bucket, s3Bucket)
setExternalS3GetS3FilesAttributeType(&this.S3Files, s3Files)
return &this
}
// NewExternalS3WithDefaults instantiates a new ExternalS3 object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewExternalS3WithDefaults() *ExternalS3 {
this := ExternalS3{}
return &this
}
// GetS3AccessKey returns the S3AccessKey field value
func (o *ExternalS3) GetS3AccessKey() (ret ExternalS3GetS3AccessKeyRetType) {
ret, _ = o.GetS3AccessKeyOk()
return ret
}
// GetS3AccessKeyOk returns a tuple with the S3AccessKey field value
// and a boolean to check if the value has been set.
func (o *ExternalS3) GetS3AccessKeyOk() (ret ExternalS3GetS3AccessKeyRetType, ok bool) {
return getExternalS3GetS3AccessKeyAttributeTypeOk(o.S3AccessKey)
}
// SetS3AccessKey sets field value
func (o *ExternalS3) SetS3AccessKey(v ExternalS3GetS3AccessKeyRetType) {
setExternalS3GetS3AccessKeyAttributeType(&o.S3AccessKey, v)
}
// GetS3AccessSecret returns the S3AccessSecret field value
func (o *ExternalS3) GetS3AccessSecret() (ret ExternalS3GetS3AccessSecretRetType) {
ret, _ = o.GetS3AccessSecretOk()
return ret
}
// GetS3AccessSecretOk returns a tuple with the S3AccessSecret field value
// and a boolean to check if the value has been set.
func (o *ExternalS3) GetS3AccessSecretOk() (ret ExternalS3GetS3AccessSecretRetType, ok bool) {
return getExternalS3GetS3AccessSecretAttributeTypeOk(o.S3AccessSecret)
}
// SetS3AccessSecret sets field value
func (o *ExternalS3) SetS3AccessSecret(v ExternalS3GetS3AccessSecretRetType) {
setExternalS3GetS3AccessSecretAttributeType(&o.S3AccessSecret, v)
}
// GetS3Bucket returns the S3Bucket field value
func (o *ExternalS3) GetS3Bucket() (ret ExternalS3GetS3BucketRetType) {
ret, _ = o.GetS3BucketOk()
return ret
}
// GetS3BucketOk returns a tuple with the S3Bucket field value
// and a boolean to check if the value has been set.
func (o *ExternalS3) GetS3BucketOk() (ret ExternalS3GetS3BucketRetType, ok bool) {
return getExternalS3GetS3BucketAttributeTypeOk(o.S3Bucket)
}
// SetS3Bucket sets field value
func (o *ExternalS3) SetS3Bucket(v ExternalS3GetS3BucketRetType) {
setExternalS3GetS3BucketAttributeType(&o.S3Bucket, v)
}
// GetS3Files returns the S3Files field value
func (o *ExternalS3) GetS3Files() (ret ExternalS3GetS3FilesRetType) {
ret, _ = o.GetS3FilesOk()
return ret
}
// GetS3FilesOk returns a tuple with the S3Files field value
// and a boolean to check if the value has been set.
func (o *ExternalS3) GetS3FilesOk() (ret ExternalS3GetS3FilesRetType, ok bool) {
return getExternalS3GetS3FilesAttributeTypeOk(o.S3Files)
}
// SetS3Files sets field value
func (o *ExternalS3) SetS3Files(v ExternalS3GetS3FilesRetType) {
setExternalS3GetS3FilesAttributeType(&o.S3Files, v)
}
func (o ExternalS3) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if val, ok := getExternalS3GetS3AccessKeyAttributeTypeOk(o.S3AccessKey); ok {
toSerialize["S3AccessKey"] = val
}
if val, ok := getExternalS3GetS3AccessSecretAttributeTypeOk(o.S3AccessSecret); ok {
toSerialize["S3AccessSecret"] = val
}
if val, ok := getExternalS3GetS3BucketAttributeTypeOk(o.S3Bucket); ok {
toSerialize["S3Bucket"] = val
}
if val, ok := getExternalS3GetS3FilesAttributeTypeOk(o.S3Files); ok {
toSerialize["S3Files"] = val
}
return toSerialize, nil
}
type NullableExternalS3 struct {
value *ExternalS3
isSet bool
}
func (v NullableExternalS3) Get() *ExternalS3 {
return v.value
}
func (v *NullableExternalS3) Set(val *ExternalS3) {
v.value = val
v.isSet = true
}
func (v NullableExternalS3) IsSet() bool {
return v.isSet
}
func (v *NullableExternalS3) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableExternalS3(val *ExternalS3) *NullableExternalS3 {
return &NullableExternalS3{value: val, isSet: true}
}
func (v NullableExternalS3) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableExternalS3) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,11 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha

View file

@ -21,26 +21,8 @@ var _ MappedNullable = &GetBackupResponse{}
types and functions for completionTime
*/
//// isAny
//type GetBackupResponseGetCompletionTimeAttributeType = any
//type GetBackupResponseGetCompletionTimeArgType = any
//type GetBackupResponseGetCompletionTimeRetType = any
//
//func getGetBackupResponseGetCompletionTimeAttributeTypeOk(arg GetBackupResponseGetCompletionTimeAttributeType) (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetCompletionTimeAttributeType(arg *GetBackupResponseGetCompletionTimeAttributeType, val GetBackupResponseGetCompletionTimeRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type GetBackupResponseGetCompletionTimeAttributeType = *string
type GetBackupResponseGetCompletionTimeArgType = string
type GetBackupResponseGetCompletionTimeRetType = string
func getGetBackupResponseGetCompletionTimeAttributeTypeOk(arg GetBackupResponseGetCompletionTimeAttributeType) (ret GetBackupResponseGetCompletionTimeRetType, ok bool) {
if arg == nil {
@ -53,27 +35,14 @@ func setGetBackupResponseGetCompletionTimeAttributeType(arg *GetBackupResponseGe
*arg = &val
}
type GetBackupResponseGetCompletionTimeArgType = string
type GetBackupResponseGetCompletionTimeRetType = string
/*
types and functions for id
*/
//// isAny
//type GetBackupResponseGetIdAttributeType = any
//type GetBackupResponseGetIdArgType = any
//type GetBackupResponseGetIdRetType = any
//
//func getGetBackupResponseGetIdAttributeTypeOk(arg GetBackupResponseGetIdAttributeType) (ret GetBackupResponseGetIdRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetIdAttributeType(arg *GetBackupResponseGetIdAttributeType, val GetBackupResponseGetIdRetType) {
// *arg = &val
//}
// isModel
// isLong
type GetBackupResponseGetIdAttributeType = *int64
type GetBackupResponseGetIdArgType = int64
type GetBackupResponseGetIdRetType = int64
@ -93,26 +62,8 @@ func setGetBackupResponseGetIdAttributeType(arg *GetBackupResponseGetIdAttribute
types and functions for name
*/
//// isAny
//type GetBackupResponseGetNameAttributeType = any
//type GetBackupResponseGetNameArgType = any
//type GetBackupResponseGetNameRetType = any
//
//func getGetBackupResponseGetNameAttributeTypeOk(arg GetBackupResponseGetNameAttributeType) (ret GetBackupResponseGetNameRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetNameAttributeType(arg *GetBackupResponseGetNameAttributeType, val GetBackupResponseGetNameRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type GetBackupResponseGetNameAttributeType = *string
type GetBackupResponseGetNameArgType = string
type GetBackupResponseGetNameRetType = string
func getGetBackupResponseGetNameAttributeTypeOk(arg GetBackupResponseGetNameAttributeType) (ret GetBackupResponseGetNameRetType, ok bool) {
if arg == nil {
@ -125,30 +76,15 @@ func setGetBackupResponseGetNameAttributeType(arg *GetBackupResponseGetNameAttri
*arg = &val
}
type GetBackupResponseGetNameArgType = string
type GetBackupResponseGetNameRetType = string
/*
types and functions for retainedUntil
*/
//// isAny
//type GetBackupResponseGetRetainedUntilAttributeType = any
//type GetBackupResponseGetRetainedUntilArgType = any
//type GetBackupResponseGetRetainedUntilRetType = any
//
//func getGetBackupResponseGetRetainedUntilAttributeTypeOk(arg GetBackupResponseGetRetainedUntilAttributeType) (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetRetainedUntilAttributeType(arg *GetBackupResponseGetRetainedUntilAttributeType, val GetBackupResponseGetRetainedUntilRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type GetBackupResponseGetRetainedUntilAttributeType = *string
type GetBackupResponseGetRetainedUntilArgType = string
type GetBackupResponseGetRetainedUntilRetType = string
func getGetBackupResponseGetRetainedUntilAttributeTypeOk(arg GetBackupResponseGetRetainedUntilAttributeType) (ret GetBackupResponseGetRetainedUntilRetType, ok bool) {
if arg == nil {
@ -161,27 +97,14 @@ func setGetBackupResponseGetRetainedUntilAttributeType(arg *GetBackupResponseGet
*arg = &val
}
type GetBackupResponseGetRetainedUntilArgType = string
type GetBackupResponseGetRetainedUntilRetType = string
/*
types and functions for size
*/
//// isAny
//type GetBackupResponseGetSizeAttributeType = any
//type GetBackupResponseGetSizeArgType = any
//type GetBackupResponseGetSizeRetType = any
//
//func getGetBackupResponseGetSizeAttributeTypeOk(arg GetBackupResponseGetSizeAttributeType) (ret GetBackupResponseGetSizeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetSizeAttributeType(arg *GetBackupResponseGetSizeAttributeType, val GetBackupResponseGetSizeRetType) {
// *arg = &val
//}
// isModel
// isLong
type GetBackupResponseGetSizeAttributeType = *int64
type GetBackupResponseGetSizeArgType = int64
type GetBackupResponseGetSizeRetType = int64
@ -201,26 +124,8 @@ func setGetBackupResponseGetSizeAttributeType(arg *GetBackupResponseGetSizeAttri
types and functions for type
*/
//// isAny
//type GetBackupResponseGetTypeAttributeType = any
//type GetBackupResponseGetTypeArgType = any
//type GetBackupResponseGetTypeRetType = any
//
//func getGetBackupResponseGetTypeAttributeTypeOk(arg GetBackupResponseGetTypeAttributeType) (ret GetBackupResponseGetTypeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setGetBackupResponseGetTypeAttributeType(arg *GetBackupResponseGetTypeAttributeType, val GetBackupResponseGetTypeRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type GetBackupResponseGetTypeAttributeType = *string
type GetBackupResponseGetTypeArgType = string
type GetBackupResponseGetTypeRetType = string
func getGetBackupResponseGetTypeAttributeTypeOk(arg GetBackupResponseGetTypeAttributeType) (ret GetBackupResponseGetTypeRetType, ok bool) {
if arg == nil {
@ -233,18 +138,27 @@ func setGetBackupResponseGetTypeAttributeType(arg *GetBackupResponseGetTypeAttri
*arg = &val
}
type GetBackupResponseGetTypeArgType = string
type GetBackupResponseGetTypeRetType = string
// GetBackupResponse struct for GetBackupResponse
type GetBackupResponse struct {
// The time when the backup was completed in RFC3339 format.
// REQUIRED
CompletionTime GetBackupResponseGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
// The ID of the backup.
// REQUIRED
Id GetBackupResponseGetIdAttributeType `json:"id" required:"true"`
// The name of the backup.
// REQUIRED
Name GetBackupResponseGetNameAttributeType `json:"name" required:"true"`
// The time until the backup will be retained.
// REQUIRED
RetainedUntil GetBackupResponseGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
// The size of the backup in bytes.
// REQUIRED
Size GetBackupResponseGetSizeAttributeType `json:"size" required:"true"`
// The type of the backup, which can be automated or manual triggered.
// REQUIRED
Type GetBackupResponseGetTypeAttributeType `json:"type" required:"true"`
}

View file

@ -21,26 +21,8 @@ var _ MappedNullable = &ListBackup{}
types and functions for completionTime
*/
//// isAny
//type ListBackupGetCompletionTimeAttributeType = any
//type ListBackupGetCompletionTimeArgType = any
//type ListBackupGetCompletionTimeRetType = any
//
//func getListBackupGetCompletionTimeAttributeTypeOk(arg ListBackupGetCompletionTimeAttributeType) (ret ListBackupGetCompletionTimeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetCompletionTimeAttributeType(arg *ListBackupGetCompletionTimeAttributeType, val ListBackupGetCompletionTimeRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type ListBackupGetCompletionTimeAttributeType = *string
type ListBackupGetCompletionTimeArgType = string
type ListBackupGetCompletionTimeRetType = string
func getListBackupGetCompletionTimeAttributeTypeOk(arg ListBackupGetCompletionTimeAttributeType) (ret ListBackupGetCompletionTimeRetType, ok bool) {
if arg == nil {
@ -53,27 +35,14 @@ func setListBackupGetCompletionTimeAttributeType(arg *ListBackupGetCompletionTim
*arg = &val
}
type ListBackupGetCompletionTimeArgType = string
type ListBackupGetCompletionTimeRetType = string
/*
types and functions for id
*/
//// isAny
//type ListBackupGetIdAttributeType = any
//type ListBackupGetIdArgType = any
//type ListBackupGetIdRetType = any
//
//func getListBackupGetIdAttributeTypeOk(arg ListBackupGetIdAttributeType) (ret ListBackupGetIdRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetIdAttributeType(arg *ListBackupGetIdAttributeType, val ListBackupGetIdRetType) {
// *arg = &val
//}
// isModel
// isLong
type ListBackupGetIdAttributeType = *int64
type ListBackupGetIdArgType = int64
type ListBackupGetIdRetType = int64
@ -93,26 +62,8 @@ func setListBackupGetIdAttributeType(arg *ListBackupGetIdAttributeType, val List
types and functions for name
*/
//// isAny
//type ListBackupGetNameAttributeType = any
//type ListBackupGetNameArgType = any
//type ListBackupGetNameRetType = any
//
//func getListBackupGetNameAttributeTypeOk(arg ListBackupGetNameAttributeType) (ret ListBackupGetNameRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetNameAttributeType(arg *ListBackupGetNameAttributeType, val ListBackupGetNameRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type ListBackupGetNameAttributeType = *string
type ListBackupGetNameArgType = string
type ListBackupGetNameRetType = string
func getListBackupGetNameAttributeTypeOk(arg ListBackupGetNameAttributeType) (ret ListBackupGetNameRetType, ok bool) {
if arg == nil {
@ -125,30 +76,15 @@ func setListBackupGetNameAttributeType(arg *ListBackupGetNameAttributeType, val
*arg = &val
}
type ListBackupGetNameArgType = string
type ListBackupGetNameRetType = string
/*
types and functions for retainedUntil
*/
//// isAny
//type ListBackupGetRetainedUntilAttributeType = any
//type ListBackupGetRetainedUntilArgType = any
//type ListBackupGetRetainedUntilRetType = any
//
//func getListBackupGetRetainedUntilAttributeTypeOk(arg ListBackupGetRetainedUntilAttributeType) (ret ListBackupGetRetainedUntilRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetRetainedUntilAttributeType(arg *ListBackupGetRetainedUntilAttributeType, val ListBackupGetRetainedUntilRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type ListBackupGetRetainedUntilAttributeType = *string
type ListBackupGetRetainedUntilArgType = string
type ListBackupGetRetainedUntilRetType = string
func getListBackupGetRetainedUntilAttributeTypeOk(arg ListBackupGetRetainedUntilAttributeType) (ret ListBackupGetRetainedUntilRetType, ok bool) {
if arg == nil {
@ -161,27 +97,14 @@ func setListBackupGetRetainedUntilAttributeType(arg *ListBackupGetRetainedUntilA
*arg = &val
}
type ListBackupGetRetainedUntilArgType = string
type ListBackupGetRetainedUntilRetType = string
/*
types and functions for size
*/
//// isAny
//type ListBackupGetSizeAttributeType = any
//type ListBackupGetSizeArgType = any
//type ListBackupGetSizeRetType = any
//
//func getListBackupGetSizeAttributeTypeOk(arg ListBackupGetSizeAttributeType) (ret ListBackupGetSizeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetSizeAttributeType(arg *ListBackupGetSizeAttributeType, val ListBackupGetSizeRetType) {
// *arg = &val
//}
// isModel
// isLong
type ListBackupGetSizeAttributeType = *int64
type ListBackupGetSizeArgType = int64
type ListBackupGetSizeRetType = int64
@ -201,26 +124,8 @@ func setListBackupGetSizeAttributeType(arg *ListBackupGetSizeAttributeType, val
types and functions for type
*/
//// isAny
//type ListBackupGetTypeAttributeType = any
//type ListBackupGetTypeArgType = any
//type ListBackupGetTypeRetType = any
//
//func getListBackupGetTypeAttributeTypeOk(arg ListBackupGetTypeAttributeType) (ret ListBackupGetTypeRetType, ok bool) {
// if arg == nil {
// return ret, false
// }
// return *arg, true
//}
//
//func setListBackupGetTypeAttributeType(arg *ListBackupGetTypeAttributeType, val ListBackupGetTypeRetType) {
// *arg = &val
//}
// isModel
// isNotNullableString
type ListBackupGetTypeAttributeType = *string
type ListBackupGetTypeArgType = string
type ListBackupGetTypeRetType = string
func getListBackupGetTypeAttributeTypeOk(arg ListBackupGetTypeAttributeType) (ret ListBackupGetTypeRetType, ok bool) {
if arg == nil {
@ -233,18 +138,27 @@ func setListBackupGetTypeAttributeType(arg *ListBackupGetTypeAttributeType, val
*arg = &val
}
type ListBackupGetTypeArgType = string
type ListBackupGetTypeRetType = string
// ListBackup struct for ListBackup
type ListBackup struct {
// The time when the backup was completed in RFC3339 format.
// REQUIRED
CompletionTime ListBackupGetCompletionTimeAttributeType `json:"completionTime" required:"true"`
// The ID of the backup.
// REQUIRED
Id ListBackupGetIdAttributeType `json:"id" required:"true"`
// The name of the backup.
// REQUIRED
Name ListBackupGetNameAttributeType `json:"name" required:"true"`
// The time until the backup will be retained.
// REQUIRED
RetainedUntil ListBackupGetRetainedUntilAttributeType `json:"retainedUntil" required:"true"`
// The size of the backup in bytes.
// REQUIRED
Size ListBackupGetSizeAttributeType `json:"size" required:"true"`
// The type of the backup, which can be automated or manual triggered.
// REQUIRED
Type ListBackupGetTypeAttributeType `json:"type" required:"true"`
}

View file

@ -0,0 +1,170 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
)
// checks if the RestoreDatabaseFromBackupPayload type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &RestoreDatabaseFromBackupPayload{}
/*
types and functions for database_name
*/
// isNotNullableString
type RestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType = *string
func getRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeTypeOk(arg RestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType) (ret RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType(arg *RestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType, val RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType) {
*arg = &val
}
type RestoreDatabaseFromBackupPayloadGetDatabaseNameArgType = string
type RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType = string
/*
types and functions for source
*/
// isModel
type RestoreDatabaseFromBackupPayloadGetSourceAttributeType = *RestoreDatabaseFromBackupPayloadSource
type RestoreDatabaseFromBackupPayloadGetSourceArgType = RestoreDatabaseFromBackupPayloadSource
type RestoreDatabaseFromBackupPayloadGetSourceRetType = RestoreDatabaseFromBackupPayloadSource
func getRestoreDatabaseFromBackupPayloadGetSourceAttributeTypeOk(arg RestoreDatabaseFromBackupPayloadGetSourceAttributeType) (ret RestoreDatabaseFromBackupPayloadGetSourceRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setRestoreDatabaseFromBackupPayloadGetSourceAttributeType(arg *RestoreDatabaseFromBackupPayloadGetSourceAttributeType, val RestoreDatabaseFromBackupPayloadGetSourceRetType) {
*arg = &val
}
// RestoreDatabaseFromBackupPayload Request to restore a database.
type RestoreDatabaseFromBackupPayload struct {
// The name of the database on the instance to be restore.
// REQUIRED
DatabaseName RestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType `json:"database_name" required:"true"`
// REQUIRED
Source RestoreDatabaseFromBackupPayloadGetSourceAttributeType `json:"source" required:"true"`
}
type _RestoreDatabaseFromBackupPayload RestoreDatabaseFromBackupPayload
// NewRestoreDatabaseFromBackupPayload instantiates a new RestoreDatabaseFromBackupPayload object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewRestoreDatabaseFromBackupPayload(databaseName RestoreDatabaseFromBackupPayloadGetDatabaseNameArgType, source RestoreDatabaseFromBackupPayloadGetSourceArgType) *RestoreDatabaseFromBackupPayload {
this := RestoreDatabaseFromBackupPayload{}
setRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType(&this.DatabaseName, databaseName)
setRestoreDatabaseFromBackupPayloadGetSourceAttributeType(&this.Source, source)
return &this
}
// NewRestoreDatabaseFromBackupPayloadWithDefaults instantiates a new RestoreDatabaseFromBackupPayload object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewRestoreDatabaseFromBackupPayloadWithDefaults() *RestoreDatabaseFromBackupPayload {
this := RestoreDatabaseFromBackupPayload{}
return &this
}
// GetDatabaseName returns the DatabaseName field value
func (o *RestoreDatabaseFromBackupPayload) GetDatabaseName() (ret RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType) {
ret, _ = o.GetDatabaseNameOk()
return ret
}
// GetDatabaseNameOk returns a tuple with the DatabaseName field value
// and a boolean to check if the value has been set.
func (o *RestoreDatabaseFromBackupPayload) GetDatabaseNameOk() (ret RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType, ok bool) {
return getRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeTypeOk(o.DatabaseName)
}
// SetDatabaseName sets field value
func (o *RestoreDatabaseFromBackupPayload) SetDatabaseName(v RestoreDatabaseFromBackupPayloadGetDatabaseNameRetType) {
setRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeType(&o.DatabaseName, v)
}
// GetSource returns the Source field value
func (o *RestoreDatabaseFromBackupPayload) GetSource() (ret RestoreDatabaseFromBackupPayloadGetSourceRetType) {
ret, _ = o.GetSourceOk()
return ret
}
// GetSourceOk returns a tuple with the Source field value
// and a boolean to check if the value has been set.
func (o *RestoreDatabaseFromBackupPayload) GetSourceOk() (ret RestoreDatabaseFromBackupPayloadGetSourceRetType, ok bool) {
return getRestoreDatabaseFromBackupPayloadGetSourceAttributeTypeOk(o.Source)
}
// SetSource sets field value
func (o *RestoreDatabaseFromBackupPayload) SetSource(v RestoreDatabaseFromBackupPayloadGetSourceRetType) {
setRestoreDatabaseFromBackupPayloadGetSourceAttributeType(&o.Source, v)
}
func (o RestoreDatabaseFromBackupPayload) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if val, ok := getRestoreDatabaseFromBackupPayloadGetDatabaseNameAttributeTypeOk(o.DatabaseName); ok {
toSerialize["DatabaseName"] = val
}
if val, ok := getRestoreDatabaseFromBackupPayloadGetSourceAttributeTypeOk(o.Source); ok {
toSerialize["Source"] = val
}
return toSerialize, nil
}
type NullableRestoreDatabaseFromBackupPayload struct {
value *RestoreDatabaseFromBackupPayload
isSet bool
}
func (v NullableRestoreDatabaseFromBackupPayload) Get() *RestoreDatabaseFromBackupPayload {
return v.value
}
func (v *NullableRestoreDatabaseFromBackupPayload) Set(val *RestoreDatabaseFromBackupPayload) {
v.value = val
v.isSet = true
}
func (v NullableRestoreDatabaseFromBackupPayload) IsSet() bool {
return v.isSet
}
func (v *NullableRestoreDatabaseFromBackupPayload) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRestoreDatabaseFromBackupPayload(val *RestoreDatabaseFromBackupPayload) *NullableRestoreDatabaseFromBackupPayload {
return &NullableRestoreDatabaseFromBackupPayload{value: val, isSet: true}
}
func (v NullableRestoreDatabaseFromBackupPayload) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRestoreDatabaseFromBackupPayload) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,163 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
"fmt"
)
// RestoreDatabaseFromBackupPayloadSource - The source of the restore.
type RestoreDatabaseFromBackupPayloadSource struct {
SourceBackup *SourceBackup
SourceExternalS3 *SourceExternalS3
}
// SourceBackupAsRestoreDatabaseFromBackupPayloadSource is a convenience function that returns SourceBackup wrapped in RestoreDatabaseFromBackupPayloadSource
func SourceBackupAsRestoreDatabaseFromBackupPayloadSource(v *SourceBackup) RestoreDatabaseFromBackupPayloadSource {
return RestoreDatabaseFromBackupPayloadSource{
SourceBackup: v,
}
}
// SourceExternalS3AsRestoreDatabaseFromBackupPayloadSource is a convenience function that returns SourceExternalS3 wrapped in RestoreDatabaseFromBackupPayloadSource
func SourceExternalS3AsRestoreDatabaseFromBackupPayloadSource(v *SourceExternalS3) RestoreDatabaseFromBackupPayloadSource {
return RestoreDatabaseFromBackupPayloadSource{
SourceExternalS3: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *RestoreDatabaseFromBackupPayloadSource) UnmarshalJSON(data []byte) error {
var err error
// use discriminator value to speed up the lookup
var jsonDict map[string]interface{}
err = newStrictDecoder(data).Decode(&jsonDict)
if err != nil {
return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
}
// check if the discriminator value is 'BACKUP'
if jsonDict["type"] == "BACKUP" {
// try to unmarshal JSON data into SourceBackup
err = json.Unmarshal(data, &dst.SourceBackup)
if err == nil {
return nil // data stored in dst.SourceBackup, return on the first match
} else {
dst.SourceBackup = nil
return fmt.Errorf("failed to unmarshal RestoreDatabaseFromBackupPayloadSource as SourceBackup: %s", err.Error())
}
}
// check if the discriminator value is 'EXTERNAL_S3'
if jsonDict["type"] == "EXTERNAL_S3" {
// try to unmarshal JSON data into SourceExternalS3
err = json.Unmarshal(data, &dst.SourceExternalS3)
if err == nil {
return nil // data stored in dst.SourceExternalS3, return on the first match
} else {
dst.SourceExternalS3 = nil
return fmt.Errorf("failed to unmarshal RestoreDatabaseFromBackupPayloadSource as SourceExternalS3: %s", err.Error())
}
}
// check if the discriminator value is 'source.backup'
if jsonDict["type"] == "source.backup" {
// try to unmarshal JSON data into SourceBackup
err = json.Unmarshal(data, &dst.SourceBackup)
if err == nil {
return nil // data stored in dst.SourceBackup, return on the first match
} else {
dst.SourceBackup = nil
return fmt.Errorf("failed to unmarshal RestoreDatabaseFromBackupPayloadSource as SourceBackup: %s", err.Error())
}
}
// check if the discriminator value is 'source.externalS3'
if jsonDict["type"] == "source.externalS3" {
// try to unmarshal JSON data into SourceExternalS3
err = json.Unmarshal(data, &dst.SourceExternalS3)
if err == nil {
return nil // data stored in dst.SourceExternalS3, return on the first match
} else {
dst.SourceExternalS3 = nil
return fmt.Errorf("failed to unmarshal RestoreDatabaseFromBackupPayloadSource as SourceExternalS3: %s", err.Error())
}
}
return nil
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src RestoreDatabaseFromBackupPayloadSource) MarshalJSON() ([]byte, error) {
if src.SourceBackup != nil {
return json.Marshal(&src.SourceBackup)
}
if src.SourceExternalS3 != nil {
return json.Marshal(&src.SourceExternalS3)
}
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
}
// Get the actual instance
func (obj *RestoreDatabaseFromBackupPayloadSource) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.SourceBackup != nil {
return obj.SourceBackup
}
if obj.SourceExternalS3 != nil {
return obj.SourceExternalS3
}
// all schemas are nil
return nil
}
type NullableRestoreDatabaseFromBackupPayloadSource struct {
value *RestoreDatabaseFromBackupPayloadSource
isSet bool
}
func (v NullableRestoreDatabaseFromBackupPayloadSource) Get() *RestoreDatabaseFromBackupPayloadSource {
return v.value
}
func (v *NullableRestoreDatabaseFromBackupPayloadSource) Set(val *RestoreDatabaseFromBackupPayloadSource) {
v.value = val
v.isSet = true
}
func (v NullableRestoreDatabaseFromBackupPayloadSource) IsSet() bool {
return v.isSet
}
func (v *NullableRestoreDatabaseFromBackupPayloadSource) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRestoreDatabaseFromBackupPayloadSource(val *RestoreDatabaseFromBackupPayloadSource) *NullableRestoreDatabaseFromBackupPayloadSource {
return &NullableRestoreDatabaseFromBackupPayloadSource{value: val, isSet: true}
}
func (v NullableRestoreDatabaseFromBackupPayloadSource) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRestoreDatabaseFromBackupPayloadSource) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,11 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha

View file

@ -0,0 +1,11 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha

View file

@ -0,0 +1,178 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
)
// checks if the S3fileInfo type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &S3fileInfo{}
/*
types and functions for file_number
*/
// isInteger
type S3fileInfoGetFileNumberAttributeType = *int64
type S3fileInfoGetFileNumberArgType = int64
type S3fileInfoGetFileNumberRetType = int64
func getS3fileInfoGetFileNumberAttributeTypeOk(arg S3fileInfoGetFileNumberAttributeType) (ret S3fileInfoGetFileNumberRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setS3fileInfoGetFileNumberAttributeType(arg *S3fileInfoGetFileNumberAttributeType, val S3fileInfoGetFileNumberRetType) {
*arg = &val
}
/*
types and functions for file_path
*/
// isNotNullableString
type S3fileInfoGetFilePathAttributeType = *string
func getS3fileInfoGetFilePathAttributeTypeOk(arg S3fileInfoGetFilePathAttributeType) (ret S3fileInfoGetFilePathRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setS3fileInfoGetFilePathAttributeType(arg *S3fileInfoGetFilePathAttributeType, val S3fileInfoGetFilePathRetType) {
*arg = &val
}
type S3fileInfoGetFilePathArgType = string
type S3fileInfoGetFilePathRetType = string
// S3fileInfo struct for S3fileInfo
type S3fileInfo struct {
// The sequence number of the file
// Can be cast to int32 without loss of precision.
FileNumber S3fileInfoGetFileNumberAttributeType `json:"file_number,omitempty"`
// The path to the file on the S3 bucket
FilePath S3fileInfoGetFilePathAttributeType `json:"file_path,omitempty"`
}
// NewS3fileInfo instantiates a new S3fileInfo object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewS3fileInfo() *S3fileInfo {
this := S3fileInfo{}
return &this
}
// NewS3fileInfoWithDefaults instantiates a new S3fileInfo object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewS3fileInfoWithDefaults() *S3fileInfo {
this := S3fileInfo{}
return &this
}
// GetFileNumber returns the FileNumber field value if set, zero value otherwise.
func (o *S3fileInfo) GetFileNumber() (res S3fileInfoGetFileNumberRetType) {
res, _ = o.GetFileNumberOk()
return
}
// GetFileNumberOk returns a tuple with the FileNumber field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *S3fileInfo) GetFileNumberOk() (ret S3fileInfoGetFileNumberRetType, ok bool) {
return getS3fileInfoGetFileNumberAttributeTypeOk(o.FileNumber)
}
// HasFileNumber returns a boolean if a field has been set.
func (o *S3fileInfo) HasFileNumber() bool {
_, ok := o.GetFileNumberOk()
return ok
}
// SetFileNumber gets a reference to the given int64 and assigns it to the FileNumber field.
func (o *S3fileInfo) SetFileNumber(v S3fileInfoGetFileNumberRetType) {
setS3fileInfoGetFileNumberAttributeType(&o.FileNumber, v)
}
// GetFilePath returns the FilePath field value if set, zero value otherwise.
func (o *S3fileInfo) GetFilePath() (res S3fileInfoGetFilePathRetType) {
res, _ = o.GetFilePathOk()
return
}
// GetFilePathOk returns a tuple with the FilePath field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *S3fileInfo) GetFilePathOk() (ret S3fileInfoGetFilePathRetType, ok bool) {
return getS3fileInfoGetFilePathAttributeTypeOk(o.FilePath)
}
// HasFilePath returns a boolean if a field has been set.
func (o *S3fileInfo) HasFilePath() bool {
_, ok := o.GetFilePathOk()
return ok
}
// SetFilePath gets a reference to the given string and assigns it to the FilePath field.
func (o *S3fileInfo) SetFilePath(v S3fileInfoGetFilePathRetType) {
setS3fileInfoGetFilePathAttributeType(&o.FilePath, v)
}
func (o S3fileInfo) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if val, ok := getS3fileInfoGetFileNumberAttributeTypeOk(o.FileNumber); ok {
toSerialize["FileNumber"] = val
}
if val, ok := getS3fileInfoGetFilePathAttributeTypeOk(o.FilePath); ok {
toSerialize["FilePath"] = val
}
return toSerialize, nil
}
type NullableS3fileInfo struct {
value *S3fileInfo
isSet bool
}
func (v NullableS3fileInfo) Get() *S3fileInfo {
return v.value
}
func (v *NullableS3fileInfo) Set(val *S3fileInfo) {
v.value = val
v.isSet = true
}
func (v NullableS3fileInfo) IsSet() bool {
return v.isSet
}
func (v *NullableS3fileInfo) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableS3fileInfo(val *S3fileInfo) *NullableS3fileInfo {
return &NullableS3fileInfo{value: val, isSet: true}
}
func (v NullableS3fileInfo) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableS3fileInfo) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,11 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha

View file

@ -0,0 +1,228 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
"fmt"
)
// checks if the SourceBackup type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &SourceBackup{}
/*
types and functions for type
*/
// isEnum
// SourceBackupTypes the model 'SourceBackup'
// value type for enums
type SourceBackupTypes string
// List of Type
const (
SOURCEBACKUPTYPE_BACKUP SourceBackupTypes = "BACKUP"
)
// All allowed values of SourceBackup enum
var AllowedSourceBackupTypesEnumValues = []SourceBackupTypes{
"BACKUP",
}
func (v *SourceBackupTypes) UnmarshalJSON(src []byte) error {
// use a type alias to prevent infinite recursion during unmarshal,
// see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers
type TmpJson SourceBackupTypes
var value TmpJson
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
// Allow unmarshalling zero value for testing purposes
var zeroValue TmpJson
if value == zeroValue {
return nil
}
enumTypeValue := SourceBackupTypes(value)
for _, existing := range AllowedSourceBackupTypesEnumValues {
if existing == enumTypeValue {
*v = enumTypeValue
return nil
}
}
return fmt.Errorf("%+v is not a valid SourceBackup", value)
}
// NewSourceBackupTypesFromValue returns a pointer to a valid SourceBackupTypes
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewSourceBackupTypesFromValue(v SourceBackupTypes) (*SourceBackupTypes, error) {
ev := SourceBackupTypes(v)
if ev.IsValid() {
return &ev, nil
} else {
return nil, fmt.Errorf("invalid value '%v' for SourceBackupTypes: valid values are %v", v, AllowedSourceBackupTypesEnumValues)
}
}
// IsValid return true if the value is valid for the enum, false otherwise
func (v SourceBackupTypes) IsValid() bool {
for _, existing := range AllowedSourceBackupTypesEnumValues {
if existing == v {
return true
}
}
return false
}
// Ptr returns reference to TypeTypes value
func (v SourceBackupTypes) Ptr() *SourceBackupTypes {
return &v
}
type NullableSourceBackupTypes struct {
value *SourceBackupTypes
isSet bool
}
func (v NullableSourceBackupTypes) Get() *SourceBackupTypes {
return v.value
}
func (v *NullableSourceBackupTypes) Set(val *SourceBackupTypes) {
v.value = val
v.isSet = true
}
func (v NullableSourceBackupTypes) IsSet() bool {
return v.isSet
}
func (v *NullableSourceBackupTypes) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableSourceBackupTypes(val *SourceBackupTypes) *NullableSourceBackupTypes {
return &NullableSourceBackupTypes{value: val, isSet: true}
}
func (v NullableSourceBackupTypes) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableSourceBackupTypes) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
type SourceBackupGetTypeAttributeType = *SourceBackupTypes
type SourceBackupGetTypeArgType = SourceBackupTypes
type SourceBackupGetTypeRetType = SourceBackupTypes
func getSourceBackupGetTypeAttributeTypeOk(arg SourceBackupGetTypeAttributeType) (ret SourceBackupGetTypeRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setSourceBackupGetTypeAttributeType(arg *SourceBackupGetTypeAttributeType, val SourceBackupGetTypeRetType) {
*arg = &val
}
// SourceBackup Restore from an existing managed backup.
type SourceBackup struct {
// REQUIRED
Type SourceBackupGetTypeAttributeType `json:"type" required:"true"`
}
type _SourceBackup SourceBackup
// NewSourceBackup instantiates a new SourceBackup object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewSourceBackup(types SourceBackupGetTypeArgType) *SourceBackup {
this := SourceBackup{}
setSourceBackupGetTypeAttributeType(&this.Type, types)
return &this
}
// NewSourceBackupWithDefaults instantiates a new SourceBackup object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewSourceBackupWithDefaults() *SourceBackup {
this := SourceBackup{}
return &this
}
// GetType returns the Type field value
func (o *SourceBackup) GetType() (ret SourceBackupGetTypeRetType) {
ret, _ = o.GetTypeOk()
return ret
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *SourceBackup) GetTypeOk() (ret SourceBackupGetTypeRetType, ok bool) {
return getSourceBackupGetTypeAttributeTypeOk(o.Type)
}
// SetType sets field value
func (o *SourceBackup) SetType(v SourceBackupGetTypeRetType) {
setSourceBackupGetTypeAttributeType(&o.Type, v)
}
func (o SourceBackup) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if val, ok := getSourceBackupGetTypeAttributeTypeOk(o.Type); ok {
toSerialize["Type"] = val
}
return toSerialize, nil
}
type NullableSourceBackup struct {
value *SourceBackup
isSet bool
}
func (v NullableSourceBackup) Get() *SourceBackup {
return v.value
}
func (v *NullableSourceBackup) Set(val *SourceBackup) {
v.value = val
v.isSet = true
}
func (v NullableSourceBackup) IsSet() bool {
return v.isSet
}
func (v *NullableSourceBackup) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableSourceBackup(val *SourceBackup) *NullableSourceBackup {
return &NullableSourceBackup{value: val, isSet: true}
}
func (v NullableSourceBackup) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableSourceBackup) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,51 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"testing"
)
// isEnum
func TestSourceBackupTypes_UnmarshalJSON(t *testing.T) {
type args struct {
src []byte
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: `success - possible enum value no. 1`,
args: args{
src: []byte(`"BACKUP"`),
},
wantErr: false,
},
{
name: "fail",
args: args{
src: []byte("\"FOOBAR\""),
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := SourceBackupTypes("")
if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr {
t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

View file

@ -0,0 +1,365 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"encoding/json"
"fmt"
)
// checks if the SourceExternalS3 type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &SourceExternalS3{}
/*
types and functions for database_owner
*/
// isNotNullableString
type SourceExternalS3GetDatabaseOwnerAttributeType = *string
func getSourceExternalS3GetDatabaseOwnerAttributeTypeOk(arg SourceExternalS3GetDatabaseOwnerAttributeType) (ret SourceExternalS3GetDatabaseOwnerRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setSourceExternalS3GetDatabaseOwnerAttributeType(arg *SourceExternalS3GetDatabaseOwnerAttributeType, val SourceExternalS3GetDatabaseOwnerRetType) {
*arg = &val
}
type SourceExternalS3GetDatabaseOwnerArgType = string
type SourceExternalS3GetDatabaseOwnerRetType = string
/*
types and functions for logging_guid
*/
// isNotNullableString
type SourceExternalS3GetLoggingGuidAttributeType = *string
func getSourceExternalS3GetLoggingGuidAttributeTypeOk(arg SourceExternalS3GetLoggingGuidAttributeType) (ret SourceExternalS3GetLoggingGuidRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setSourceExternalS3GetLoggingGuidAttributeType(arg *SourceExternalS3GetLoggingGuidAttributeType, val SourceExternalS3GetLoggingGuidRetType) {
*arg = &val
}
type SourceExternalS3GetLoggingGuidArgType = string
type SourceExternalS3GetLoggingGuidRetType = string
/*
types and functions for s3_details
*/
// isModel
type SourceExternalS3GetS3DetailsAttributeType = *ExternalS3
type SourceExternalS3GetS3DetailsArgType = ExternalS3
type SourceExternalS3GetS3DetailsRetType = ExternalS3
func getSourceExternalS3GetS3DetailsAttributeTypeOk(arg SourceExternalS3GetS3DetailsAttributeType) (ret SourceExternalS3GetS3DetailsRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setSourceExternalS3GetS3DetailsAttributeType(arg *SourceExternalS3GetS3DetailsAttributeType, val SourceExternalS3GetS3DetailsRetType) {
*arg = &val
}
/*
types and functions for type
*/
// isEnum
// SourceExternalS3Types the model 'SourceExternalS3'
// value type for enums
type SourceExternalS3Types string
// List of Type
const (
SOURCEEXTERNALS3TYPE_EXTERNAL_S3 SourceExternalS3Types = "EXTERNAL_S3"
)
// All allowed values of SourceExternalS3 enum
var AllowedSourceExternalS3TypesEnumValues = []SourceExternalS3Types{
"EXTERNAL_S3",
}
func (v *SourceExternalS3Types) UnmarshalJSON(src []byte) error {
// use a type alias to prevent infinite recursion during unmarshal,
// see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers
type TmpJson SourceExternalS3Types
var value TmpJson
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
// Allow unmarshalling zero value for testing purposes
var zeroValue TmpJson
if value == zeroValue {
return nil
}
enumTypeValue := SourceExternalS3Types(value)
for _, existing := range AllowedSourceExternalS3TypesEnumValues {
if existing == enumTypeValue {
*v = enumTypeValue
return nil
}
}
return fmt.Errorf("%+v is not a valid SourceExternalS3", value)
}
// NewSourceExternalS3TypesFromValue returns a pointer to a valid SourceExternalS3Types
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewSourceExternalS3TypesFromValue(v SourceExternalS3Types) (*SourceExternalS3Types, error) {
ev := SourceExternalS3Types(v)
if ev.IsValid() {
return &ev, nil
} else {
return nil, fmt.Errorf("invalid value '%v' for SourceExternalS3Types: valid values are %v", v, AllowedSourceExternalS3TypesEnumValues)
}
}
// IsValid return true if the value is valid for the enum, false otherwise
func (v SourceExternalS3Types) IsValid() bool {
for _, existing := range AllowedSourceExternalS3TypesEnumValues {
if existing == v {
return true
}
}
return false
}
// Ptr returns reference to TypeTypes value
func (v SourceExternalS3Types) Ptr() *SourceExternalS3Types {
return &v
}
type NullableSourceExternalS3Types struct {
value *SourceExternalS3Types
isSet bool
}
func (v NullableSourceExternalS3Types) Get() *SourceExternalS3Types {
return v.value
}
func (v *NullableSourceExternalS3Types) Set(val *SourceExternalS3Types) {
v.value = val
v.isSet = true
}
func (v NullableSourceExternalS3Types) IsSet() bool {
return v.isSet
}
func (v *NullableSourceExternalS3Types) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableSourceExternalS3Types(val *SourceExternalS3Types) *NullableSourceExternalS3Types {
return &NullableSourceExternalS3Types{value: val, isSet: true}
}
func (v NullableSourceExternalS3Types) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableSourceExternalS3Types) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
type SourceExternalS3GetTypeAttributeType = *SourceExternalS3Types
type SourceExternalS3GetTypeArgType = SourceExternalS3Types
type SourceExternalS3GetTypeRetType = SourceExternalS3Types
func getSourceExternalS3GetTypeAttributeTypeOk(arg SourceExternalS3GetTypeAttributeType) (ret SourceExternalS3GetTypeRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setSourceExternalS3GetTypeAttributeType(arg *SourceExternalS3GetTypeAttributeType, val SourceExternalS3GetTypeRetType) {
*arg = &val
}
// SourceExternalS3 Restore from an external S3 backup file.
type SourceExternalS3 struct {
// The owner of the database.
// REQUIRED
DatabaseOwner SourceExternalS3GetDatabaseOwnerAttributeType `json:"database_owner" required:"true"`
// Logging guid to have a complete activity log over all sub stored procedures.
LoggingGuid SourceExternalS3GetLoggingGuidAttributeType `json:"logging_guid,omitempty"`
// REQUIRED
S3Details SourceExternalS3GetS3DetailsAttributeType `json:"s3_details" required:"true"`
// REQUIRED
Type SourceExternalS3GetTypeAttributeType `json:"type" required:"true"`
}
type _SourceExternalS3 SourceExternalS3
// NewSourceExternalS3 instantiates a new SourceExternalS3 object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewSourceExternalS3(databaseOwner SourceExternalS3GetDatabaseOwnerArgType, s3Details SourceExternalS3GetS3DetailsArgType, types SourceExternalS3GetTypeArgType) *SourceExternalS3 {
this := SourceExternalS3{}
setSourceExternalS3GetDatabaseOwnerAttributeType(&this.DatabaseOwner, databaseOwner)
setSourceExternalS3GetS3DetailsAttributeType(&this.S3Details, s3Details)
setSourceExternalS3GetTypeAttributeType(&this.Type, types)
return &this
}
// NewSourceExternalS3WithDefaults instantiates a new SourceExternalS3 object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewSourceExternalS3WithDefaults() *SourceExternalS3 {
this := SourceExternalS3{}
return &this
}
// GetDatabaseOwner returns the DatabaseOwner field value
func (o *SourceExternalS3) GetDatabaseOwner() (ret SourceExternalS3GetDatabaseOwnerRetType) {
ret, _ = o.GetDatabaseOwnerOk()
return ret
}
// GetDatabaseOwnerOk returns a tuple with the DatabaseOwner field value
// and a boolean to check if the value has been set.
func (o *SourceExternalS3) GetDatabaseOwnerOk() (ret SourceExternalS3GetDatabaseOwnerRetType, ok bool) {
return getSourceExternalS3GetDatabaseOwnerAttributeTypeOk(o.DatabaseOwner)
}
// SetDatabaseOwner sets field value
func (o *SourceExternalS3) SetDatabaseOwner(v SourceExternalS3GetDatabaseOwnerRetType) {
setSourceExternalS3GetDatabaseOwnerAttributeType(&o.DatabaseOwner, v)
}
// GetLoggingGuid returns the LoggingGuid field value if set, zero value otherwise.
func (o *SourceExternalS3) GetLoggingGuid() (res SourceExternalS3GetLoggingGuidRetType) {
res, _ = o.GetLoggingGuidOk()
return
}
// GetLoggingGuidOk returns a tuple with the LoggingGuid field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SourceExternalS3) GetLoggingGuidOk() (ret SourceExternalS3GetLoggingGuidRetType, ok bool) {
return getSourceExternalS3GetLoggingGuidAttributeTypeOk(o.LoggingGuid)
}
// HasLoggingGuid returns a boolean if a field has been set.
func (o *SourceExternalS3) HasLoggingGuid() bool {
_, ok := o.GetLoggingGuidOk()
return ok
}
// SetLoggingGuid gets a reference to the given string and assigns it to the LoggingGuid field.
func (o *SourceExternalS3) SetLoggingGuid(v SourceExternalS3GetLoggingGuidRetType) {
setSourceExternalS3GetLoggingGuidAttributeType(&o.LoggingGuid, v)
}
// GetS3Details returns the S3Details field value
func (o *SourceExternalS3) GetS3Details() (ret SourceExternalS3GetS3DetailsRetType) {
ret, _ = o.GetS3DetailsOk()
return ret
}
// GetS3DetailsOk returns a tuple with the S3Details field value
// and a boolean to check if the value has been set.
func (o *SourceExternalS3) GetS3DetailsOk() (ret SourceExternalS3GetS3DetailsRetType, ok bool) {
return getSourceExternalS3GetS3DetailsAttributeTypeOk(o.S3Details)
}
// SetS3Details sets field value
func (o *SourceExternalS3) SetS3Details(v SourceExternalS3GetS3DetailsRetType) {
setSourceExternalS3GetS3DetailsAttributeType(&o.S3Details, v)
}
// GetType returns the Type field value
func (o *SourceExternalS3) GetType() (ret SourceExternalS3GetTypeRetType) {
ret, _ = o.GetTypeOk()
return ret
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *SourceExternalS3) GetTypeOk() (ret SourceExternalS3GetTypeRetType, ok bool) {
return getSourceExternalS3GetTypeAttributeTypeOk(o.Type)
}
// SetType sets field value
func (o *SourceExternalS3) SetType(v SourceExternalS3GetTypeRetType) {
setSourceExternalS3GetTypeAttributeType(&o.Type, v)
}
func (o SourceExternalS3) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if val, ok := getSourceExternalS3GetDatabaseOwnerAttributeTypeOk(o.DatabaseOwner); ok {
toSerialize["DatabaseOwner"] = val
}
if val, ok := getSourceExternalS3GetLoggingGuidAttributeTypeOk(o.LoggingGuid); ok {
toSerialize["LoggingGuid"] = val
}
if val, ok := getSourceExternalS3GetS3DetailsAttributeTypeOk(o.S3Details); ok {
toSerialize["S3Details"] = val
}
if val, ok := getSourceExternalS3GetTypeAttributeTypeOk(o.Type); ok {
toSerialize["Type"] = val
}
return toSerialize, nil
}
type NullableSourceExternalS3 struct {
value *SourceExternalS3
isSet bool
}
func (v NullableSourceExternalS3) Get() *SourceExternalS3 {
return v.value
}
func (v *NullableSourceExternalS3) Set(val *SourceExternalS3) {
v.value = val
v.isSet = true
}
func (v NullableSourceExternalS3) IsSet() bool {
return v.isSet
}
func (v *NullableSourceExternalS3) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableSourceExternalS3(val *SourceExternalS3) *NullableSourceExternalS3 {
return &NullableSourceExternalS3{value: val, isSet: true}
}
func (v NullableSourceExternalS3) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableSourceExternalS3) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View file

@ -0,0 +1,51 @@
/*
STACKIT MSSQL Service API
This is the documentation for the STACKIT MSSQL service
API version: 3alpha1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package sqlserverflexalpha
import (
"testing"
)
// isEnum
func TestSourceExternalS3Types_UnmarshalJSON(t *testing.T) {
type args struct {
src []byte
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: `success - possible enum value no. 1`,
args: args{
src: []byte(`"EXTERNAL_S3"`),
},
wantErr: false,
},
{
name: "fail",
args: args{
src: []byte("\"FOOBAR\""),
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := SourceExternalS3Types("")
if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr {
t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

View file

@ -1,112 +0,0 @@
// Copyright (c) STACKIT
package wait
import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"time"
"github.com/hashicorp/terraform-plugin-log/tflog"
sqlserverflex "github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/sqlserverflexalpha"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/wait"
)
const (
InstanceStateEmpty = ""
InstanceStateProcessing = "Progressing"
InstanceStateUnknown = "Unknown"
InstanceStateSuccess = "Ready"
InstanceStateFailed = "Failed"
)
// Interface needed for tests
type APIClientInstanceInterface interface {
GetInstanceRequestExecute(ctx context.Context, projectId, region, instanceId string) (*sqlserverflex.GetInstanceResponse, error)
}
// CreateInstanceWaitHandler will wait for instance creation
func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
if err != nil {
return false, nil, err
}
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
return false, nil, nil
}
switch strings.ToLower(string(*s.Status)) {
case strings.ToLower(InstanceStateSuccess):
if s.Network.InstanceAddress == nil {
tflog.Info(ctx, "Waiting for instance_address")
return false, nil, nil
}
if s.Network.RouterAddress == nil {
tflog.Info(ctx, "Waiting for router_address")
return false, nil, nil
}
return true, s, nil
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
default:
return false, s, nil
}
})
handler.SetTimeout(45 * time.Minute)
handler.SetSleepBeforeWait(15 * time.Second)
return handler
}
// UpdateInstanceWaitHandler will wait for instance update
func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
if err != nil {
return false, nil, err
}
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
return false, nil, nil
}
switch strings.ToLower(string(*s.Status)) {
case strings.ToLower(InstanceStateSuccess):
return true, s, nil
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
return true, s, fmt.Errorf("update failed for instance with id %s", instanceId)
default:
return false, s, nil
}
})
handler.SetSleepBeforeWait(2 * time.Second)
handler.SetTimeout(45 * time.Minute)
return handler
}
// PartialUpdateInstanceWaitHandler will wait for instance update
func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
return UpdateInstanceWaitHandler(ctx, a, projectId, instanceId, region)
}
// DeleteInstanceWaitHandler will wait for instance deletion
func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[struct{}] {
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
_, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
if err == nil {
return false, nil, nil
}
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
if !ok {
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
}
if oapiErr.StatusCode != http.StatusNotFound {
return false, nil, err
}
return true, nil, nil
})
handler.SetTimeout(15 * time.Minute)
return handler
}

View file

@ -1,260 +0,0 @@
// Copyright (c) STACKIT
package wait
import (
"context"
"testing"
"time"
"github.com/google/go-cmp/cmp"
sqlserverflex "github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/sqlserverflexalpha"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
)
// Used for testing instance operations
type apiClientInstanceMocked struct {
instanceId string
instanceState string
instanceNetwork sqlserverflex.InstanceNetwork
instanceIsDeleted bool
instanceGetFails bool
}
func (a *apiClientInstanceMocked) GetInstanceRequestExecute(_ context.Context, _, _, _ string) (*sqlserverflex.GetInstanceResponse, error) {
if a.instanceGetFails {
return nil, &oapierror.GenericOpenAPIError{
StatusCode: 500,
}
}
if a.instanceIsDeleted {
return nil, &oapierror.GenericOpenAPIError{
StatusCode: 404,
}
}
return &sqlserverflex.GetInstanceResponse{
Id: &a.instanceId,
Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(&a.instanceState),
Network: &a.instanceNetwork,
}, nil
}
func TestCreateInstanceWaitHandler(t *testing.T) {
t.Skip("skipping - needs refactoring")
tests := []struct {
desc string
instanceGetFails bool
instanceState string
instanceNetwork sqlserverflex.InstanceNetwork
usersGetErrorStatus int
wantErr bool
wantRes *sqlserverflex.GetInstanceResponse
}{
{
desc: "create_succeeded",
instanceGetFails: false,
instanceState: InstanceStateSuccess,
instanceNetwork: sqlserverflex.InstanceNetwork{
AccessScope: nil,
Acl: nil,
InstanceAddress: utils.Ptr("10.0.0.1"),
RouterAddress: utils.Ptr("10.0.0.2"),
},
wantErr: false,
wantRes: &sqlserverflex.GetInstanceResponse{
BackupSchedule: nil,
Edition: nil,
Encryption: nil,
FlavorId: nil,
Id: nil,
IsDeletable: nil,
Name: nil,
Network: &sqlserverflex.InstanceNetwork{
AccessScope: nil,
Acl: nil,
InstanceAddress: utils.Ptr("10.0.0.1"),
RouterAddress: utils.Ptr("10.0.0.2"),
},
Replicas: nil,
RetentionDays: nil,
Status: nil,
Storage: nil,
Version: nil,
},
},
{
desc: "create_failed",
instanceGetFails: false,
instanceState: InstanceStateFailed,
wantErr: true,
wantRes: nil,
},
{
desc: "create_failed_2",
instanceGetFails: false,
instanceState: InstanceStateEmpty,
wantErr: true,
wantRes: nil,
},
{
desc: "instance_get_fails",
instanceGetFails: true,
wantErr: true,
wantRes: nil,
},
{
desc: "timeout",
instanceGetFails: false,
instanceState: InstanceStateProcessing,
wantErr: true,
wantRes: nil,
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
instanceId := "foo-bar"
apiClient := &apiClientInstanceMocked{
instanceId: instanceId,
instanceState: tt.instanceState,
instanceGetFails: tt.instanceGetFails,
}
handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
if (err != nil) != tt.wantErr {
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
}
if !cmp.Equal(gotRes, tt.wantRes) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes)
}
})
}
}
func TestUpdateInstanceWaitHandler(t *testing.T) {
t.Skip("skipping - needs refactoring")
tests := []struct {
desc string
instanceGetFails bool
instanceState string
wantErr bool
wantResp bool
}{
{
desc: "update_succeeded",
instanceGetFails: false,
instanceState: InstanceStateSuccess,
wantErr: false,
wantResp: true,
},
{
desc: "update_failed",
instanceGetFails: false,
instanceState: InstanceStateFailed,
wantErr: true,
wantResp: true,
},
{
desc: "update_failed_2",
instanceGetFails: false,
instanceState: InstanceStateEmpty,
wantErr: true,
wantResp: true,
},
{
desc: "get_fails",
instanceGetFails: true,
wantErr: true,
wantResp: false,
},
{
desc: "timeout",
instanceGetFails: false,
instanceState: InstanceStateProcessing,
wantErr: true,
wantResp: true,
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
instanceId := "foo-bar"
apiClient := &apiClientInstanceMocked{
instanceId: instanceId,
instanceState: tt.instanceState,
instanceGetFails: tt.instanceGetFails,
}
var wantRes *sqlserverflex.GetInstanceResponse
if tt.wantResp {
wantRes = &sqlserverflex.GetInstanceResponse{
Id: &instanceId,
Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)),
}
}
handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
if (err != nil) != tt.wantErr {
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
}
if !cmp.Equal(gotRes, wantRes) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
}
}
func TestDeleteInstanceWaitHandler(t *testing.T) {
tests := []struct {
desc string
instanceGetFails bool
instanceState string
wantErr bool
}{
{
desc: "delete_succeeded",
instanceGetFails: false,
instanceState: InstanceStateSuccess,
wantErr: false,
},
{
desc: "delete_failed",
instanceGetFails: false,
instanceState: InstanceStateFailed,
wantErr: true,
},
{
desc: "get_fails",
instanceGetFails: true,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
instanceId := "foo-bar"
apiClient := &apiClientInstanceMocked{
instanceGetFails: tt.instanceGetFails,
instanceIsDeleted: tt.instanceState == InstanceStateSuccess,
instanceId: instanceId,
instanceState: tt.instanceState,
}
handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "")
_, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
if (err != nil) != tt.wantErr {
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}