-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstances.go
More file actions
25 lines (22 loc) · 805 Bytes
/
instances.go
File metadata and controls
25 lines (22 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package stackit
import (
"context"
"net/http"
"github.com/stackitcloud/cloud-provider-stackit/pkg/stackit/stackiterrors"
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"github.com/stackitcloud/stackit-sdk-go/services/iaas/wait"
)
func (os *iaasClient) GetInstanceByID(ctx context.Context, instanceID string) (*iaas.Server, error) {
var httpResp *http.Response
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(ctx, &httpResp)
server, err := os.iaas.GetServer(ctxWithHTTPResp, os.projectID, os.region, instanceID).Execute()
if err != nil {
if httpResp != nil {
reqID := httpResp.Header.Get(wait.XRequestIDHeader)
return nil, stackiterrors.WrapErrorWithResponseID(err, reqID)
}
return nil, err
}
return server, nil
}