@@ -2,12 +2,9 @@ package stackit
22
33import (
44 "context"
5- "errors"
6- "net/http"
75
86 "github.com/google/uuid"
97
10- oapiError "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
118 albsdk "github.com/stackitcloud/stackit-sdk-go/services/alb/v2api"
129)
1310
@@ -48,7 +45,7 @@ func NewClient(cl *albsdk.APIClient) (Client, error) {
4845}
4946
5047func (cl client ) GetLoadBalancer (ctx context.Context , projectID , region , name string ) (* albsdk.LoadBalancer , error ) {
51- lb , err := cl .client .GetLoadBalancerExecute (ctx , projectID , region , name )
48+ lb , err := cl .client .DefaultAPI . GetLoadBalancer (ctx , projectID , region , name ). Execute ( )
5249 if isOpenAPINotFound (err ) {
5350 return lb , ErrorNotFound
5451 }
@@ -57,13 +54,13 @@ func (cl client) GetLoadBalancer(ctx context.Context, projectID, region, name st
5754
5855// DeleteLoadBalancer returns no error if the load balancer doesn't exist.
5956func (cl client ) DeleteLoadBalancer (ctx context.Context , projectID , region , name string ) error {
60- _ , err := cl .client .DeleteLoadBalancerExecute (ctx , projectID , region , name )
57+ _ , err := cl .client .DefaultAPI . DeleteLoadBalancer (ctx , projectID , region , name ). Execute ( )
6158 return err
6259}
6360
6461// CreateLoadBalancer returns ErrorNotFound if the project is not enabled.
6562func (cl client ) CreateLoadBalancer (ctx context.Context , projectID , region string , create * albsdk.CreateLoadBalancerPayload ) (* albsdk.LoadBalancer , error ) {
66- lb , err := cl .client .CreateLoadBalancer (ctx , projectID , region ).CreateLoadBalancerPayload (* create ).XRequestID (uuid .NewString ()).Execute ()
63+ lb , err := cl .client .DefaultAPI . CreateLoadBalancer (ctx , projectID , region ).CreateLoadBalancerPayload (* create ).XRequestID (uuid .NewString ()).Execute ()
6764 if isOpenAPINotFound (err ) {
6865 return lb , ErrorNotFound
6966 }
@@ -73,11 +70,11 @@ func (cl client) CreateLoadBalancer(ctx context.Context, projectID, region strin
7370func (cl client ) UpdateLoadBalancer (ctx context.Context , projectID , region , name string , update * albsdk.UpdateLoadBalancerPayload ) (
7471 * albsdk.LoadBalancer , error ,
7572) {
76- return cl .client .UpdateLoadBalancer (ctx , projectID , region , name ).UpdateLoadBalancerPayload (* update ).Execute ()
73+ return cl .client .DefaultAPI . UpdateLoadBalancer (ctx , projectID , region , name ).UpdateLoadBalancerPayload (* update ).Execute ()
7774}
7875
7976func (cl client ) UpdateTargetPool (ctx context.Context , projectID , region , name , targetPoolName string , payload albsdk.UpdateTargetPoolPayload ) error {
80- _ , err := cl .client .UpdateTargetPool (ctx , projectID , region , name , targetPoolName ).UpdateTargetPoolPayload (payload ).Execute ()
77+ _ , err := cl .client .DefaultAPI . UpdateTargetPool (ctx , projectID , region , name , targetPoolName ).UpdateTargetPoolPayload (payload ).Execute ()
8178 return err
8279}
8380
@@ -87,41 +84,29 @@ func (cl client) CreateCredentials(
8784 region string ,
8885 payload albsdk.CreateCredentialsPayload ,
8986) (* albsdk.CreateCredentialsResponse , error ) {
90- return cl .client .CreateCredentials (ctx , projectID , region ).CreateCredentialsPayload (payload ).XRequestID (uuid .NewString ()).Execute ()
87+ return cl .client .DefaultAPI . CreateCredentials (ctx , projectID , region ).CreateCredentialsPayload (payload ).XRequestID (uuid .NewString ()).Execute ()
9188}
9289
9390func (cl client ) ListCredentials (ctx context.Context , projectID , region string ) (* albsdk.ListCredentialsResponse , error ) {
94- return cl .client .ListCredentialsExecute (ctx , projectID , region )
91+ return cl .client .DefaultAPI . ListCredentials (ctx , projectID , region ). Execute ( )
9592}
9693
9794func (cl client ) GetCredentials (ctx context.Context , projectID , region , credentialsRef string ) (* albsdk.GetCredentialsResponse , error ) {
98- return cl .client .GetCredentialsExecute (ctx , projectID , region , credentialsRef )
95+ return cl .client .DefaultAPI . GetCredentials (ctx , projectID , region , credentialsRef ). Execute ( )
9996}
10097
10198func (cl client ) UpdateCredentials (ctx context.Context , projectID , region , credentialsRef string , payload albsdk.UpdateCredentialsPayload ) error {
102- _ , err := cl .client .UpdateCredentials (ctx , projectID , region , credentialsRef ).UpdateCredentialsPayload (payload ).Execute ()
99+ _ , err := cl .client .DefaultAPI . UpdateCredentials (ctx , projectID , region , credentialsRef ).UpdateCredentialsPayload (payload ).Execute ()
103100 if err != nil {
104101 return err
105102 }
106103 return nil
107104}
108105
109106func (cl client ) DeleteCredentials (ctx context.Context , projectID , region , credentialsRef string ) error {
110- _ , err := cl .client .DeleteCredentials (ctx , projectID , region , credentialsRef ).Execute ()
107+ _ , err := cl .client .DefaultAPI . DeleteCredentials (ctx , projectID , region , credentialsRef ).Execute ()
111108 if err != nil {
112109 return err
113110 }
114111 return nil
115112}
116-
117- func isOpenAPINotFound (err error ) bool {
118- apiErr := & oapiError.GenericOpenAPIError {}
119- if ! errors .As (err , & apiErr ) {
120- return false
121- }
122- return apiErr .StatusCode == http .StatusNotFound
123- }
124-
125- func IsNotFound (err error ) bool {
126- return errors .Is (err , ErrorNotFound )
127- }
0 commit comments