terraform-provider-stackitp.../pkg/postgresflexalpha/api_default_test.go
harmsan 979220be66
chore: adjust pagination for postgres database and flavor listing (#20)
* feat: implement pagination for database listing

* fix: change database_id attribute type from string to int64

* refactor: rename getDatabase to getDatabaseById for clarity

* fix: improve error handling for database not found scenario

* feat: add validation for database_id and name attributes; implement separate functions for fetching databases by ID and name

* feat: implement database client interface and update database fetching functions

* refactor: rename matcher to filter for clarity and update pagination logic

* feat: implement flavors retrieval with pagination and filtering support

* refactor: rename flavor import for consistency and clarity

* feat: add support for InstanceStatePending in wait handler logic

* refactor: simplify GetFlavorsRequest and GetFlavorsRequestExecute by removing pagination parameters

* refactor: improve readability of test cases by formatting function signatures and restructuring test runs

* refactor: remove pagination parameters from GetFlavorsRequest in test case

* refactor: simplify function signatures and improve readability in datasource and resource files

* refactor: add descriptions for user-related attributes in datasource schema

* refactor: enhance user resource schema with additional attributes and improve logging

* refactor: delete unused file

* refactor: standardize formatting and improve function naming for user resource management

* refactor: remove skip from TestMapFields and update roles initialization in resource tests

* fix: golangci lint issues

* fix: golangci lint issues again

* fix: golangci lint issues again
2026-01-16 16:23:10 +01:00

2263 lines
63 KiB
Go

/*
PostgreSQL Flex API
Testing DefaultApiService
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
package postgresflexalpha
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"github.com/stackitcloud/stackit-sdk-go/core/config"
)
func Test_postgresflexalpha_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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
createDatabaseRequestPayload := CreateDatabaseRequestPayload{}
resp, reqErr := apiClient.CreateDatabaseRequest(
context.Background(),
projectId,
region,
instanceId,
).CreateDatabaseRequestPayload(createDatabaseRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
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
}
},
)
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 postgresflexalpha_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
createInstanceRequestPayload := CreateInstanceRequestPayload{}
resp, reqErr := apiClient.CreateInstanceRequest(
context.Background(),
projectId,
region,
).CreateInstanceRequestPayload(createInstanceRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
createUserRequestPayload := CreateUserRequestPayload{}
resp, reqErr := apiClient.CreateUserRequest(
context.Background(),
projectId,
region,
instanceId,
).CreateUserRequestPayload(createUserRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
t.Run(
"Test DefaultApiService DeleteDatabaseRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"projectId"+"}",
url.PathEscape(ParameterValueToString(projectIdValue, "projectId")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
databaseIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"databaseId"+"}",
url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")),
)
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 postgresflexalpha_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
databaseId := databaseIdValue
reqErr := apiClient.DeleteDatabaseRequest(
context.Background(),
projectId,
region,
instanceId,
databaseId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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 postgresflexalpha_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
reqErr := apiClient.DeleteInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"userId"+"}",
url.PathEscape(ParameterValueToString(userIdValue, "userId")),
)
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 postgresflexalpha_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
userId := userIdValue
reqErr := apiClient.DeleteUserRequest(context.Background(), projectId, region, instanceId, userId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
backupIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"backupId"+"}",
url.PathEscape(ParameterValueToString(backupIdValue, "backupId")),
)
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
}
},
)
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 postgresflexalpha_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
backupId := backupIdValue
resp, reqErr := apiClient.GetBackupRequest(
context.Background(),
projectId,
region,
instanceId,
backupId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.GetCollationsRequest(
context.Background(),
projectId,
region,
instanceId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.GetFlavorsRequest(context.Background(), projectId, region).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.GetInstanceRequest(context.Background(), projectId, region, instanceId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"userId"+"}",
url.PathEscape(ParameterValueToString(userIdValue, "userId")),
)
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
}
},
)
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 postgresflexalpha_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
userId := userIdValue
resp, reqErr := apiClient.GetUserRequest(
context.Background(),
projectId,
region,
instanceId,
userId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.GetVersionsRequest(context.Background(), projectId, region).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.ListBackupsRequest(context.Background(), projectId, region, instanceId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.ListDatabasesRequest(
context.Background(),
projectId,
region,
instanceId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.ListInstancesRequest(context.Background(), projectId, region).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.ListRolesRequest(context.Background(), projectId, region, instanceId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.ListUsersRequest(context.Background(), projectId, region, instanceId).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
t.Run(
"Test DefaultApiService PointInTimeRecoveryRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/recoveries"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"projectId"+"}",
url.PathEscape(ParameterValueToString(projectIdValue, "projectId")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(
_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := RecoveryResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
},
)
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 postgresflexalpha_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
resp, reqErr := apiClient.PointInTimeRecoveryRequest(
context.Background(),
projectId,
region,
instanceId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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
}
},
)
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 postgresflexalpha_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
protectInstanceRequestPayload := ProtectInstanceRequestPayload{}
resp, reqErr := apiClient.ProtectInstanceRequest(
context.Background(),
projectId,
region,
instanceId,
).ProtectInstanceRequestPayload(protectInstanceRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"userId"+"}",
url.PathEscape(ParameterValueToString(userIdValue, "userId")),
)
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
}
},
)
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 postgresflexalpha_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
userId := userIdValue
resp, reqErr := apiClient.ResetUserRequest(
context.Background(),
projectId,
region,
instanceId,
userId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
t.Run(
"Test DefaultApiService RestoreInstanceRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/backups/{backupId}/restores"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"projectId"+"}",
url.PathEscape(ParameterValueToString(projectIdValue, "projectId")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
backupIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"backupId"+"}",
url.PathEscape(ParameterValueToString(backupIdValue, "backupId")),
)
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 postgresflexalpha_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
backupId := backupIdValue
reqErr := apiClient.RestoreInstanceRequest(
context.Background(),
projectId,
region,
instanceId,
backupId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
t.Run(
"Test DefaultApiService UpdateDatabasePartiallyRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"projectId"+"}",
url.PathEscape(ParameterValueToString(projectIdValue, "projectId")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
databaseIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"databaseId"+"}",
url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")),
)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(
_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := UpdateDatabasePartiallyResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
},
)
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 postgresflexalpha_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
databaseId := databaseIdValue
updateDatabasePartiallyRequestPayload := UpdateDatabasePartiallyRequestPayload{}
resp, reqErr := apiClient.UpdateDatabasePartiallyRequest(
context.Background(),
projectId,
region,
instanceId,
databaseId,
).UpdateDatabasePartiallyRequestPayload(updateDatabasePartiallyRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
t.Run(
"Test DefaultApiService UpdateDatabaseRequest", func(t *testing.T) {
_apiUrlPath := "/v3alpha1/projects/{projectId}/regions/{region}/instances/{instanceId}/databases/{databaseId}"
projectIdValue := "projectId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"projectId"+"}",
url.PathEscape(ParameterValueToString(projectIdValue, "projectId")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
databaseIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"databaseId"+"}",
url.PathEscape(ParameterValueToString(databaseIdValue, "databaseId")),
)
testDefaultApiServeMux := http.NewServeMux()
testDefaultApiServeMux.HandleFunc(
_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
data := UpdateDatabaseResponse{}
w.Header().Add("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(data)
if err != nil {
return
}
},
)
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 postgresflexalpha_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
databaseId := databaseIdValue
updateDatabaseRequestPayload := UpdateDatabaseRequestPayload{}
resp, reqErr := apiClient.UpdateDatabaseRequest(
context.Background(),
projectId,
region,
instanceId,
databaseId,
).UpdateDatabaseRequestPayload(updateDatabaseRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
if IsNil(resp) {
t.Fatalf("response not present")
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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 postgresflexalpha_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
updateInstancePartiallyRequestPayload := UpdateInstancePartiallyRequestPayload{}
reqErr := apiClient.UpdateInstancePartiallyRequest(
context.Background(),
projectId,
region,
instanceId,
).UpdateInstancePartiallyRequestPayload(updateInstancePartiallyRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
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 postgresflexalpha_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
updateInstanceRequestPayload := UpdateInstanceRequestPayload{}
reqErr := apiClient.UpdateInstanceRequest(
context.Background(),
projectId,
region,
instanceId,
).UpdateInstanceRequestPayload(updateInstanceRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
t.Run(
"Test DefaultApiService UpdateUserPartiallyRequest", 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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"userId"+"}",
url.PathEscape(ParameterValueToString(userIdValue, "userId")),
)
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 postgresflexalpha_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
userId := userIdValue
reqErr := apiClient.UpdateUserPartiallyRequest(
context.Background(),
projectId,
region,
instanceId,
userId,
).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
t.Run(
"Test DefaultApiService UpdateUserRequest", 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")),
)
regionValue := "region-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"region"+"}",
url.PathEscape(ParameterValueToString(regionValue, "region")),
)
instanceIdValue := "instanceId-value"
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"instanceId"+"}",
url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")),
)
userIdValue := int64(123)
_apiUrlPath = strings.ReplaceAll(
_apiUrlPath,
"{"+"userId"+"}",
url.PathEscape(ParameterValueToString(userIdValue, "userId")),
)
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 postgresflexalpha_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
userId := userIdValue
updateUserRequestPayload := UpdateUserRequestPayload{}
reqErr := apiClient.UpdateUserRequest(
context.Background(),
projectId,
region,
instanceId,
userId,
).UpdateUserRequestPayload(updateUserRequestPayload).Execute()
if reqErr != nil {
t.Fatalf("error in call: %v", reqErr)
}
},
)
}