712 lines
26 KiB
Go
712 lines
26 KiB
Go
/*
|
|
STACKIT Logs API
|
|
|
|
Testing DefaultApiService
|
|
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
|
|
|
package logsbeta
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
|
)
|
|
|
|
func Test_logsbeta_DefaultApiService(t *testing.T) {
|
|
|
|
t.Run("Test DefaultApiService CreateAccessToken", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := AccessToken{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
createAccessTokenPayload := CreateAccessTokenPayload{}
|
|
|
|
resp, reqErr := apiClient.CreateAccessToken(context.Background(), projectId, regionId, instanceId).CreateAccessTokenPayload(createAccessTokenPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService CreateLogsInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := LogsInstance{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
createLogsInstancePayload := CreateLogsInstancePayload{}
|
|
|
|
resp, reqErr := apiClient.CreateLogsInstance(context.Background(), projectId, regionId).CreateLogsInstancePayload(createLogsInstancePayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteAccessToken", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens/{tId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
tIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"tId"+"}", url.PathEscape(ParameterValueToString(tIdValue, "tId")), -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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
tId := tIdValue
|
|
|
|
reqErr := apiClient.DeleteAccessToken(context.Background(), projectId, regionId, instanceId, tId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteAllAccessTokens", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := AccessTokenList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.DeleteAllAccessTokens(context.Background(), projectId, regionId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteAllExpiredAccessTokens", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens/expired"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := AccessTokenList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.DeleteAllExpiredAccessTokens(context.Background(), projectId, regionId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService DeleteLogsInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
|
|
reqErr := apiClient.DeleteLogsInstance(context.Background(), projectId, regionId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetAccessToken", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens/{tId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
tIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"tId"+"}", url.PathEscape(ParameterValueToString(tIdValue, "tId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := AccessToken{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
tId := tIdValue
|
|
|
|
resp, reqErr := apiClient.GetAccessToken(context.Background(), projectId, regionId, instanceId, tId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService GetLogsInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := LogsInstance{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.GetLogsInstance(context.Background(), projectId, regionId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListAccessTokens", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := AccessTokenList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
|
|
resp, reqErr := apiClient.ListAccessTokens(context.Background(), projectId, regionId, instanceId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService ListLogsInstances", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
|
|
testDefaultApiServeMux := http.NewServeMux()
|
|
testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) {
|
|
data := LogsInstancesList{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
|
|
resp, reqErr := apiClient.ListLogsInstances(context.Background(), projectId, regionId).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService UpdateAccessToken", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}/access-tokens/{tId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1)
|
|
tIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"tId"+"}", url.PathEscape(ParameterValueToString(tIdValue, "tId")), -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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
tId := tIdValue
|
|
updateAccessTokenPayload := UpdateAccessTokenPayload{}
|
|
|
|
reqErr := apiClient.UpdateAccessToken(context.Background(), projectId, regionId, instanceId, tId).UpdateAccessTokenPayload(updateAccessTokenPayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
})
|
|
|
|
t.Run("Test DefaultApiService UpdateLogsInstance", func(t *testing.T) {
|
|
_apiUrlPath := "/v1beta/projects/{projectId}/regions/{regionId}/instances/{instanceId}"
|
|
projectIdValue := uuid.NewString()
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1)
|
|
regionIdValue := "regionId-value"
|
|
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"regionId"+"}", url.PathEscape(ParameterValueToString(regionIdValue, "regionId")), -1)
|
|
instanceIdValue := uuid.NewString()
|
|
_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 := LogsInstance{}
|
|
w.Header().Add("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(data)
|
|
})
|
|
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 logsbeta_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
|
|
regionId := regionIdValue
|
|
instanceId := instanceIdValue
|
|
updateLogsInstancePayload := UpdateLogsInstancePayload{}
|
|
|
|
resp, reqErr := apiClient.UpdateLogsInstance(context.Background(), projectId, regionId, instanceId).UpdateLogsInstancePayload(updateLogsInstancePayload).Execute()
|
|
|
|
if reqErr != nil {
|
|
t.Fatalf("error in call: %v", reqErr)
|
|
}
|
|
if IsNil(resp) {
|
|
t.Fatalf("response not present")
|
|
}
|
|
})
|
|
|
|
}
|