diff --git a/.github/workflows/validation-lambdalabs.yml b/.github/workflows/validation-lambdalabs.yml index ea8246de..194a0be6 100644 --- a/.github/workflows/validation-lambdalabs.yml +++ b/.github/workflows/validation-lambdalabs.yml @@ -8,9 +8,9 @@ on: # Allow manual triggering pull_request: paths: - - 'internal/lambdalabs/**' + - 'lambdalabs/**' - 'internal/validation/**' - - 'pkg/v1/**' + - '**/*.go' branches: [ main ] jobs: @@ -47,7 +47,7 @@ jobs: TEST_PUBLIC_KEY_BASE64: ${{ secrets.TEST_PUBLIC_KEY_BASE64 }} VALIDATION_TEST: true run: | - cd internal/lambdalabs + cd lambdalabs go test -v -short=false -timeout=30m ./... - name: Upload test results @@ -56,4 +56,4 @@ jobs: with: name: lambdalabs-validation-results path: | - internal/lambdalabs/coverage.out + lambdalabs/coverage.out diff --git a/.github/workflows/validation-shadeform.yml b/.github/workflows/validation-shadeform.yml index 3cd067f2..24f02299 100644 --- a/.github/workflows/validation-shadeform.yml +++ b/.github/workflows/validation-shadeform.yml @@ -8,9 +8,9 @@ on: # Allow manual triggering pull_request: paths: - - 'internal/shadeform/**' + - 'shadeform/**' - 'internal/validation/**' - - 'pkg/v1/**' + - '**/*.go' branches: [ main ] jobs: @@ -47,7 +47,7 @@ jobs: TEST_PUBLIC_KEY_BASE64: ${{ secrets.TEST_PUBLIC_KEY_BASE64 }} VALIDATION_TEST: true run: | - cd internal/shadeform + cd shadeform go test -v -short=false -timeout=30m ./... - name: Upload test results @@ -56,4 +56,4 @@ jobs: with: name: shadeform-validation-results path: | - internal/shadeform/coverage.out + shadeform/coverage.out diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..5c7247b4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/pkg/v1/V1_DESIGN_NOTES.md b/V1_DESIGN_NOTES.md similarity index 100% rename from pkg/v1/V1_DESIGN_NOTES.md rename to V1_DESIGN_NOTES.md diff --git a/pkg/v1/capabilities.go b/cloud/capabilities.go similarity index 98% rename from pkg/v1/capabilities.go rename to cloud/capabilities.go index 7342e0da..83953ac1 100644 --- a/pkg/v1/capabilities.go +++ b/cloud/capabilities.go @@ -1,4 +1,4 @@ -package v1 +package cloud type Capability string diff --git a/pkg/v1/client.go b/cloud/client.go similarity index 98% rename from pkg/v1/client.go rename to cloud/client.go index 54be552f..18bc9c77 100644 --- a/pkg/v1/client.go +++ b/cloud/client.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/pkg/v1/errors.go b/cloud/errors.go similarity index 97% rename from pkg/v1/errors.go rename to cloud/errors.go index ceb0b2ef..24b0070f 100644 --- a/pkg/v1/errors.go +++ b/cloud/errors.go @@ -1,4 +1,4 @@ -package v1 +package cloud import "errors" diff --git a/internal/fluidstack/Makefile b/cloud/fluidstack/Makefile similarity index 87% rename from internal/fluidstack/Makefile rename to cloud/fluidstack/Makefile index bc79b411..294ce020 100644 --- a/internal/fluidstack/Makefile +++ b/cloud/fluidstack/Makefile @@ -1,3 +1,4 @@ +# Generate fluidstack client generate-fluidstack-client: docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.8.0 generate \ --additional-properties disallowAdditionalPropertiesIfNotPresent=false \ @@ -7,5 +8,5 @@ generate-fluidstack-client: --git-repo-id cloud \ -o /local/gen/fluidstack sudo chown -R $(shell id -u):$(shell id -g) gen/fluidstack - gofmt -s -w gen/fluidstack + gofmt -s -w internal/gen/fluidstack rm -rf gen/fluidstack/go.mod gen/fluidstack/go.sum diff --git a/internal/fluidstack/v1/README.md b/cloud/fluidstack/README.md similarity index 100% rename from internal/fluidstack/v1/README.md rename to cloud/fluidstack/README.md diff --git a/internal/fluidstack/v1/SECURITY.md b/cloud/fluidstack/SECURITY.md similarity index 100% rename from internal/fluidstack/v1/SECURITY.md rename to cloud/fluidstack/SECURITY.md diff --git a/cloud/fluidstack/capabilities.go b/cloud/fluidstack/capabilities.go new file mode 100644 index 00000000..18e15d55 --- /dev/null +++ b/cloud/fluidstack/capabilities.go @@ -0,0 +1,19 @@ +package fluidstack + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *FluidStackClient) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + capabilities := cloud.Capabilities{ + cloud.CapabilityCreateInstance, + cloud.CapabilityTerminateInstance, + cloud.CapabilityStopStartInstance, + cloud.CapabilityTags, + cloud.CapabilityInstanceUserData, + } + + return capabilities, nil +} diff --git a/internal/fluidstack/v1/client.go b/cloud/fluidstack/client.go similarity index 80% rename from internal/fluidstack/v1/client.go rename to cloud/fluidstack/client.go index 9b343745..18dce890 100644 --- a/internal/fluidstack/v1/client.go +++ b/cloud/fluidstack/client.go @@ -1,4 +1,4 @@ -package v1 +package fluidstack import ( "context" @@ -6,8 +6,8 @@ import ( "fmt" "net/http" - openapi "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" ) const CloudProviderID = "fluidstack" @@ -18,7 +18,7 @@ type FluidStackCredential struct { APIKey string } -var _ v1.CloudCredential = &FluidStackCredential{} +var _ cloud.CloudCredential = &FluidStackCredential{} func NewFluidStackCredential(refID, apiKey string) *FluidStackCredential { return &FluidStackCredential{ @@ -33,12 +33,12 @@ func (c *FluidStackCredential) GetReferenceID() string { } // GetAPIType returns the API type for FluidStack -func (c *FluidStackCredential) GetAPIType() v1.APIType { - return v1.APITypeGlobal +func (c *FluidStackCredential) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal } // GetCloudProviderID returns the cloud provider ID for FluidStack -func (c *FluidStackCredential) GetCloudProviderID() v1.CloudProviderID { +func (c *FluidStackCredential) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } @@ -48,7 +48,7 @@ func (c *FluidStackCredential) GetTenantID() (string, error) { } // GetCapabilities returns the capabilities for FluidStack -func (c *FluidStackCredential) GetCapabilities(ctx context.Context) (v1.Capabilities, error) { +func (c *FluidStackCredential) GetCapabilities(ctx context.Context) (cloud.Capabilities, error) { client, err := c.MakeClient(ctx, "") if err != nil { return nil, err @@ -57,14 +57,14 @@ func (c *FluidStackCredential) GetCapabilities(ctx context.Context) (v1.Capabili } // MakeClient creates a new FluidStack client from this credential -func (c *FluidStackCredential) MakeClient(_ context.Context, _ string) (v1.CloudClient, error) { +func (c *FluidStackCredential) MakeClient(_ context.Context, _ string) (cloud.CloudClient, error) { return NewFluidStackClient(c.RefID, c.APIKey), nil } // FluidStackClient implements the CloudClient interface for FluidStack // It embeds NotImplCloudClient to handle unsupported features type FluidStackClient struct { - v1.NotImplCloudClient + cloud.NotImplCloudClient refID string apiKey string baseURL string @@ -72,7 +72,7 @@ type FluidStackClient struct { client *openapi.APIClient } -var _ v1.CloudClient = &FluidStackClient{} +var _ cloud.CloudClient = &FluidStackClient{} func NewFluidStackClient(refID, apiKey string) *FluidStackClient { config := openapi.NewConfiguration() @@ -88,17 +88,17 @@ func NewFluidStackClient(refID, apiKey string) *FluidStackClient { } // GetAPIType returns the API type for FluidStack -func (c *FluidStackClient) GetAPIType() v1.APIType { - return v1.APITypeGlobal +func (c *FluidStackClient) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal } // GetCloudProviderID returns the cloud provider ID for FluidStack -func (c *FluidStackClient) GetCloudProviderID() v1.CloudProviderID { +func (c *FluidStackClient) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } // MakeClient creates a new client instance -func (c *FluidStackClient) MakeClient(_ context.Context, _ string) (v1.CloudClient, error) { +func (c *FluidStackClient) MakeClient(_ context.Context, _ string) (cloud.CloudClient, error) { return c, nil } diff --git a/internal/fluidstack/gen/fluidstack/.gitignore b/cloud/fluidstack/gen/fluidstack/.gitignore similarity index 100% rename from internal/fluidstack/gen/fluidstack/.gitignore rename to cloud/fluidstack/gen/fluidstack/.gitignore diff --git a/internal/fluidstack/gen/fluidstack/.openapi-generator-ignore b/cloud/fluidstack/gen/fluidstack/.openapi-generator-ignore similarity index 100% rename from internal/fluidstack/gen/fluidstack/.openapi-generator-ignore rename to cloud/fluidstack/gen/fluidstack/.openapi-generator-ignore diff --git a/internal/fluidstack/gen/fluidstack/.openapi-generator/FILES b/cloud/fluidstack/gen/fluidstack/.openapi-generator/FILES similarity index 100% rename from internal/fluidstack/gen/fluidstack/.openapi-generator/FILES rename to cloud/fluidstack/gen/fluidstack/.openapi-generator/FILES diff --git a/internal/fluidstack/gen/fluidstack/.openapi-generator/VERSION b/cloud/fluidstack/gen/fluidstack/.openapi-generator/VERSION similarity index 100% rename from internal/fluidstack/gen/fluidstack/.openapi-generator/VERSION rename to cloud/fluidstack/gen/fluidstack/.openapi-generator/VERSION diff --git a/internal/fluidstack/gen/fluidstack/.travis.yml b/cloud/fluidstack/gen/fluidstack/.travis.yml similarity index 100% rename from internal/fluidstack/gen/fluidstack/.travis.yml rename to cloud/fluidstack/gen/fluidstack/.travis.yml diff --git a/internal/fluidstack/gen/fluidstack/README.md b/cloud/fluidstack/gen/fluidstack/README.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/README.md rename to cloud/fluidstack/gen/fluidstack/README.md diff --git a/internal/fluidstack/gen/fluidstack/api/openapi.yaml b/cloud/fluidstack/gen/fluidstack/api/openapi.yaml similarity index 100% rename from internal/fluidstack/gen/fluidstack/api/openapi.yaml rename to cloud/fluidstack/gen/fluidstack/api/openapi.yaml diff --git a/internal/fluidstack/gen/fluidstack/api_capabilities.go b/cloud/fluidstack/gen/fluidstack/api_capabilities.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_capabilities.go rename to cloud/fluidstack/gen/fluidstack/api_capabilities.go diff --git a/internal/fluidstack/gen/fluidstack/api_capacity.go b/cloud/fluidstack/gen/fluidstack/api_capacity.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_capacity.go rename to cloud/fluidstack/gen/fluidstack/api_capacity.go diff --git a/internal/fluidstack/gen/fluidstack/api_filesystems.go b/cloud/fluidstack/gen/fluidstack/api_filesystems.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_filesystems.go rename to cloud/fluidstack/gen/fluidstack/api_filesystems.go diff --git a/internal/fluidstack/gen/fluidstack/api_instance_types.go b/cloud/fluidstack/gen/fluidstack/api_instance_types.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_instance_types.go rename to cloud/fluidstack/gen/fluidstack/api_instance_types.go diff --git a/internal/fluidstack/gen/fluidstack/api_instances.go b/cloud/fluidstack/gen/fluidstack/api_instances.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_instances.go rename to cloud/fluidstack/gen/fluidstack/api_instances.go diff --git a/internal/fluidstack/gen/fluidstack/api_kubernetes.go b/cloud/fluidstack/gen/fluidstack/api_kubernetes.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_kubernetes.go rename to cloud/fluidstack/gen/fluidstack/api_kubernetes.go diff --git a/internal/fluidstack/gen/fluidstack/api_projects.go b/cloud/fluidstack/gen/fluidstack/api_projects.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_projects.go rename to cloud/fluidstack/gen/fluidstack/api_projects.go diff --git a/internal/fluidstack/gen/fluidstack/api_slurm.go b/cloud/fluidstack/gen/fluidstack/api_slurm.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/api_slurm.go rename to cloud/fluidstack/gen/fluidstack/api_slurm.go diff --git a/internal/fluidstack/gen/fluidstack/client.go b/cloud/fluidstack/gen/fluidstack/client.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/client.go rename to cloud/fluidstack/gen/fluidstack/client.go diff --git a/internal/fluidstack/gen/fluidstack/configuration.go b/cloud/fluidstack/gen/fluidstack/configuration.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/configuration.go rename to cloud/fluidstack/gen/fluidstack/configuration.go diff --git a/internal/fluidstack/gen/fluidstack/docs/Accelerator.md b/cloud/fluidstack/gen/fluidstack/docs/Accelerator.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Accelerator.md rename to cloud/fluidstack/gen/fluidstack/docs/Accelerator.md diff --git a/internal/fluidstack/gen/fluidstack/docs/CapabilitiesAPI.md b/cloud/fluidstack/gen/fluidstack/docs/CapabilitiesAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/CapabilitiesAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/CapabilitiesAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/Capability.md b/cloud/fluidstack/gen/fluidstack/docs/Capability.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Capability.md rename to cloud/fluidstack/gen/fluidstack/docs/Capability.md diff --git a/internal/fluidstack/gen/fluidstack/docs/CapacityAPI.md b/cloud/fluidstack/gen/fluidstack/docs/CapacityAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/CapacityAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/CapacityAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/Error.md b/cloud/fluidstack/gen/fluidstack/docs/Error.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Error.md rename to cloud/fluidstack/gen/fluidstack/docs/Error.md diff --git a/internal/fluidstack/gen/fluidstack/docs/Filesystem.md b/cloud/fluidstack/gen/fluidstack/docs/Filesystem.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Filesystem.md rename to cloud/fluidstack/gen/fluidstack/docs/Filesystem.md diff --git a/internal/fluidstack/gen/fluidstack/docs/FilesystemsAPI.md b/cloud/fluidstack/gen/fluidstack/docs/FilesystemsAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/FilesystemsAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/FilesystemsAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/FilesystemsPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/FilesystemsPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/FilesystemsPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/FilesystemsPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/Instance.md b/cloud/fluidstack/gen/fluidstack/docs/Instance.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Instance.md rename to cloud/fluidstack/gen/fluidstack/docs/Instance.md diff --git a/internal/fluidstack/gen/fluidstack/docs/InstanceState.md b/cloud/fluidstack/gen/fluidstack/docs/InstanceState.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/InstanceState.md rename to cloud/fluidstack/gen/fluidstack/docs/InstanceState.md diff --git a/internal/fluidstack/gen/fluidstack/docs/InstanceType.md b/cloud/fluidstack/gen/fluidstack/docs/InstanceType.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/InstanceType.md rename to cloud/fluidstack/gen/fluidstack/docs/InstanceType.md diff --git a/internal/fluidstack/gen/fluidstack/docs/InstanceTypesAPI.md b/cloud/fluidstack/gen/fluidstack/docs/InstanceTypesAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/InstanceTypesAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/InstanceTypesAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/InstancesAPI.md b/cloud/fluidstack/gen/fluidstack/docs/InstancesAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/InstancesAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/InstancesAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/InstancesPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/InstancesPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/InstancesPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/InstancesPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesAPI.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesCluster.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesCluster.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesCluster.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesCluster.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesClustersPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesClustersPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesClustersPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesClustersPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesNode.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesNode.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesNode.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesNode.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesNodeConditionsInner.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesNodeConditionsInner.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesNodeConditionsInner.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesNodeConditionsInner.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesNodePool.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesNodePool.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesNodePool.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesNodePool.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesNodePoolPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesNodePoolPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesNodePoolPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesNodePoolPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/KubernetesNodeTaintsInner.md b/cloud/fluidstack/gen/fluidstack/docs/KubernetesNodeTaintsInner.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/KubernetesNodeTaintsInner.md rename to cloud/fluidstack/gen/fluidstack/docs/KubernetesNodeTaintsInner.md diff --git a/internal/fluidstack/gen/fluidstack/docs/ListCapacity200ResponseInner.md b/cloud/fluidstack/gen/fluidstack/docs/ListCapacity200ResponseInner.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/ListCapacity200ResponseInner.md rename to cloud/fluidstack/gen/fluidstack/docs/ListCapacity200ResponseInner.md diff --git a/internal/fluidstack/gen/fluidstack/docs/Project.md b/cloud/fluidstack/gen/fluidstack/docs/Project.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/Project.md rename to cloud/fluidstack/gen/fluidstack/docs/Project.md diff --git a/internal/fluidstack/gen/fluidstack/docs/ProjectState.md b/cloud/fluidstack/gen/fluidstack/docs/ProjectState.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/ProjectState.md rename to cloud/fluidstack/gen/fluidstack/docs/ProjectState.md diff --git a/internal/fluidstack/gen/fluidstack/docs/ProjectsAPI.md b/cloud/fluidstack/gen/fluidstack/docs/ProjectsAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/ProjectsAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/ProjectsAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/ProjectsPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/ProjectsPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/ProjectsPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/ProjectsPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmAPI.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmAPI.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmAPI.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmAPI.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmCluster.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmCluster.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmCluster.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmCluster.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmClustersPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmClustersPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmClustersPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmClustersPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmLoginNode.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmLoginNode.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmLoginNode.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmLoginNode.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmNode.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmNode.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmNode.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmNode.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmNodePool.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmNodePool.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmNodePool.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmNodePool.md diff --git a/internal/fluidstack/gen/fluidstack/docs/SlurmNodePoolPostRequest.md b/cloud/fluidstack/gen/fluidstack/docs/SlurmNodePoolPostRequest.md similarity index 100% rename from internal/fluidstack/gen/fluidstack/docs/SlurmNodePoolPostRequest.md rename to cloud/fluidstack/gen/fluidstack/docs/SlurmNodePoolPostRequest.md diff --git a/internal/fluidstack/gen/fluidstack/git_push.sh b/cloud/fluidstack/gen/fluidstack/git_push.sh similarity index 100% rename from internal/fluidstack/gen/fluidstack/git_push.sh rename to cloud/fluidstack/gen/fluidstack/git_push.sh diff --git a/internal/fluidstack/gen/fluidstack/model_accelerator.go b/cloud/fluidstack/gen/fluidstack/model_accelerator.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_accelerator.go rename to cloud/fluidstack/gen/fluidstack/model_accelerator.go diff --git a/internal/fluidstack/gen/fluidstack/model_capability.go b/cloud/fluidstack/gen/fluidstack/model_capability.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_capability.go rename to cloud/fluidstack/gen/fluidstack/model_capability.go diff --git a/internal/fluidstack/gen/fluidstack/model_error.go b/cloud/fluidstack/gen/fluidstack/model_error.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_error.go rename to cloud/fluidstack/gen/fluidstack/model_error.go diff --git a/internal/fluidstack/gen/fluidstack/model_filesystem.go b/cloud/fluidstack/gen/fluidstack/model_filesystem.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_filesystem.go rename to cloud/fluidstack/gen/fluidstack/model_filesystem.go diff --git a/internal/fluidstack/gen/fluidstack/model_filesystems_post_request.go b/cloud/fluidstack/gen/fluidstack/model_filesystems_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_filesystems_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_filesystems_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_instance.go b/cloud/fluidstack/gen/fluidstack/model_instance.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_instance.go rename to cloud/fluidstack/gen/fluidstack/model_instance.go diff --git a/internal/fluidstack/gen/fluidstack/model_instance_state.go b/cloud/fluidstack/gen/fluidstack/model_instance_state.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_instance_state.go rename to cloud/fluidstack/gen/fluidstack/model_instance_state.go diff --git a/internal/fluidstack/gen/fluidstack/model_instance_type.go b/cloud/fluidstack/gen/fluidstack/model_instance_type.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_instance_type.go rename to cloud/fluidstack/gen/fluidstack/model_instance_type.go diff --git a/internal/fluidstack/gen/fluidstack/model_instances_post_request.go b/cloud/fluidstack/gen/fluidstack/model_instances_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_instances_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_instances_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_cluster.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_cluster.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_cluster.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_cluster.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_clusters_post_request.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_clusters_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_clusters_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_clusters_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_node.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_node.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_node.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_node.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_node_conditions_inner.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_node_conditions_inner.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_node_conditions_inner.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_node_conditions_inner.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_node_pool.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_node_pool.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_node_pool.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_node_pool.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_node_pool_post_request.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_node_pool_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_node_pool_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_node_pool_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_kubernetes_node_taints_inner.go b/cloud/fluidstack/gen/fluidstack/model_kubernetes_node_taints_inner.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_kubernetes_node_taints_inner.go rename to cloud/fluidstack/gen/fluidstack/model_kubernetes_node_taints_inner.go diff --git a/internal/fluidstack/gen/fluidstack/model_list_capacity_200_response_inner.go b/cloud/fluidstack/gen/fluidstack/model_list_capacity_200_response_inner.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_list_capacity_200_response_inner.go rename to cloud/fluidstack/gen/fluidstack/model_list_capacity_200_response_inner.go diff --git a/internal/fluidstack/gen/fluidstack/model_project.go b/cloud/fluidstack/gen/fluidstack/model_project.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_project.go rename to cloud/fluidstack/gen/fluidstack/model_project.go diff --git a/internal/fluidstack/gen/fluidstack/model_project_state.go b/cloud/fluidstack/gen/fluidstack/model_project_state.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_project_state.go rename to cloud/fluidstack/gen/fluidstack/model_project_state.go diff --git a/internal/fluidstack/gen/fluidstack/model_projects_post_request.go b/cloud/fluidstack/gen/fluidstack/model_projects_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_projects_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_projects_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_cluster.go b/cloud/fluidstack/gen/fluidstack/model_slurm_cluster.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_cluster.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_cluster.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_clusters_post_request.go b/cloud/fluidstack/gen/fluidstack/model_slurm_clusters_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_clusters_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_clusters_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_login_node.go b/cloud/fluidstack/gen/fluidstack/model_slurm_login_node.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_login_node.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_login_node.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_node.go b/cloud/fluidstack/gen/fluidstack/model_slurm_node.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_node.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_node.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_node_pool.go b/cloud/fluidstack/gen/fluidstack/model_slurm_node_pool.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_node_pool.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_node_pool.go diff --git a/internal/fluidstack/gen/fluidstack/model_slurm_node_pool_post_request.go b/cloud/fluidstack/gen/fluidstack/model_slurm_node_pool_post_request.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/model_slurm_node_pool_post_request.go rename to cloud/fluidstack/gen/fluidstack/model_slurm_node_pool_post_request.go diff --git a/internal/fluidstack/gen/fluidstack/response.go b/cloud/fluidstack/gen/fluidstack/response.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/response.go rename to cloud/fluidstack/gen/fluidstack/response.go diff --git a/internal/fluidstack/gen/fluidstack/test/api_capabilities_test.go b/cloud/fluidstack/gen/fluidstack/test/api_capabilities_test.go similarity index 90% rename from internal/fluidstack/gen/fluidstack/test/api_capabilities_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_capabilities_test.go index 2cdf48bb..ef62bf9f 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_capabilities_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_capabilities_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_capacity_test.go b/cloud/fluidstack/gen/fluidstack/test/api_capacity_test.go similarity index 90% rename from internal/fluidstack/gen/fluidstack/test/api_capacity_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_capacity_test.go index 619d438d..58e73e01 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_capacity_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_capacity_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_filesystems_test.go b/cloud/fluidstack/gen/fluidstack/test/api_filesystems_test.go similarity index 95% rename from internal/fluidstack/gen/fluidstack/test/api_filesystems_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_filesystems_test.go index 16241f4b..b0c35f50 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_filesystems_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_filesystems_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_instance_types_test.go b/cloud/fluidstack/gen/fluidstack/test/api_instance_types_test.go similarity index 90% rename from internal/fluidstack/gen/fluidstack/test/api_instance_types_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_instance_types_test.go index 2f085993..d526e130 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_instance_types_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_instance_types_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_instances_test.go b/cloud/fluidstack/gen/fluidstack/test/api_instances_test.go similarity index 96% rename from internal/fluidstack/gen/fluidstack/test/api_instances_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_instances_test.go index c906c16d..a48ae0ec 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_instances_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_instances_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_kubernetes_test.go b/cloud/fluidstack/gen/fluidstack/test/api_kubernetes_test.go similarity index 97% rename from internal/fluidstack/gen/fluidstack/test/api_kubernetes_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_kubernetes_test.go index 51be8baf..e4135745 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_kubernetes_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_kubernetes_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_projects_test.go b/cloud/fluidstack/gen/fluidstack/test/api_projects_test.go similarity index 95% rename from internal/fluidstack/gen/fluidstack/test/api_projects_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_projects_test.go index 020ed0ca..cfee5e99 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_projects_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_projects_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/test/api_slurm_test.go b/cloud/fluidstack/gen/fluidstack/test/api_slurm_test.go similarity index 97% rename from internal/fluidstack/gen/fluidstack/test/api_slurm_test.go rename to cloud/fluidstack/gen/fluidstack/test/api_slurm_test.go index 71b5a020..ad3b4451 100644 --- a/internal/fluidstack/gen/fluidstack/test/api_slurm_test.go +++ b/cloud/fluidstack/gen/fluidstack/test/api_slurm_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" + openapiclient "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/fluidstack/gen/fluidstack/utils.go b/cloud/fluidstack/gen/fluidstack/utils.go similarity index 100% rename from internal/fluidstack/gen/fluidstack/utils.go rename to cloud/fluidstack/gen/fluidstack/utils.go diff --git a/internal/fluidstack/v1/instance.go b/cloud/fluidstack/instance.go similarity index 72% rename from internal/fluidstack/v1/instance.go rename to cloud/fluidstack/instance.go index cc3c69d7..f134b586 100644 --- a/internal/fluidstack/v1/instance.go +++ b/cloud/fluidstack/instance.go @@ -1,14 +1,14 @@ -package v1 +package fluidstack import ( "context" "fmt" - openapi "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" ) -func (c *FluidStackClient) CreateInstance(ctx context.Context, attrs v1.CreateInstanceAttrs) (*v1.Instance, error) { +func (c *FluidStackClient) CreateInstance(ctx context.Context, attrs cloud.CreateInstanceAttrs) (*cloud.Instance, error) { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -44,7 +44,7 @@ func (c *FluidStackClient) CreateInstance(ctx context.Context, attrs v1.CreateIn return convertFluidStackInstanceToV1Instance(*resp), nil } -func (c *FluidStackClient) GetInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) (*v1.Instance, error) { +func (c *FluidStackClient) GetInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) (*cloud.Instance, error) { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -63,7 +63,7 @@ func (c *FluidStackClient) GetInstance(ctx context.Context, instanceID v1.CloudP return convertFluidStackInstanceToV1Instance(*resp), nil } -func (c *FluidStackClient) TerminateInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error { +func (c *FluidStackClient) TerminateInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) error { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -78,7 +78,7 @@ func (c *FluidStackClient) TerminateInstance(ctx context.Context, instanceID v1. return nil } -func (c *FluidStackClient) ListInstances(ctx context.Context, _ v1.ListInstancesArgs) ([]v1.Instance, error) { +func (c *FluidStackClient) ListInstances(ctx context.Context, _ cloud.ListInstancesArgs) ([]cloud.Instance, error) { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -90,7 +90,7 @@ func (c *FluidStackClient) ListInstances(ctx context.Context, _ v1.ListInstances return nil, fmt.Errorf("failed to list instances: %w", err) } - var instances []v1.Instance + var instances []cloud.Instance for _, fsInstance := range resp { instances = append(instances, *convertFluidStackInstanceToV1Instance(fsInstance)) } @@ -98,49 +98,49 @@ func (c *FluidStackClient) ListInstances(ctx context.Context, _ v1.ListInstances return instances, nil } -func (c *FluidStackClient) RebootInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented +func (c *FluidStackClient) RebootInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented } -func (c *FluidStackClient) MergeInstanceForUpdate(currInst v1.Instance, _ v1.Instance) v1.Instance { +func (c *FluidStackClient) MergeInstanceForUpdate(currInst cloud.Instance, _ cloud.Instance) cloud.Instance { return currInst } -func (c *FluidStackClient) MergeInstanceTypeForUpdate(currIt v1.InstanceType, _ v1.InstanceType) v1.InstanceType { +func (c *FluidStackClient) MergeInstanceTypeForUpdate(currIt cloud.InstanceType, _ cloud.InstanceType) cloud.InstanceType { return currIt } -func convertFluidStackInstanceToV1Instance(fsInstance openapi.Instance) *v1.Instance { +func convertFluidStackInstanceToV1Instance(fsInstance openapi.Instance) *cloud.Instance { var privateIP string if fsInstance.Ip.IsSet() && fsInstance.Ip.Get() != nil { privateIP = *fsInstance.Ip.Get() } - var lifecycleStatus v1.LifecycleStatus + var lifecycleStatus cloud.LifecycleStatus switch fsInstance.State { case openapi.INSTANCE_RUNNING: - lifecycleStatus = v1.LifecycleStatusRunning + lifecycleStatus = cloud.LifecycleStatusRunning case openapi.INSTANCE_STOPPED: - lifecycleStatus = v1.LifecycleStatusStopped + lifecycleStatus = cloud.LifecycleStatusStopped case openapi.INSTANCE_STOPPING: - lifecycleStatus = v1.LifecycleStatusStopping + lifecycleStatus = cloud.LifecycleStatusStopping case openapi.INSTANCE_STARTING, openapi.INSTANCE_CREATING: - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending case openapi.INSTANCE_DELETING: - lifecycleStatus = v1.LifecycleStatusTerminating + lifecycleStatus = cloud.LifecycleStatusTerminating case openapi.INSTANCE_ERROR: - lifecycleStatus = v1.LifecycleStatusFailed + lifecycleStatus = cloud.LifecycleStatusFailed default: - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending } - instance := &v1.Instance{ + instance := &cloud.Instance{ Name: fsInstance.Name, - CloudID: v1.CloudProviderInstanceID(fsInstance.Id), + CloudID: cloud.CloudProviderInstanceID(fsInstance.Id), InstanceType: fsInstance.Type, PrivateIP: privateIP, ImageID: fsInstance.Image, - Status: v1.Status{ + Status: cloud.Status{ LifecycleStatus: lifecycleStatus, }, Tags: make(map[string]string), diff --git a/internal/fluidstack/v1/instancetype.go b/cloud/fluidstack/instancetype.go similarity index 74% rename from internal/fluidstack/v1/instancetype.go rename to cloud/fluidstack/instancetype.go index eb2a90f6..23d132d4 100644 --- a/internal/fluidstack/v1/instancetype.go +++ b/cloud/fluidstack/instancetype.go @@ -1,4 +1,4 @@ -package v1 +package fluidstack import ( "context" @@ -9,11 +9,11 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - openapi "github.com/brevdev/cloud/internal/fluidstack/gen/fluidstack" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/fluidstack/gen/fluidstack" ) -func (c *FluidStackClient) GetInstanceTypes(ctx context.Context, _ v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) { +func (c *FluidStackClient) GetInstanceTypes(ctx context.Context, _ cloud.GetInstanceTypeArgs) ([]cloud.InstanceType, error) { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -25,7 +25,7 @@ func (c *FluidStackClient) GetInstanceTypes(ctx context.Context, _ v1.GetInstanc return nil, fmt.Errorf("failed to get instance types: %w", err) } - var instanceTypes []v1.InstanceType + var instanceTypes []cloud.InstanceType for _, fsInstanceType := range resp { instanceType := convertFluidStackInstanceTypeToV1InstanceType("", fsInstanceType, true) instanceTypes = append(instanceTypes, instanceType) @@ -38,7 +38,7 @@ func (c *FluidStackClient) GetInstanceTypePollTime() time.Duration { return 5 * time.Minute } -func (c *FluidStackClient) GetLocations(ctx context.Context, _ v1.GetLocationsArgs) ([]v1.Location, error) { +func (c *FluidStackClient) GetLocations(ctx context.Context, _ cloud.GetLocationsArgs) ([]cloud.Location, error) { authCtx := c.makeAuthContext(ctx) projectCtx := c.makeProjectContext(authCtx) @@ -50,23 +50,21 @@ func (c *FluidStackClient) GetLocations(ctx context.Context, _ v1.GetLocationsAr return nil, fmt.Errorf("failed to get locations: %w", err) } - var locations []v1.Location - if resp != nil { - for _, capacity := range resp { - location := v1.Location{ - Name: capacity.Name, - Description: capacity.Name, - Available: capacity.Capacity > 0, - } - locations = append(locations, location) + var locations []cloud.Location + for _, capacity := range resp { + location := cloud.Location{ + Name: capacity.Name, + Description: capacity.Name, + Available: capacity.Capacity > 0, } + locations = append(locations, location) } return locations, nil } -func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceType openapi.InstanceType, isAvailable bool) v1.InstanceType { - var gpus []v1.GPU +func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceType openapi.InstanceType, isAvailable bool) cloud.InstanceType { + var gpus []cloud.GPU if fsInstanceType.GpuCount != nil && *fsInstanceType.GpuCount > 0 { count := int(*fsInstanceType.GpuCount) @@ -76,7 +74,7 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy } for i := 0; i < count; i++ { - gpus = append(gpus, v1.GPU{ + gpus = append(gpus, cloud.GPU{ Name: model, }) } @@ -98,7 +96,7 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy price, _ := currency.NewAmount("0", "USD") - return v1.InstanceType{ + return cloud.InstanceType{ Type: fsInstanceType.Name, VCPU: vcpus, Memory: ram, diff --git a/pkg/v1/image.go b/cloud/image.go similarity index 98% rename from pkg/v1/image.go rename to cloud/image.go index 4298ac71..588b4576 100644 --- a/pkg/v1/image.go +++ b/cloud/image.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/brevdev/cloud/pkg/ssh" + "github.com/brevdev/sdk/internal/ssh" ) type CloudMachineImage interface { diff --git a/pkg/v1/instance.go b/cloud/instance.go similarity index 99% rename from pkg/v1/instance.go rename to cloud/instance.go index becf1961..7fc56c24 100644 --- a/pkg/v1/instance.go +++ b/cloud/instance.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" @@ -7,8 +7,8 @@ import ( "time" "github.com/alecthomas/units" - "github.com/brevdev/cloud/internal/collections" - "github.com/brevdev/cloud/pkg/ssh" + "github.com/brevdev/sdk/internal/collections" + "github.com/brevdev/sdk/internal/ssh" "github.com/google/uuid" ) diff --git a/pkg/v1/instancetype.go b/cloud/instancetype.go similarity index 99% rename from pkg/v1/instancetype.go rename to cloud/instancetype.go index 53777189..75bb7cd6 100644 --- a/pkg/v1/instancetype.go +++ b/cloud/instancetype.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/internal/lambdalabs/CONTRIBUTE.md b/cloud/lambdalabs/CONTRIBUTE.md similarity index 100% rename from internal/lambdalabs/CONTRIBUTE.md rename to cloud/lambdalabs/CONTRIBUTE.md diff --git a/internal/lambdalabs/Makefile b/cloud/lambdalabs/Makefile similarity index 84% rename from internal/lambdalabs/Makefile rename to cloud/lambdalabs/Makefile index d62dedec..dbc424fb 100644 --- a/internal/lambdalabs/Makefile +++ b/cloud/lambdalabs/Makefile @@ -1,3 +1,4 @@ +# Generate lambdalabs client generate-lambdalabs-client: docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.8.0 generate \ --additional-properties disallowAdditionalPropertiesIfNotPresent=false \ @@ -8,4 +9,4 @@ generate-lambdalabs-client: -o /local/gen/lambdalabs sudo chown -R $(shell id -u):$(shell id -g) gen/lambdalabs gofmt -s -w gen/lambdalabs - rm -rf gen/lambdalabs/go.mod gen/lambdalabs/go.sum \ No newline at end of file + rm -rf gen/lambdalabs/go.mod gen/lambdalabs/go.sum diff --git a/internal/lambdalabs/v1/README.md b/cloud/lambdalabs/README.md similarity index 100% rename from internal/lambdalabs/v1/README.md rename to cloud/lambdalabs/README.md diff --git a/internal/lambdalabs/SECURITY.md b/cloud/lambdalabs/SECURITY.md similarity index 100% rename from internal/lambdalabs/SECURITY.md rename to cloud/lambdalabs/SECURITY.md diff --git a/cloud/lambdalabs/capabilities.go b/cloud/lambdalabs/capabilities.go new file mode 100644 index 00000000..64eedadd --- /dev/null +++ b/cloud/lambdalabs/capabilities.go @@ -0,0 +1,38 @@ +package lambdalabs + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +// getLambdaLabsCapabilities returns the unified capabilities for Lambda Labs +// Based on API documentation at https://cloud.lambda.ai/api/v1/openapi.json +func getLambdaLabsCapabilities() cloud.Capabilities { + return cloud.Capabilities{ + // SUPPORTED FEATURES (with API evidence): + + // Instance Management + cloud.CapabilityCreateInstance, // POST /api/v1/instance-operations/launch + cloud.CapabilityTerminateInstance, // POST /api/v1/instance-operations/terminate + cloud.CapabilityCreateTerminateInstance, // Combined create/terminate capability + cloud.CapabilityRebootInstance, // POST /api/v1/instance-operations/restart + + // UNSUPPORTED FEATURES (no API evidence found): + // - cloud.CapabilityModifyFirewall // Firewall management is project-level, not instance-level + // - cloud.CapabilityStopStartInstance // No stop/start endpoints + // - cloud.CapabilityResizeInstanceVolume // No volume resizing endpoints + // - cloud.CapabilityMachineImage // No image endpoints + // - cloud.CapabilityTags // No tagging endpoints + } +} + +// GetCapabilities returns the capabilities of Lambda Labs client +func (c *LambdaLabsClient) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + return getLambdaLabsCapabilities(), nil +} + +// GetCapabilities returns the capabilities for Lambda Labs credential +func (c *LambdaLabsCredential) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + return getLambdaLabsCapabilities(), nil +} diff --git a/cloud/lambdalabs/capabilities_test.go b/cloud/lambdalabs/capabilities_test.go new file mode 100644 index 00000000..c51f580f --- /dev/null +++ b/cloud/lambdalabs/capabilities_test.go @@ -0,0 +1,33 @@ +package lambdalabs + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/brevdev/sdk/cloud" +) + +func TestLambdaLabsClient_GetCapabilities(t *testing.T) { + client := &LambdaLabsClient{} + capabilities, err := client.GetCapabilities(context.Background()) + require.NoError(t, err) + + assert.Contains(t, capabilities, cloud.CapabilityCreateInstance) + assert.Contains(t, capabilities, cloud.CapabilityTerminateInstance) + assert.Contains(t, capabilities, cloud.CapabilityRebootInstance) + assert.NotContains(t, capabilities, cloud.CapabilityStopStartInstance) +} + +func TestLambdaLabsCredential_GetCapabilities(t *testing.T) { + cred := &LambdaLabsCredential{} + capabilities, err := cred.GetCapabilities(context.Background()) + require.NoError(t, err) + + assert.Contains(t, capabilities, cloud.CapabilityCreateInstance) + assert.Contains(t, capabilities, cloud.CapabilityTerminateInstance) + assert.Contains(t, capabilities, cloud.CapabilityRebootInstance) + assert.NotContains(t, capabilities, cloud.CapabilityStopStartInstance) +} diff --git a/internal/lambdalabs/v1/client.go b/cloud/lambdalabs/client.go similarity index 89% rename from internal/lambdalabs/v1/client.go rename to cloud/lambdalabs/client.go index 7eab9999..15010c1f 100644 --- a/internal/lambdalabs/v1/client.go +++ b/cloud/lambdalabs/client.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -6,8 +6,8 @@ import ( "net/http" "time" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" "github.com/cenkalti/backoff/v4" ) @@ -20,7 +20,7 @@ const ( // LambdaLabsClient implements the CloudClient interface for Lambda Labs // It embeds NotImplCloudClient to handle unsupported features type LambdaLabsClient struct { - v1.NotImplCloudClient + cloud.NotImplCloudClient refID string apiKey string baseURL string @@ -29,7 +29,7 @@ type LambdaLabsClient struct { backoff backoff.BackOff } -var _ v1.CloudClient = &LambdaLabsClient{} +var _ cloud.CloudClient = &LambdaLabsClient{} type options struct { baseURL string @@ -113,17 +113,17 @@ func NewLambdaLabsClient(refID, apiKey string, opts ...Option) (*LambdaLabsClien } // GetAPIType returns the API type for Lambda Labs -func (c *LambdaLabsClient) GetAPIType() v1.APIType { - return v1.APITypeGlobal // Lambda Labs uses a global API +func (c *LambdaLabsClient) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal // Lambda Labs uses a global API } // GetCloudProviderID returns the cloud provider ID for Lambda Labs -func (c *LambdaLabsClient) GetCloudProviderID() v1.CloudProviderID { +func (c *LambdaLabsClient) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } // MakeClient creates a new client instance -func (c *LambdaLabsClient) MakeClient(_ context.Context, location string) (v1.CloudClient, error) { +func (c *LambdaLabsClient) MakeClient(_ context.Context, location string) (cloud.CloudClient, error) { if location == "" { location = DefaultRegion } diff --git a/internal/lambdalabs/v1/client_test.go b/cloud/lambdalabs/client_test.go similarity index 90% rename from internal/lambdalabs/v1/client_test.go rename to cloud/lambdalabs/client_test.go index 0c026bcf..2782e01a 100644 --- a/internal/lambdalabs/v1/client_test.go +++ b/cloud/lambdalabs/client_test.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -8,18 +8,18 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" ) func TestLambdaLabsClient_GetAPIType(t *testing.T) { client := &LambdaLabsClient{} - assert.Equal(t, v1.APITypeGlobal, client.GetAPIType()) + assert.Equal(t, cloud.APITypeGlobal, client.GetAPIType()) } func TestLambdaLabsClient_GetCloudProviderID(t *testing.T) { client := &LambdaLabsClient{} - assert.Equal(t, v1.CloudProviderID(CloudProviderID), client.GetCloudProviderID()) + assert.Equal(t, cloud.CloudProviderID(CloudProviderID), client.GetCloudProviderID()) } func TestLambdaLabsClient_MakeClient(t *testing.T) { diff --git a/internal/lambdalabs/v1/common_test.go b/cloud/lambdalabs/common_test.go similarity index 94% rename from internal/lambdalabs/v1/common_test.go rename to cloud/lambdalabs/common_test.go index df34d3fa..8de4167a 100644 --- a/internal/lambdalabs/v1/common_test.go +++ b/cloud/lambdalabs/common_test.go @@ -1,7 +1,7 @@ -package v1 +package lambdalabs import ( - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" "github.com/cenkalti/backoff/v4" "github.com/jarcoal/httpmock" ) diff --git a/internal/lambdalabs/v1/credential.go b/cloud/lambdalabs/credential.go similarity index 79% rename from internal/lambdalabs/v1/credential.go rename to cloud/lambdalabs/credential.go index e0de8bac..eecbe44a 100644 --- a/internal/lambdalabs/v1/credential.go +++ b/cloud/lambdalabs/credential.go @@ -1,11 +1,11 @@ -package v1 +package lambdalabs import ( "context" "crypto/sha256" "fmt" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) const CloudProviderID = "lambda-labs" @@ -18,7 +18,7 @@ type LambdaLabsCredential struct { APIKey string } -var _ v1.CloudCredential = &LambdaLabsCredential{} +var _ cloud.CloudCredential = &LambdaLabsCredential{} // NewLambdaLabsCredential creates a new Lambda Labs credential func NewLambdaLabsCredential(refID, apiKey string) *LambdaLabsCredential { @@ -34,12 +34,12 @@ func (c *LambdaLabsCredential) GetReferenceID() string { } // GetAPIType returns the API type for Lambda Labs -func (c *LambdaLabsCredential) GetAPIType() v1.APIType { - return v1.APITypeGlobal +func (c *LambdaLabsCredential) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal } // GetCloudProviderID returns the cloud provider ID for Lambda Labs -func (c *LambdaLabsCredential) GetCloudProviderID() v1.CloudProviderID { +func (c *LambdaLabsCredential) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } @@ -49,6 +49,6 @@ func (c *LambdaLabsCredential) GetTenantID() (string, error) { } // MakeClient creates a new Lambda Labs client from this credential -func (c *LambdaLabsCredential) MakeClient(_ context.Context, _ string) (v1.CloudClient, error) { +func (c *LambdaLabsCredential) MakeClient(_ context.Context, _ string) (cloud.CloudClient, error) { return NewLambdaLabsClient(c.RefID, c.APIKey) } diff --git a/internal/lambdalabs/v1/credential_test.go b/cloud/lambdalabs/credential_test.go similarity index 85% rename from internal/lambdalabs/v1/credential_test.go rename to cloud/lambdalabs/credential_test.go index 700358de..2aca0f68 100644 --- a/internal/lambdalabs/v1/credential_test.go +++ b/cloud/lambdalabs/credential_test.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) func TestLambdaLabsCredential_GetReferenceID(t *testing.T) { @@ -21,12 +21,12 @@ func TestLambdaLabsCredential_GetReferenceID(t *testing.T) { func TestLambdaLabsCredential_GetAPIType(t *testing.T) { cred := &LambdaLabsCredential{} - assert.Equal(t, v1.APITypeGlobal, cred.GetAPIType()) + assert.Equal(t, cloud.APITypeGlobal, cred.GetAPIType()) } func TestLambdaLabsCredential_GetCloudProviderID(t *testing.T) { cred := &LambdaLabsCredential{} - assert.Equal(t, v1.CloudProviderID("lambda-labs"), cred.GetCloudProviderID()) + assert.Equal(t, cloud.CloudProviderID("lambda-labs"), cred.GetCloudProviderID()) } func TestLambdaLabsCredential_GetTenantID(t *testing.T) { diff --git a/internal/lambdalabs/v1/errors.go b/cloud/lambdalabs/errors.go similarity index 83% rename from internal/lambdalabs/v1/errors.go rename to cloud/lambdalabs/errors.go index 10a47a63..382b8038 100644 --- a/internal/lambdalabs/v1/errors.go +++ b/cloud/lambdalabs/errors.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -7,8 +7,8 @@ import ( "net/http" "strings" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" "github.com/cenkalti/backoff/v4" ) @@ -27,7 +27,7 @@ func handleAPIError(_ context.Context, resp *http.Response, err error) error { } outErr := fmt.Errorf("LambdaLabs API error\n%s\n%s:\nErr: %s\n%s", resp.Request.URL, resp.Status, err.Error(), body) if strings.Contains(body, "instance does not exist") { //nolint:gocritic // ignore - return backoff.Permanent(v1.ErrInstanceNotFound) + return backoff.Permanent(cloud.ErrInstanceNotFound) } else if strings.Contains(body, "banned you temporarily") { return outErr } else if resp.StatusCode < 500 && resp.StatusCode != 429 { // 429 Too Many Requests (use back off) @@ -42,9 +42,9 @@ func handleErrToCloudErr(e error) error { return nil } if strings.Contains(e.Error(), "Not enough capacity") || strings.Contains(e.Error(), "insufficient-capacity") { //nolint:gocritic // ignore - return v1.ErrInsufficientResources + return cloud.ErrInsufficientResources } else if strings.Contains(e.Error(), "global/invalid-parameters") && strings.Contains(e.Error(), "Region") && strings.Contains(e.Error(), "does not exist") { - return v1.ErrInsufficientResources + return cloud.ErrInsufficientResources } else { return e } diff --git a/internal/lambdalabs/v1/errors_test.go b/cloud/lambdalabs/errors_test.go similarity index 93% rename from internal/lambdalabs/v1/errors_test.go rename to cloud/lambdalabs/errors_test.go index d6a1cc72..bbed6180 100644 --- a/internal/lambdalabs/v1/errors_test.go +++ b/cloud/lambdalabs/errors_test.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" ) func TestHandleAPIError_InstanceNotFound(t *testing.T) { @@ -30,7 +30,7 @@ func TestHandleAPIError_InstanceNotFound(t *testing.T) { var permanentErr *backoff.PermanentError require.True(t, errors.As(err, &permanentErr)) - assert.Equal(t, v1.ErrInstanceNotFound, permanentErr.Err) + assert.Equal(t, cloud.ErrInstanceNotFound, permanentErr.Err) } func TestHandleAPIError_BannedTemporarily(t *testing.T) { @@ -203,17 +203,17 @@ func TestHandleErrToCloudErr_CapacityErrors(t *testing.T) { { name: "not enough capacity", errMsg: "Not enough capacity in region", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, { name: "insufficient capacity", errMsg: "insufficient-capacity error occurred", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, { name: "capacity with mixed case", errMsg: "Error: Not enough capacity available", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, } @@ -235,12 +235,12 @@ func TestHandleErrToCloudErr_RegionErrors(t *testing.T) { { name: "region does not exist", errMsg: "global/invalid-parameters: Region us-invalid-1 does not exist", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, { name: "region error with different format", errMsg: "global/invalid-parameters error: Region eu-central-99 does not exist in this zone", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, { name: "invalid parameters without region", @@ -253,7 +253,7 @@ func TestHandleErrToCloudErr_RegionErrors(t *testing.T) { t.Run(tt.name, func(t *testing.T) { inputErr := errors.New(tt.errMsg) result := handleErrToCloudErr(inputErr) - if tt.expected == v1.ErrInsufficientResources { + if tt.expected == cloud.ErrInsufficientResources { assert.Equal(t, tt.expected, result) } else { assert.Equal(t, tt.expected.Error(), result.Error()) @@ -304,12 +304,12 @@ func TestHandleErrToCloudErr_EdgeCases(t *testing.T) { { name: "capacity substring in larger message", errMsg: "The request failed because Not enough capacity is available in the selected region", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, { name: "insufficient capacity with prefix", errMsg: "API Error: insufficient-capacity - please try again later", - expected: v1.ErrInsufficientResources, + expected: cloud.ErrInsufficientResources, }, } @@ -317,7 +317,7 @@ func TestHandleErrToCloudErr_EdgeCases(t *testing.T) { t.Run(tt.name, func(t *testing.T) { inputErr := errors.New(tt.errMsg) result := handleErrToCloudErr(inputErr) - if tt.expected == v1.ErrInsufficientResources { + if tt.expected == cloud.ErrInsufficientResources { assert.Equal(t, tt.expected, result) } else { assert.Equal(t, tt.expected.Error(), result.Error()) diff --git a/internal/lambdalabs/gen/lambdalabs/.gitignore b/cloud/lambdalabs/gen/lambdalabs/.gitignore similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/.gitignore rename to cloud/lambdalabs/gen/lambdalabs/.gitignore diff --git a/internal/lambdalabs/gen/lambdalabs/.openapi-generator-ignore b/cloud/lambdalabs/gen/lambdalabs/.openapi-generator-ignore similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/.openapi-generator-ignore rename to cloud/lambdalabs/gen/lambdalabs/.openapi-generator-ignore diff --git a/internal/lambdalabs/gen/lambdalabs/.openapi-generator/FILES b/cloud/lambdalabs/gen/lambdalabs/.openapi-generator/FILES similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/.openapi-generator/FILES rename to cloud/lambdalabs/gen/lambdalabs/.openapi-generator/FILES diff --git a/internal/lambdalabs/gen/lambdalabs/.openapi-generator/VERSION b/cloud/lambdalabs/gen/lambdalabs/.openapi-generator/VERSION similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/.openapi-generator/VERSION rename to cloud/lambdalabs/gen/lambdalabs/.openapi-generator/VERSION diff --git a/internal/lambdalabs/gen/lambdalabs/.travis.yml b/cloud/lambdalabs/gen/lambdalabs/.travis.yml similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/.travis.yml rename to cloud/lambdalabs/gen/lambdalabs/.travis.yml diff --git a/internal/lambdalabs/gen/lambdalabs/README.md b/cloud/lambdalabs/gen/lambdalabs/README.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/README.md rename to cloud/lambdalabs/gen/lambdalabs/README.md diff --git a/internal/lambdalabs/gen/lambdalabs/api/openapi.yaml b/cloud/lambdalabs/gen/lambdalabs/api/openapi.yaml similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/api/openapi.yaml rename to cloud/lambdalabs/gen/lambdalabs/api/openapi.yaml diff --git a/internal/lambdalabs/gen/lambdalabs/api_default.go b/cloud/lambdalabs/gen/lambdalabs/api_default.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/api_default.go rename to cloud/lambdalabs/gen/lambdalabs/api_default.go diff --git a/internal/lambdalabs/gen/lambdalabs/client.go b/cloud/lambdalabs/gen/lambdalabs/client.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/client.go rename to cloud/lambdalabs/gen/lambdalabs/client.go diff --git a/internal/lambdalabs/gen/lambdalabs/configuration.go b/cloud/lambdalabs/gen/lambdalabs/configuration.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/configuration.go rename to cloud/lambdalabs/gen/lambdalabs/configuration.go diff --git a/internal/lambdalabs/gen/lambdalabs/docs/AddSSHKey200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/AddSSHKey200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/AddSSHKey200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/AddSSHKey200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/AddSSHKeyRequest.md b/cloud/lambdalabs/gen/lambdalabs/docs/AddSSHKeyRequest.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/AddSSHKeyRequest.md rename to cloud/lambdalabs/gen/lambdalabs/docs/AddSSHKeyRequest.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/DefaultAPI.md b/cloud/lambdalabs/gen/lambdalabs/docs/DefaultAPI.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/DefaultAPI.md rename to cloud/lambdalabs/gen/lambdalabs/docs/DefaultAPI.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ErrorCode.md b/cloud/lambdalabs/gen/lambdalabs/docs/ErrorCode.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ErrorCode.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ErrorCode.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ErrorResponseBody.md b/cloud/lambdalabs/gen/lambdalabs/docs/ErrorResponseBody.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ErrorResponseBody.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ErrorResponseBody.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/FileSystem.md b/cloud/lambdalabs/gen/lambdalabs/docs/FileSystem.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/FileSystem.md rename to cloud/lambdalabs/gen/lambdalabs/docs/FileSystem.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/GetInstance200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/GetInstance200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/GetInstance200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/GetInstance200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/Instance.md b/cloud/lambdalabs/gen/lambdalabs/docs/Instance.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/Instance.md rename to cloud/lambdalabs/gen/lambdalabs/docs/Instance.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/InstanceType.md b/cloud/lambdalabs/gen/lambdalabs/docs/InstanceType.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/InstanceType.md rename to cloud/lambdalabs/gen/lambdalabs/docs/InstanceType.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/InstanceTypeSpecs.md b/cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypeSpecs.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/InstanceTypeSpecs.md rename to cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypeSpecs.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/InstanceTypes200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypes200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/InstanceTypes200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypes200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/InstanceTypes200ResponseDataValue.md b/cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypes200ResponseDataValue.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/InstanceTypes200ResponseDataValue.md rename to cloud/lambdalabs/gen/lambdalabs/docs/InstanceTypes200ResponseDataValue.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/LaunchInstance200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstance200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/LaunchInstance200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstance200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/LaunchInstance200ResponseData.md b/cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstance200ResponseData.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/LaunchInstance200ResponseData.md rename to cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstance200ResponseData.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/LaunchInstanceRequest.md b/cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstanceRequest.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/LaunchInstanceRequest.md rename to cloud/lambdalabs/gen/lambdalabs/docs/LaunchInstanceRequest.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ListFileSystems200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/ListFileSystems200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ListFileSystems200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ListFileSystems200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ListInstances200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/ListInstances200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ListInstances200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ListInstances200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ListSSHKeys200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/ListSSHKeys200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ListSSHKeys200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ListSSHKeys200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/ModelError.md b/cloud/lambdalabs/gen/lambdalabs/docs/ModelError.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/ModelError.md rename to cloud/lambdalabs/gen/lambdalabs/docs/ModelError.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/Region.md b/cloud/lambdalabs/gen/lambdalabs/docs/Region.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/Region.md rename to cloud/lambdalabs/gen/lambdalabs/docs/Region.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/RestartInstance200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/RestartInstance200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/RestartInstance200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/RestartInstance200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/RestartInstance200ResponseData.md b/cloud/lambdalabs/gen/lambdalabs/docs/RestartInstance200ResponseData.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/RestartInstance200ResponseData.md rename to cloud/lambdalabs/gen/lambdalabs/docs/RestartInstance200ResponseData.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/RestartInstanceRequest.md b/cloud/lambdalabs/gen/lambdalabs/docs/RestartInstanceRequest.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/RestartInstanceRequest.md rename to cloud/lambdalabs/gen/lambdalabs/docs/RestartInstanceRequest.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/SshKey.md b/cloud/lambdalabs/gen/lambdalabs/docs/SshKey.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/SshKey.md rename to cloud/lambdalabs/gen/lambdalabs/docs/SshKey.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/TerminateInstance200Response.md b/cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstance200Response.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/TerminateInstance200Response.md rename to cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstance200Response.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/TerminateInstance200ResponseData.md b/cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstance200ResponseData.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/TerminateInstance200ResponseData.md rename to cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstance200ResponseData.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/TerminateInstanceRequest.md b/cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstanceRequest.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/TerminateInstanceRequest.md rename to cloud/lambdalabs/gen/lambdalabs/docs/TerminateInstanceRequest.md diff --git a/internal/lambdalabs/gen/lambdalabs/docs/User.md b/cloud/lambdalabs/gen/lambdalabs/docs/User.md similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/docs/User.md rename to cloud/lambdalabs/gen/lambdalabs/docs/User.md diff --git a/internal/lambdalabs/gen/lambdalabs/git_push.sh b/cloud/lambdalabs/gen/lambdalabs/git_push.sh similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/git_push.sh rename to cloud/lambdalabs/gen/lambdalabs/git_push.sh diff --git a/internal/lambdalabs/gen/lambdalabs/model_add_ssh_key_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_add_ssh_key_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_add_ssh_key_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_add_ssh_key_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_add_ssh_key_request.go b/cloud/lambdalabs/gen/lambdalabs/model_add_ssh_key_request.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_add_ssh_key_request.go rename to cloud/lambdalabs/gen/lambdalabs/model_add_ssh_key_request.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_error.go b/cloud/lambdalabs/gen/lambdalabs/model_error.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_error.go rename to cloud/lambdalabs/gen/lambdalabs/model_error.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_error_code.go b/cloud/lambdalabs/gen/lambdalabs/model_error_code.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_error_code.go rename to cloud/lambdalabs/gen/lambdalabs/model_error_code.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_error_response_body.go b/cloud/lambdalabs/gen/lambdalabs/model_error_response_body.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_error_response_body.go rename to cloud/lambdalabs/gen/lambdalabs/model_error_response_body.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_file_system.go b/cloud/lambdalabs/gen/lambdalabs/model_file_system.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_file_system.go rename to cloud/lambdalabs/gen/lambdalabs/model_file_system.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_get_instance_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_get_instance_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_get_instance_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_get_instance_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_instance.go b/cloud/lambdalabs/gen/lambdalabs/model_instance.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_instance.go rename to cloud/lambdalabs/gen/lambdalabs/model_instance.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_instance_type.go b/cloud/lambdalabs/gen/lambdalabs/model_instance_type.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_instance_type.go rename to cloud/lambdalabs/gen/lambdalabs/model_instance_type.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_instance_type_specs.go b/cloud/lambdalabs/gen/lambdalabs/model_instance_type_specs.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_instance_type_specs.go rename to cloud/lambdalabs/gen/lambdalabs/model_instance_type_specs.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_instance_types_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_instance_types_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_instance_types_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_instance_types_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_instance_types_200_response_data_value.go b/cloud/lambdalabs/gen/lambdalabs/model_instance_types_200_response_data_value.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_instance_types_200_response_data_value.go rename to cloud/lambdalabs/gen/lambdalabs/model_instance_types_200_response_data_value.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_launch_instance_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_launch_instance_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_launch_instance_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_launch_instance_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_launch_instance_200_response_data.go b/cloud/lambdalabs/gen/lambdalabs/model_launch_instance_200_response_data.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_launch_instance_200_response_data.go rename to cloud/lambdalabs/gen/lambdalabs/model_launch_instance_200_response_data.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_launch_instance_request.go b/cloud/lambdalabs/gen/lambdalabs/model_launch_instance_request.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_launch_instance_request.go rename to cloud/lambdalabs/gen/lambdalabs/model_launch_instance_request.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_list_file_systems_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_list_file_systems_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_list_file_systems_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_list_file_systems_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_list_instances_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_list_instances_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_list_instances_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_list_instances_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_list_ssh_keys_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_list_ssh_keys_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_list_ssh_keys_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_list_ssh_keys_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_region.go b/cloud/lambdalabs/gen/lambdalabs/model_region.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_region.go rename to cloud/lambdalabs/gen/lambdalabs/model_region.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_restart_instance_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_restart_instance_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_restart_instance_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_restart_instance_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_restart_instance_200_response_data.go b/cloud/lambdalabs/gen/lambdalabs/model_restart_instance_200_response_data.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_restart_instance_200_response_data.go rename to cloud/lambdalabs/gen/lambdalabs/model_restart_instance_200_response_data.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_restart_instance_request.go b/cloud/lambdalabs/gen/lambdalabs/model_restart_instance_request.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_restart_instance_request.go rename to cloud/lambdalabs/gen/lambdalabs/model_restart_instance_request.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_ssh_key.go b/cloud/lambdalabs/gen/lambdalabs/model_ssh_key.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_ssh_key.go rename to cloud/lambdalabs/gen/lambdalabs/model_ssh_key.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response.go b/cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response.go rename to cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response_data.go b/cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response_data.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response_data.go rename to cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_200_response_data.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_terminate_instance_request.go b/cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_request.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_terminate_instance_request.go rename to cloud/lambdalabs/gen/lambdalabs/model_terminate_instance_request.go diff --git a/internal/lambdalabs/gen/lambdalabs/model_user.go b/cloud/lambdalabs/gen/lambdalabs/model_user.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/model_user.go rename to cloud/lambdalabs/gen/lambdalabs/model_user.go diff --git a/internal/lambdalabs/gen/lambdalabs/response.go b/cloud/lambdalabs/gen/lambdalabs/response.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/response.go rename to cloud/lambdalabs/gen/lambdalabs/response.go diff --git a/internal/lambdalabs/gen/lambdalabs/test/api_default_test.go b/cloud/lambdalabs/gen/lambdalabs/test/api_default_test.go similarity index 97% rename from internal/lambdalabs/gen/lambdalabs/test/api_default_test.go rename to cloud/lambdalabs/gen/lambdalabs/test/api_default_test.go index d5ee0014..b488dfb5 100644 --- a/internal/lambdalabs/gen/lambdalabs/test/api_default_test.go +++ b/cloud/lambdalabs/gen/lambdalabs/test/api_default_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" + openapiclient "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/lambdalabs/gen/lambdalabs/utils.go b/cloud/lambdalabs/gen/lambdalabs/utils.go similarity index 100% rename from internal/lambdalabs/gen/lambdalabs/utils.go rename to cloud/lambdalabs/gen/lambdalabs/utils.go diff --git a/internal/lambdalabs/v1/helpers_test.go b/cloud/lambdalabs/helpers_test.go similarity index 64% rename from internal/lambdalabs/v1/helpers_test.go rename to cloud/lambdalabs/helpers_test.go index cb7f01fb..67c5dd9a 100644 --- a/internal/lambdalabs/v1/helpers_test.go +++ b/cloud/lambdalabs/helpers_test.go @@ -1,11 +1,11 @@ -package v1 +package lambdalabs import ( "testing" "github.com/stretchr/testify/assert" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) func TestConvertLambdaLabsInstanceToV1Instance(t *testing.T) { @@ -15,7 +15,7 @@ func TestConvertLambdaLabsInstanceToV1Instance(t *testing.T) { assert.Equal(t, "test-instance-id", string(v1Instance.CloudID)) assert.Equal(t, "test-instance", v1Instance.Name) - assert.Equal(t, v1.LifecycleStatusRunning, v1Instance.Status.LifecycleStatus) + assert.Equal(t, cloud.LifecycleStatusRunning, v1Instance.Status.LifecycleStatus) assert.Equal(t, "192.168.1.100", v1Instance.PublicIP) assert.Equal(t, "10.0.1.100", v1Instance.PrivateIP) assert.Equal(t, "us-west-1", v1Instance.Location) @@ -25,14 +25,14 @@ func TestConvertLambdaLabsInstanceToV1Instance(t *testing.T) { func TestConvertLambdaLabsStatusToV1Status(t *testing.T) { tests := []struct { lambdaStatus string - expected v1.LifecycleStatus + expected cloud.LifecycleStatus }{ - {"active", v1.LifecycleStatusRunning}, - {"booting", v1.LifecycleStatusPending}, - {"unhealthy", v1.LifecycleStatusRunning}, - {"terminating", v1.LifecycleStatusTerminating}, - {"terminated", v1.LifecycleStatusTerminated}, - {"error", v1.LifecycleStatusFailed}, + {"active", cloud.LifecycleStatusRunning}, + {"booting", cloud.LifecycleStatusPending}, + {"unhealthy", cloud.LifecycleStatusRunning}, + {"terminating", cloud.LifecycleStatusTerminating}, + {"terminated", cloud.LifecycleStatusTerminated}, + {"error", cloud.LifecycleStatusFailed}, } for _, test := range tests { @@ -45,31 +45,31 @@ func TestConvertLambdaLabsStatusToV1Status(t *testing.T) { func TestMergeInstanceForUpdate(t *testing.T) { client := &LambdaLabsClient{} - original := v1.Instance{ + original := cloud.Instance{ CloudID: "test-id", Name: "original-name", - Status: v1.Status{LifecycleStatus: v1.LifecycleStatusRunning}, + Status: cloud.Status{LifecycleStatus: cloud.LifecycleStatusRunning}, } - update := v1.Instance{ + update := cloud.Instance{ Name: "updated-name", - Status: v1.Status{LifecycleStatus: v1.LifecycleStatusTerminated}, + Status: cloud.Status{LifecycleStatus: cloud.LifecycleStatusTerminated}, } merged := client.MergeInstanceForUpdate(original, update) assert.Equal(t, "updated-name", merged.Name) - assert.Equal(t, v1.LifecycleStatusTerminated, merged.Status.LifecycleStatus) + assert.Equal(t, cloud.LifecycleStatusTerminated, merged.Status.LifecycleStatus) } func TestMergeInstanceTypeForUpdate(t *testing.T) { client := &LambdaLabsClient{} - original := v1.InstanceType{ + original := cloud.InstanceType{ ID: "test-id", Type: "original-type", } - update := v1.InstanceType{ + update := cloud.InstanceType{ Type: "updated-type", } diff --git a/internal/lambdalabs/v1/instance.go b/cloud/lambdalabs/instance.go similarity index 83% rename from internal/lambdalabs/v1/instance.go rename to cloud/lambdalabs/instance.go index 412841b9..6390fd82 100644 --- a/internal/lambdalabs/v1/instance.go +++ b/cloud/lambdalabs/instance.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -8,16 +8,16 @@ import ( "time" "github.com/alecthomas/units" - "github.com/brevdev/cloud/internal/collections" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" + "github.com/brevdev/sdk/internal/collections" ) const lambdaLabsTimeNameFormat = "2006-01-02-15-04-05Z07-00" // CreateInstance creates a new instance in Lambda Labs // Supported via: POST /api/v1/instance-operations/launch -func (c *LambdaLabsClient) CreateInstance(ctx context.Context, attrs v1.CreateInstanceAttrs) (*v1.Instance, error) { +func (c *LambdaLabsClient) CreateInstance(ctx context.Context, attrs cloud.CreateInstanceAttrs) (*cloud.Instance, error) { keyPairName := attrs.RefID if attrs.KeyPairName != nil { keyPairName = *attrs.KeyPairName @@ -68,13 +68,13 @@ func (c *LambdaLabsClient) CreateInstance(ctx context.Context, attrs v1.CreateIn return nil, fmt.Errorf("expected 1 instance ID, got %d", len(resp.Data.InstanceIds)) } - instanceID := v1.CloudProviderInstanceID(resp.Data.InstanceIds[0]) + instanceID := cloud.CloudProviderInstanceID(resp.Data.InstanceIds[0]) return c.GetInstance(ctx, instanceID) } // GetInstance retrieves an instance by ID // Supported via: GET /api/v1/instances/{id} -func (c *LambdaLabsClient) GetInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) (*v1.Instance, error) { +func (c *LambdaLabsClient) GetInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) (*cloud.Instance, error) { resp, err := c.getInstance(ctx, string(instanceID)) if err != nil { return nil, fmt.Errorf("failed to get instance: %w", err) @@ -85,7 +85,7 @@ func (c *LambdaLabsClient) GetInstance(ctx context.Context, instanceID v1.CloudP // TerminateInstance terminates an instance // Supported via: POST /api/v1/instance-operations/terminate -func (c *LambdaLabsClient) TerminateInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error { +func (c *LambdaLabsClient) TerminateInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) error { request := openapi.TerminateInstanceRequest{ InstanceIds: []string{string(instanceID)}, } @@ -100,13 +100,13 @@ func (c *LambdaLabsClient) TerminateInstance(ctx context.Context, instanceID v1. // ListInstances lists all instances // Supported via: GET /api/v1/instances -func (c *LambdaLabsClient) ListInstances(ctx context.Context, _ v1.ListInstancesArgs) ([]v1.Instance, error) { +func (c *LambdaLabsClient) ListInstances(ctx context.Context, _ cloud.ListInstancesArgs) ([]cloud.Instance, error) { resp, err := c.listInstances(ctx) if err != nil { return nil, fmt.Errorf("failed to list instances: %w", err) } - instances := make([]v1.Instance, 0, len(resp.Data)) + instances := make([]cloud.Instance, 0, len(resp.Data)) for _, llInstance := range resp.Data { instance := convertLambdaLabsInstanceToV1Instance(llInstance) instances = append(instances, *instance) @@ -117,7 +117,7 @@ func (c *LambdaLabsClient) ListInstances(ctx context.Context, _ v1.ListInstances // RebootInstance reboots an instance // Supported via: POST /api/v1/instance-operations/restart -func (c *LambdaLabsClient) RebootInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error { +func (c *LambdaLabsClient) RebootInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) error { request := openapi.RestartInstanceRequest{ InstanceIds: []string{string(instanceID)}, } @@ -131,7 +131,7 @@ func (c *LambdaLabsClient) RebootInstance(ctx context.Context, instanceID v1.Clo } // MergeInstanceForUpdate merges instance data for updates -func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instance { +func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *cloud.Instance { var instanceIP string if instance.Ip.IsSet() { instanceIP = *instance.Ip.Get() @@ -163,25 +163,25 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan instancePrivateIP = *instance.PrivateIp.Get() } - inst := v1.Instance{ + inst := cloud.Instance{ RefID: instance.SshKeyNames[0], CloudCredRefID: cloudCredRefID, CreatedAt: createTime, - CloudID: v1.CloudProviderInstanceID(instance.Id), + CloudID: cloud.CloudProviderInstanceID(instance.Id), Name: instanceName, PublicIP: instanceIP, PublicDNS: instanceIP, PrivateIP: instancePrivateIP, Hostname: instanceHostname, - Status: v1.Status{ + Status: cloud.Status{ LifecycleStatus: convertLambdaLabsStatusToV1Status(instance.Status), }, InstanceType: instance.InstanceType.Name, VolumeType: "ssd", DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), - FirewallRules: v1.FirewallRules{ - IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api - EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api + FirewallRules: cloud.FirewallRules{ + IngressRules: []cloud.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api + EgressRules: []cloud.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api }, SSHUser: "ubuntu", SSHPort: 22, @@ -189,42 +189,42 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan Rebootable: true, Location: instance.Region.Name, } - inst.InstanceTypeID = v1.MakeGenericInstanceTypeIDFromInstance(inst) + inst.InstanceTypeID = cloud.MakeGenericInstanceTypeIDFromInstance(inst) return &inst } -func generateFirewallRouteFromPort(port int32) v1.FirewallRule { - return v1.FirewallRule{ +func generateFirewallRouteFromPort(port int32) cloud.FirewallRule { + return cloud.FirewallRule{ FromPort: port, ToPort: port, IPRanges: []string{"0.0.0.0/0"}, } } -func convertLambdaLabsStatusToV1Status(status string) v1.LifecycleStatus { +func convertLambdaLabsStatusToV1Status(status string) cloud.LifecycleStatus { switch status { case "booting": - return v1.LifecycleStatusPending + return cloud.LifecycleStatusPending case "active": - return v1.LifecycleStatusRunning + return cloud.LifecycleStatusRunning case "terminating": - return v1.LifecycleStatusTerminating + return cloud.LifecycleStatusTerminating case "terminated": - return v1.LifecycleStatusTerminated + return cloud.LifecycleStatusTerminated case "error": - return v1.LifecycleStatusFailed + return cloud.LifecycleStatusFailed case "unhealthy": - return v1.LifecycleStatusRunning + return cloud.LifecycleStatusRunning default: - return v1.LifecycleStatusPending + return cloud.LifecycleStatusPending } } -func (c *LambdaLabsClient) MergeInstanceForUpdate(_ v1.Instance, newInst v1.Instance) v1.Instance { +func (c *LambdaLabsClient) MergeInstanceForUpdate(_ cloud.Instance, newInst cloud.Instance) cloud.Instance { return newInst } -func (c *LambdaLabsClient) MergeInstanceTypeForUpdate(_ v1.InstanceType, newIt v1.InstanceType) v1.InstanceType { +func (c *LambdaLabsClient) MergeInstanceTypeForUpdate(_ cloud.InstanceType, newIt cloud.InstanceType) cloud.InstanceType { return newIt } diff --git a/internal/lambdalabs/v1/instance_test.go b/cloud/lambdalabs/instance_test.go similarity index 86% rename from internal/lambdalabs/v1/instance_test.go rename to cloud/lambdalabs/instance_test.go index 87d388ba..cb8f240e 100644 --- a/internal/lambdalabs/v1/instance_test.go +++ b/cloud/lambdalabs/instance_test.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -9,9 +9,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/brevdev/cloud/internal/collections" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" + "github.com/brevdev/sdk/internal/collections" ) func TestLambdaLabsClient_CreateInstance_Success(t *testing.T) { @@ -43,7 +43,7 @@ func TestLambdaLabsClient_CreateInstance_Success(t *testing.T) { Data: mockInstance, })) - args := v1.CreateInstanceAttrs{ + args := cloud.CreateInstanceAttrs{ InstanceType: "gpu_1x_a10", Location: "us-west-1", PublicKey: publicKey, @@ -54,7 +54,7 @@ func TestLambdaLabsClient_CreateInstance_Success(t *testing.T) { require.NoError(t, err) assert.Equal(t, instanceID, string(instance.CloudID)) assert.Contains(t, instance.Name, "test-instance") - assert.Equal(t, v1.LifecycleStatusRunning, instance.Status.LifecycleStatus) + assert.Equal(t, cloud.LifecycleStatusRunning, instance.Status.LifecycleStatus) } func TestLambdaLabsClient_CreateInstance_WithoutPublicKey(t *testing.T) { @@ -76,7 +76,7 @@ func TestLambdaLabsClient_CreateInstance_WithoutPublicKey(t *testing.T) { Data: mockInstance, })) - args := v1.CreateInstanceAttrs{ + args := cloud.CreateInstanceAttrs{ InstanceType: "gpu_1x_a10", Location: "us-west-1", Name: "test-instance", @@ -97,7 +97,7 @@ func TestLambdaLabsClient_CreateInstance_SSHKeyError(t *testing.T) { httpmock.RegisterResponder("POST", "https://cloud.lambda.ai/api/v1/ssh-keys", httpmock.NewStringResponder(400, `{"error": {"code": "INVALID_REQUEST", "message": "SSH key already exists"}}`)) - args := v1.CreateInstanceAttrs{ + args := cloud.CreateInstanceAttrs{ InstanceType: "gpu_1x_a10", Location: "us-west-1", PublicKey: publicKey, @@ -115,7 +115,7 @@ func TestLambdaLabsClient_CreateInstance_LaunchError(t *testing.T) { httpmock.RegisterResponder("POST", "https://cloud.lambda.ai/api/v1/instance-operations/launch", httpmock.NewStringResponder(400, `{"error": {"code": "INVALID_REQUEST", "message": "Instance type not available"}}`)) - args := v1.CreateInstanceAttrs{ + args := cloud.CreateInstanceAttrs{ InstanceType: "gpu_1x_a10", Location: "us-west-1", Name: "test-instance", @@ -137,11 +137,11 @@ func TestLambdaLabsClient_GetInstance_Success(t *testing.T) { Data: mockInstance, })) - instance, err := client.GetInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + instance, err := client.GetInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) require.NoError(t, err) assert.Equal(t, instanceID, string(instance.CloudID)) assert.Equal(t, "test-instance", instance.Name) - assert.Equal(t, v1.LifecycleStatusRunning, instance.Status.LifecycleStatus) + assert.Equal(t, cloud.LifecycleStatusRunning, instance.Status.LifecycleStatus) } func TestLambdaLabsClient_GetInstance_NotFound(t *testing.T) { @@ -153,7 +153,7 @@ func TestLambdaLabsClient_GetInstance_NotFound(t *testing.T) { httpmock.RegisterResponder("GET", fmt.Sprintf("https://cloud.lambda.ai/api/v1/instances/%s", instanceID), httpmock.NewStringResponder(404, `{"error": {"code": "NOT_FOUND", "message": "Instance not found"}}`)) - _, err := client.GetInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + _, err := client.GetInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) assert.Error(t, err) } @@ -171,7 +171,7 @@ func TestLambdaLabsClient_ListInstances_Success(t *testing.T) { Data: mockInstances, })) - instances, err := client.ListInstances(context.Background(), v1.ListInstancesArgs{}) + instances, err := client.ListInstances(context.Background(), cloud.ListInstancesArgs{}) require.NoError(t, err) assert.Len(t, instances, 2) assert.Equal(t, "instance-1", string(instances[0].CloudID)) @@ -187,7 +187,7 @@ func TestLambdaLabsClient_ListInstances_Empty(t *testing.T) { Data: []openapi.Instance{}, })) - instances, err := client.ListInstances(context.Background(), v1.ListInstancesArgs{}) + instances, err := client.ListInstances(context.Background(), cloud.ListInstancesArgs{}) require.NoError(t, err) assert.Len(t, instances, 0) } @@ -199,7 +199,7 @@ func TestLambdaLabsClient_ListInstances_Error(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instances", httpmock.NewStringResponder(500, `{"error": {"code": "INTERNAL_ERROR", "message": "Internal server error"}}`)) - _, err := client.ListInstances(context.Background(), v1.ListInstancesArgs{}) + _, err := client.ListInstances(context.Background(), cloud.ListInstancesArgs{}) assert.Error(t, err) } @@ -218,7 +218,7 @@ func TestLambdaLabsClient_TerminateInstance_Success(t *testing.T) { }, })) - err := client.TerminateInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + err := client.TerminateInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) assert.NoError(t, err) } @@ -231,7 +231,7 @@ func TestLambdaLabsClient_TerminateInstance_Error(t *testing.T) { httpmock.RegisterResponder("POST", "https://cloud.lambda.ai/api/v1/instance-operations/terminate", httpmock.NewStringResponder(404, `{"error": {"code": "NOT_FOUND", "message": "Instance not found"}}`)) - err := client.TerminateInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + err := client.TerminateInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) assert.Error(t, err) } @@ -250,7 +250,7 @@ func TestLambdaLabsClient_RebootInstance_Success(t *testing.T) { }, })) - err := client.RebootInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + err := client.RebootInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) assert.NoError(t, err) } @@ -263,6 +263,6 @@ func TestLambdaLabsClient_RebootInstance_Error(t *testing.T) { httpmock.RegisterResponder("POST", "https://cloud.lambda.ai/api/v1/instance-operations/restart", httpmock.NewStringResponder(404, `{"error": {"code": "NOT_FOUND", "message": "Instance not found"}}`)) - err := client.RebootInstance(context.Background(), v1.CloudProviderInstanceID(instanceID)) + err := client.RebootInstance(context.Background(), cloud.CloudProviderInstanceID(instanceID)) assert.Error(t, err) } diff --git a/internal/lambdalabs/v1/instancetype.go b/cloud/lambdalabs/instancetype.go similarity index 79% rename from internal/lambdalabs/v1/instancetype.go rename to cloud/lambdalabs/instancetype.go index 219f5b19..ba2c296f 100644 --- a/internal/lambdalabs/v1/instancetype.go +++ b/cloud/lambdalabs/instancetype.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -10,9 +10,9 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - "github.com/brevdev/cloud/internal/collections" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" + "github.com/brevdev/sdk/internal/collections" ) // GetInstanceTypePollTime returns the polling interval for instance types @@ -20,34 +20,34 @@ func (c *LambdaLabsClient) GetInstanceTypePollTime() time.Duration { return 5 * time.Minute } -func (c *LambdaLabsClient) GetInstanceTypes(ctx context.Context, args v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) { +func (c *LambdaLabsClient) GetInstanceTypes(ctx context.Context, args cloud.GetInstanceTypeArgs) ([]cloud.InstanceType, error) { instanceTypesResp, err := c.getInstanceTypes(ctx) if err != nil { return nil, err } - locations, err := c.GetLocations(ctx, v1.GetLocationsArgs{}) + locations, err := c.GetLocations(ctx, cloud.GetLocationsArgs{}) if err != nil { return nil, err } - instanceTypes, err := collections.MapE(collections.GetMapValues(instanceTypesResp.Data), func(resp openapi.InstanceTypes200ResponseDataValue) ([]v1.InstanceType, error) { + instanceTypes, err := collections.MapE(collections.GetMapValues(instanceTypesResp.Data), func(resp openapi.InstanceTypes200ResponseDataValue) ([]cloud.InstanceType, error) { currentlyAvailableRegions := collections.GroupBy(resp.RegionsWithCapacityAvailable, func(lambdaRegion openapi.Region) string { return lambdaRegion.Name }) - its, err1 := collections.MapE(locations, func(region v1.Location) (v1.InstanceType, error) { + its, err1 := collections.MapE(locations, func(region cloud.Location) (cloud.InstanceType, error) { isAvailable := false if _, ok := currentlyAvailableRegions[region.Name]; ok { isAvailable = true } it, err2 := convertLambdaLabsInstanceTypeToV1InstanceType(region.Name, resp.InstanceType, isAvailable) if err2 != nil { - return v1.InstanceType{}, err2 + return cloud.InstanceType{}, err2 } return it, nil }) if err1 != nil { - return []v1.InstanceType{}, err1 + return []cloud.InstanceType{}, err1 } return its, nil }) @@ -60,18 +60,18 @@ func (c *LambdaLabsClient) GetInstanceTypes(ctx context.Context, args v1.GetInst if c.location != "" { args.Locations = []string{c.location} } else { - args.Locations = v1.All + args.Locations = cloud.All } } if !args.Locations.IsAll() { - instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(it v1.InstanceType) bool { + instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(it cloud.InstanceType) bool { return collections.ListContains(args.Locations, it.Location) }) } if len(args.SupportedArchitectures) > 0 { - instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(instanceType v1.InstanceType) bool { + instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(instanceType cloud.InstanceType) bool { for _, arch := range args.SupportedArchitectures { if collections.ListContains(instanceType.SupportedArchitectures, arch) { return true @@ -81,7 +81,7 @@ func (c *LambdaLabsClient) GetInstanceTypes(ctx context.Context, args v1.GetInst }) } if len(args.InstanceTypes) > 0 { - instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(instanceType v1.InstanceType) bool { + instanceTypesFlattened = collections.Filter(instanceTypesFlattened, func(instanceType cloud.InstanceType) bool { return collections.ListContains(args.InstanceTypes, instanceType.Type) }) } @@ -107,14 +107,14 @@ func (c *LambdaLabsClient) getInstanceTypes(ctx context.Context) (*openapi.Insta return ilr, nil } -func parseGPUFromDescription(input string) (v1.GPU, error) { - var gpu v1.GPU +func parseGPUFromDescription(input string) (cloud.GPU, error) { + var gpu cloud.GPU // Extract the count countRegex := regexp.MustCompile(`(\d+)x`) countMatch := countRegex.FindStringSubmatch(input) if len(countMatch) == 0 { - return v1.GPU{}, fmt.Errorf("could not find count in %s", input) + return cloud.GPU{}, fmt.Errorf("could not find count in %s", input) } count, _ := strconv.ParseInt(countMatch[1], 10, 32) gpu.Count = int32(count) @@ -123,7 +123,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { memoryRegex := regexp.MustCompile(`(\d+) GB`) memoryMatch := memoryRegex.FindStringSubmatch(input) if len(memoryMatch) == 0 { - return v1.GPU{}, fmt.Errorf("could not find memory in %s", input) + return cloud.GPU{}, fmt.Errorf("could not find memory in %s", input) } memoryStr := memoryMatch[1] memoryGiB, _ := strconv.Atoi(memoryStr) @@ -133,7 +133,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { networkRegex := regexp.MustCompile(`(\w+\s?)+\)`) networkMatch := networkRegex.FindStringSubmatch(input) if len(networkMatch) == 0 { - return v1.GPU{}, fmt.Errorf("could not find network details in %s", input) + return cloud.GPU{}, fmt.Errorf("could not find network details in %s", input) } networkStr := strings.TrimSuffix(networkMatch[0], ")") networkDetails := strings.TrimSpace(strings.ReplaceAll(networkStr, memoryStr+" GB", "")) @@ -143,7 +143,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { nameRegex := regexp.MustCompile(`x (.*?) \(`) nameMatch := nameRegex.FindStringSubmatch(input) if len(nameMatch) == 0 { - return v1.GPU{}, fmt.Errorf("could not find name in %s", input) + return cloud.GPU{}, fmt.Errorf("could not find name in %s", input) } nameStr := strings.TrimRight(strings.TrimLeft(nameMatch[0], "x "), " (") nameStr = regexp.MustCompile(`(?i)^Tesla\s+`).ReplaceAllString(nameStr, "") @@ -159,24 +159,24 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { return gpu, nil } -func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType openapi.InstanceType, isAvailable bool) (v1.InstanceType, error) { - gpus := []v1.GPU{} +func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType openapi.InstanceType, isAvailable bool) (cloud.InstanceType, error) { + gpus := []cloud.GPU{} if !strings.Contains(instType.Description, "CPU") { gpu, err := parseGPUFromDescription(instType.Description) if err != nil { - return v1.InstanceType{}, err + return cloud.InstanceType{}, err } gpus = append(gpus, gpu) } amount, err := currency.NewAmountFromInt64(int64(instType.PriceCentsPerHour), "USD") if err != nil { - return v1.InstanceType{}, err + return cloud.InstanceType{}, err } - it := v1.InstanceType{ + it := cloud.InstanceType{ Location: location, Type: instType.Name, SupportedGPUs: gpus, - SupportedStorage: []v1.Storage{ + SupportedStorage: []cloud.Storage{ { Type: "ssd", Count: 1, @@ -198,6 +198,6 @@ func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType ope BasePrice: &amount, Provider: string(CloudProviderID), } - it.ID = v1.MakeGenericInstanceTypeID(it) + it.ID = cloud.MakeGenericInstanceTypeID(it) return it, nil } diff --git a/internal/lambdalabs/v1/instancetype_test.go b/cloud/lambdalabs/instancetype_test.go similarity index 92% rename from internal/lambdalabs/v1/instancetype_test.go rename to cloud/lambdalabs/instancetype_test.go index 483eb07a..608dcb2b 100644 --- a/internal/lambdalabs/v1/instancetype_test.go +++ b/cloud/lambdalabs/instancetype_test.go @@ -1,4 +1,4 @@ -package v1 +package lambdalabs import ( "context" @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - openapi "github.com/brevdev/cloud/internal/lambdalabs/gen/lambdalabs" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/lambdalabs/gen/lambdalabs" ) func TestLambdaLabsClient_GetInstanceTypes_Success(t *testing.T) { @@ -22,7 +22,7 @@ func TestLambdaLabsClient_GetInstanceTypes_Success(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewJsonResponderOrPanic(200, mockResponse)) - instanceTypes, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{}) + instanceTypes, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{}) require.NoError(t, err) locations, err := getLambdaLabsLocations() require.NoError(t, err) @@ -46,8 +46,8 @@ func TestLambdaLabsClient_GetInstanceTypes_FilterByLocation(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewJsonResponderOrPanic(200, mockResponse)) - instanceTypes, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{ - Locations: v1.LocationsFilter{"us-west-1"}, + instanceTypes, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{ + Locations: cloud.LocationsFilter{"us-west-1"}, }) require.NoError(t, err) assert.Len(t, instanceTypes, 2) @@ -65,7 +65,7 @@ func TestLambdaLabsClient_GetInstanceTypes_FilterByInstanceType(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewJsonResponderOrPanic(200, mockResponse)) - instanceTypes, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{ + instanceTypes, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{ InstanceTypes: []string{"gpu_1x_a10"}, }) require.NoError(t, err) @@ -86,8 +86,8 @@ func TestLambdaLabsClient_GetInstanceTypes_FilterBoth(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewJsonResponderOrPanic(200, mockResponse)) - instanceTypes, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{ - Locations: v1.LocationsFilter{"us-east-1"}, + instanceTypes, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{ + Locations: cloud.LocationsFilter{"us-east-1"}, InstanceTypes: []string{"gpu_8x_h100"}, }) require.NoError(t, err) @@ -106,7 +106,7 @@ func TestLambdaLabsClient_GetInstanceTypes_Empty(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewJsonResponderOrPanic(200, emptyResponse)) - instanceTypes, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{}) + instanceTypes, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{}) require.NoError(t, err) assert.Len(t, instanceTypes, 0) } @@ -118,7 +118,7 @@ func TestLambdaLabsClient_GetInstanceTypes_Error(t *testing.T) { httpmock.RegisterResponder("GET", "https://cloud.lambda.ai/api/v1/instance-types", httpmock.NewStringResponder(500, `{"error": {"code": "INTERNAL_ERROR", "message": "Internal server error"}}`)) - _, err := client.GetInstanceTypes(context.Background(), v1.GetInstanceTypeArgs{}) + _, err := client.GetInstanceTypes(context.Background(), cloud.GetInstanceTypeArgs{}) assert.Error(t, err) } @@ -166,11 +166,11 @@ func TestConvertLambdaLabsInstanceTypeToV1InstanceType_CPUOnly(t *testing.T) { func TestParseGPUFromDescription(t *testing.T) { tests := []struct { description string - expected v1.GPU + expected cloud.GPU }{ { description: "1x H100 (80 GB SXM5)", - expected: v1.GPU{ + expected: cloud.GPU{ Count: 1, Manufacturer: "NVIDIA", Name: "H100", @@ -182,7 +182,7 @@ func TestParseGPUFromDescription(t *testing.T) { }, { description: "8x Tesla V100 (16 GB)", - expected: v1.GPU{ + expected: cloud.GPU{ Count: 8, Manufacturer: "NVIDIA", Name: "V100", @@ -256,7 +256,7 @@ func createMockRegion(name, description string) openapi.Region { } } -func findInstanceTypeByName(instanceTypes []v1.InstanceType, name string) *v1.InstanceType { +func findInstanceTypeByName(instanceTypes []cloud.InstanceType, name string) *cloud.InstanceType { for _, instanceType := range instanceTypes { if instanceType.Type == name { return &instanceType diff --git a/internal/lambdalabs/v1/location.go b/cloud/lambdalabs/location.go similarity index 89% rename from internal/lambdalabs/v1/location.go rename to cloud/lambdalabs/location.go index 22834074..dee220dd 100644 --- a/internal/lambdalabs/v1/location.go +++ b/cloud/lambdalabs/location.go @@ -1,11 +1,11 @@ -package v1 +package lambdalabs import ( "context" "encoding/json" "fmt" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) const lambdaLocationsData = `[ @@ -43,15 +43,15 @@ func getLambdaLabsLocations() ([]LambdaLocation, error) { return locationData, nil } -func (c *LambdaLabsClient) GetLocations(_ context.Context, _ v1.GetLocationsArgs) ([]v1.Location, error) { +func (c *LambdaLabsClient) GetLocations(_ context.Context, _ cloud.GetLocationsArgs) ([]cloud.Location, error) { locationData, err := getLambdaLabsLocations() if err != nil { return nil, err } - locations := make([]v1.Location, 0, len(locationData)) + locations := make([]cloud.Location, 0, len(locationData)) for _, location := range locationData { - locations = append(locations, v1.Location{ + locations = append(locations, cloud.Location{ Name: location.LocationName, Description: location.Description, Available: true, diff --git a/cloud/lambdalabs/location_test.go b/cloud/lambdalabs/location_test.go new file mode 100644 index 00000000..7e9f25c7 --- /dev/null +++ b/cloud/lambdalabs/location_test.go @@ -0,0 +1 @@ +package lambdalabs diff --git a/internal/lambdalabs/v1/validation_test.go b/cloud/lambdalabs/validation_test.go similarity index 81% rename from internal/lambdalabs/v1/validation_test.go rename to cloud/lambdalabs/validation_test.go index 54b8b5ba..096e1f44 100644 --- a/internal/lambdalabs/v1/validation_test.go +++ b/cloud/lambdalabs/validation_test.go @@ -1,11 +1,11 @@ -package v1 +package lambdalabs import ( "os" "testing" - "github.com/brevdev/cloud/internal/validation" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + "github.com/brevdev/sdk/internal/validation" ) func TestValidationFunctions(t *testing.T) { @@ -14,7 +14,7 @@ func TestValidationFunctions(t *testing.T) { config := validation.ProviderConfig{ Credential: NewLambdaLabsCredential("validation-test", apiKey), - StableIDs: []v1.InstanceTypeID{"us-west-1-noSub-gpu_8x_a100_80gb_sxm4", "us-east-1-noSub-gpu_8x_a100_80gb_sxm4"}, + StableIDs: []cloud.InstanceTypeID{"us-west-1-noSub-gpu_8x_a100_80gb_sxm4", "us-east-1-noSub-gpu_8x_a100_80gb_sxm4"}, } validation.RunValidationSuite(t, config) diff --git a/pkg/v1/location.go b/cloud/location.go similarity index 98% rename from pkg/v1/location.go rename to cloud/location.go index 5518595e..dfbd8700 100644 --- a/pkg/v1/location.go +++ b/cloud/location.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/internal/nebius/CONTRIBUTE.md b/cloud/nebius/CONTRIBUTE.md similarity index 100% rename from internal/nebius/CONTRIBUTE.md rename to cloud/nebius/CONTRIBUTE.md diff --git a/internal/nebius/v1/README.md b/cloud/nebius/README.md similarity index 100% rename from internal/nebius/v1/README.md rename to cloud/nebius/README.md diff --git a/internal/nebius/SECURITY.md b/cloud/nebius/SECURITY.md similarity index 100% rename from internal/nebius/SECURITY.md rename to cloud/nebius/SECURITY.md diff --git a/cloud/nebius/capabilities.go b/cloud/nebius/capabilities.go new file mode 100644 index 00000000..981484de --- /dev/null +++ b/cloud/nebius/capabilities.go @@ -0,0 +1,37 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func getNebiusCapabilities() cloud.Capabilities { + return cloud.Capabilities{ + // SUPPORTED FEATURES (with API evidence): + + // Instance Management + cloud.CapabilityCreateInstance, // Nebius compute API supports instance creation + cloud.CapabilityTerminateInstance, // Nebius compute API supports instance deletion + cloud.CapabilityCreateTerminateInstance, // Combined create/terminate capability + cloud.CapabilityRebootInstance, // Nebius supports instance restart operations + cloud.CapabilityStopStartInstance, // Nebius supports instance stop/start operations + + cloud.CapabilityModifyFirewall, // Nebius has Security Groups for firewall management + cloud.CapabilityMachineImage, // Nebius supports custom machine images + cloud.CapabilityResizeInstanceVolume, // Nebius supports disk resizing + cloud.CapabilityTags, // Nebius supports resource tagging + cloud.CapabilityInstanceUserData, // Nebius supports user data in instance creation + + } +} + +// GetCapabilities returns the capabilities of Nebius client +func (c *NebiusClient) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + return getNebiusCapabilities(), nil +} + +// GetCapabilities returns the capabilities for Nebius credential +func (c *NebiusCredential) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + return getNebiusCapabilities(), nil +} diff --git a/internal/nebius/v1/client.go b/cloud/nebius/client.go similarity index 80% rename from internal/nebius/v1/client.go rename to cloud/nebius/client.go index 25d6d203..a23305bb 100644 --- a/internal/nebius/v1/client.go +++ b/cloud/nebius/client.go @@ -1,10 +1,10 @@ -package v1 +package nebius import ( "context" "fmt" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" "github.com/nebius/gosdk" ) @@ -14,7 +14,7 @@ type NebiusCredential struct { ProjectID string } -var _ v1.CloudCredential = &NebiusCredential{} +var _ cloud.CloudCredential = &NebiusCredential{} func NewNebiusCredential(refID, serviceAccountKey, projectID string) *NebiusCredential { return &NebiusCredential{ @@ -30,12 +30,12 @@ func (c *NebiusCredential) GetReferenceID() string { } // GetAPIType returns the API type for Nebius -func (c *NebiusCredential) GetAPIType() v1.APIType { - return v1.APITypeLocational // Nebius uses location-specific endpoints +func (c *NebiusCredential) GetAPIType() cloud.APIType { + return cloud.APITypeLocational // Nebius uses location-specific endpoints } // GetCloudProviderID returns the cloud provider ID for Nebius -func (c *NebiusCredential) GetCloudProviderID() v1.CloudProviderID { +func (c *NebiusCredential) GetCloudProviderID() cloud.CloudProviderID { return "nebius" } @@ -47,13 +47,13 @@ func (c *NebiusCredential) GetTenantID() (string, error) { return c.ProjectID, nil } -func (c *NebiusCredential) MakeClient(ctx context.Context, location string) (v1.CloudClient, error) { +func (c *NebiusCredential) MakeClient(ctx context.Context, location string) (cloud.CloudClient, error) { return NewNebiusClient(ctx, c.RefID, c.ServiceAccountKey, c.ProjectID, location) } // It embeds NotImplCloudClient to handle unsupported features type NebiusClient struct { - v1.NotImplCloudClient + cloud.NotImplCloudClient refID string serviceAccountKey string projectID string @@ -61,7 +61,7 @@ type NebiusClient struct { sdk *gosdk.SDK } -var _ v1.CloudClient = &NebiusClient{} +var _ cloud.CloudClient = &NebiusClient{} func NewNebiusClient(ctx context.Context, refID, serviceAccountKey, projectID, location string) (*NebiusClient, error) { sdk, err := gosdk.New(ctx, gosdk.WithCredentials( @@ -81,17 +81,17 @@ func NewNebiusClient(ctx context.Context, refID, serviceAccountKey, projectID, l } // GetAPIType returns the API type for Nebius -func (c *NebiusClient) GetAPIType() v1.APIType { - return v1.APITypeLocational +func (c *NebiusClient) GetAPIType() cloud.APIType { + return cloud.APITypeLocational } // GetCloudProviderID returns the cloud provider ID for Nebius -func (c *NebiusClient) GetCloudProviderID() v1.CloudProviderID { +func (c *NebiusClient) GetCloudProviderID() cloud.CloudProviderID { return "nebius" } // MakeClient creates a new client instance for a different location -func (c *NebiusClient) MakeClient(ctx context.Context, location string) (v1.CloudClient, error) { +func (c *NebiusClient) MakeClient(ctx context.Context, location string) (cloud.CloudClient, error) { return NewNebiusClient(ctx, c.refID, c.serviceAccountKey, c.projectID, location) } diff --git a/cloud/nebius/image.go b/cloud/nebius/image.go new file mode 100644 index 00000000..01ebba7e --- /dev/null +++ b/cloud/nebius/image.go @@ -0,0 +1,11 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) GetImages(_ context.Context, _ cloud.GetImageArgs) ([]cloud.Image, error) { + return nil, cloud.ErrNotImplemented +} diff --git a/cloud/nebius/instance.go b/cloud/nebius/instance.go new file mode 100644 index 00000000..0330f8f3 --- /dev/null +++ b/cloud/nebius/instance.go @@ -0,0 +1,49 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) CreateInstance(_ context.Context, _ cloud.CreateInstanceAttrs) (*cloud.Instance, error) { + return nil, cloud.ErrNotImplemented +} + +func (c *NebiusClient) GetInstance(_ context.Context, _ cloud.CloudProviderInstanceID) (*cloud.Instance, error) { + return nil, cloud.ErrNotImplemented +} + +func (c *NebiusClient) TerminateInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented +} + +func (c *NebiusClient) ListInstances(_ context.Context, _ cloud.ListInstancesArgs) ([]cloud.Instance, error) { + return nil, cloud.ErrNotImplemented +} + +func (c *NebiusClient) StopInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented +} + +func (c *NebiusClient) StartInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented +} + +func (c *NebiusClient) RebootInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented +} + +func (c *NebiusClient) MergeInstanceForUpdate(currInst cloud.Instance, newInst cloud.Instance) cloud.Instance { + merged := newInst + + merged.Name = currInst.Name + merged.RefID = currInst.RefID + merged.CloudCredRefID = currInst.CloudCredRefID + merged.CreatedAt = currInst.CreatedAt + merged.CloudID = currInst.CloudID + merged.Location = currInst.Location + merged.SubLocation = currInst.SubLocation + + return merged +} diff --git a/cloud/nebius/instancetype.go b/cloud/nebius/instancetype.go new file mode 100644 index 00000000..aec32887 --- /dev/null +++ b/cloud/nebius/instancetype.go @@ -0,0 +1,24 @@ +package nebius + +import ( + "context" + "time" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) GetInstanceTypes(_ context.Context, _ cloud.GetInstanceTypeArgs) ([]cloud.InstanceType, error) { + return nil, cloud.ErrNotImplemented +} + +func (c *NebiusClient) GetInstanceTypePollTime() time.Duration { + return 5 * time.Minute +} + +func (c *NebiusClient) MergeInstanceTypeForUpdate(currIt cloud.InstanceType, newIt cloud.InstanceType) cloud.InstanceType { + merged := newIt + + merged.ID = currIt.ID + + return merged +} diff --git a/cloud/nebius/location.go b/cloud/nebius/location.go new file mode 100644 index 00000000..71203e11 --- /dev/null +++ b/cloud/nebius/location.go @@ -0,0 +1,11 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) GetLocations(_ context.Context, _ cloud.GetLocationsArgs) ([]cloud.Location, error) { + return nil, cloud.ErrNotImplemented +} diff --git a/cloud/nebius/networking.go b/cloud/nebius/networking.go new file mode 100644 index 00000000..3dcf4d7d --- /dev/null +++ b/cloud/nebius/networking.go @@ -0,0 +1,15 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) AddFirewallRulesToInstance(_ context.Context, _ cloud.AddFirewallRulesToInstanceArgs) error { + return cloud.ErrNotImplemented +} + +func (c *NebiusClient) RevokeSecurityGroupRules(_ context.Context, _ cloud.RevokeSecurityGroupRuleArgs) error { + return cloud.ErrNotImplemented +} diff --git a/cloud/nebius/quota.go b/cloud/nebius/quota.go new file mode 100644 index 00000000..dd637a9f --- /dev/null +++ b/cloud/nebius/quota.go @@ -0,0 +1,11 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) GetInstanceTypeQuotas(_ context.Context, _ cloud.GetInstanceTypeQuotasArgs) (cloud.Quota, error) { + return cloud.Quota{}, cloud.ErrNotImplemented +} diff --git a/cloud/nebius/storage.go b/cloud/nebius/storage.go new file mode 100644 index 00000000..fa5eb4ed --- /dev/null +++ b/cloud/nebius/storage.go @@ -0,0 +1,11 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) ResizeInstanceVolume(_ context.Context, _ cloud.ResizeInstanceVolumeArgs) error { + return cloud.ErrNotImplemented +} diff --git a/cloud/nebius/tags.go b/cloud/nebius/tags.go new file mode 100644 index 00000000..d1081531 --- /dev/null +++ b/cloud/nebius/tags.go @@ -0,0 +1,11 @@ +package nebius + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *NebiusClient) UpdateInstanceTags(_ context.Context, _ cloud.UpdateInstanceTagsArgs) error { + return cloud.ErrNotImplemented +} diff --git a/pkg/v1/networking.go b/cloud/networking.go similarity index 98% rename from pkg/v1/networking.go rename to cloud/networking.go index 5b03e1e4..9f2503d9 100644 --- a/pkg/v1/networking.go +++ b/cloud/networking.go @@ -1,4 +1,4 @@ -package v1 +package cloud import "context" diff --git a/pkg/v1/notimplemented.go b/cloud/notimplemented.go similarity index 99% rename from pkg/v1/notimplemented.go rename to cloud/notimplemented.go index afe02d77..5c22615d 100644 --- a/pkg/v1/notimplemented.go +++ b/cloud/notimplemented.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/pkg/v1/quota.go b/cloud/quota.go similarity index 97% rename from pkg/v1/quota.go rename to cloud/quota.go index 68ad5924..e1139998 100644 --- a/pkg/v1/quota.go +++ b/cloud/quota.go @@ -1,4 +1,4 @@ -package v1 +package cloud import "context" diff --git a/internal/shadeform/Makefile b/cloud/shadeform/Makefile similarity index 94% rename from internal/shadeform/Makefile rename to cloud/shadeform/Makefile index b1b7e13b..1bd91df7 100644 --- a/internal/shadeform/Makefile +++ b/cloud/shadeform/Makefile @@ -1,3 +1,4 @@ +# Generate shadeform client generate-shadeform-client: docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.8.0 generate \ --additional-properties disallowAdditionalPropertiesIfNotPresent=false \ diff --git a/cloud/shadeform/capabilities.go b/cloud/shadeform/capabilities.go new file mode 100644 index 00000000..eba1fd26 --- /dev/null +++ b/cloud/shadeform/capabilities.go @@ -0,0 +1,19 @@ +package shadeform + +import ( + "context" + + "github.com/brevdev/sdk/cloud" +) + +func (c *ShadeformClient) GetCapabilities(_ context.Context) (cloud.Capabilities, error) { + capabilities := cloud.Capabilities{ + cloud.CapabilityCreateInstance, + cloud.CapabilityTerminateInstance, + cloud.CapabilityTags, + cloud.CapabilityRebootInstance, + cloud.CapabilityMachineImage, + } + + return capabilities, nil +} diff --git a/internal/shadeform/v1/client.go b/cloud/shadeform/client.go similarity index 80% rename from internal/shadeform/v1/client.go rename to cloud/shadeform/client.go index 14ed1b72..fc4e1cdc 100644 --- a/internal/shadeform/v1/client.go +++ b/cloud/shadeform/client.go @@ -1,4 +1,4 @@ -package v1 +package shadeform import ( "context" @@ -6,8 +6,8 @@ import ( "fmt" "net/http" - openapi "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" ) const CloudProviderID = "shadeform" @@ -18,7 +18,7 @@ type ShadeformCredential struct { APIKey string } -var _ v1.CloudCredential = &ShadeformCredential{} +var _ cloud.CloudCredential = &ShadeformCredential{} func NewShadeformCredential(refID, apiKey string) *ShadeformCredential { return &ShadeformCredential{ @@ -33,12 +33,12 @@ func (c *ShadeformCredential) GetReferenceID() string { } // GetAPIType returns the API type for Shadeform -func (c *ShadeformCredential) GetAPIType() v1.APIType { - return v1.APITypeGlobal +func (c *ShadeformCredential) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal } // GetCloudProviderID returns the cloud provider ID for Shadeform -func (c *ShadeformCredential) GetCloudProviderID() v1.CloudProviderID { +func (c *ShadeformCredential) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } @@ -49,7 +49,7 @@ func (c *ShadeformCredential) GetTenantID() (string, error) { } // GetCapabilities returns the capabilities for Shadeform -func (c *ShadeformCredential) GetCapabilities(ctx context.Context) (v1.Capabilities, error) { +func (c *ShadeformCredential) GetCapabilities(ctx context.Context) (cloud.Capabilities, error) { client, err := c.MakeClient(ctx, "") if err != nil { return nil, err @@ -58,14 +58,14 @@ func (c *ShadeformCredential) GetCapabilities(ctx context.Context) (v1.Capabilit } // MakeClient creates a new Shadeform client from this credential -func (c *ShadeformCredential) MakeClient(_ context.Context, _ string) (v1.CloudClient, error) { +func (c *ShadeformCredential) MakeClient(_ context.Context, _ string) (cloud.CloudClient, error) { return NewShadeformClient(c.RefID, c.APIKey), nil } // Shadeform implements the CloudClient interface for Shadeform // It embeds NotImplCloudClient to handle unsupported features type ShadeformClient struct { - v1.NotImplCloudClient + cloud.NotImplCloudClient refID string apiKey string baseURL string @@ -73,7 +73,7 @@ type ShadeformClient struct { config *Configuration } -var _ v1.CloudClient = &ShadeformClient{} +var _ cloud.CloudClient = &ShadeformClient{} func NewShadeformClient(refID, apiKey string) *ShadeformClient { config := openapi.NewConfiguration() @@ -94,17 +94,17 @@ func (c *ShadeformClient) WithConfiguration(config Configuration) *ShadeformClie } // GetAPIType returns the API type for Shadeform -func (c *ShadeformClient) GetAPIType() v1.APIType { - return v1.APITypeGlobal +func (c *ShadeformClient) GetAPIType() cloud.APIType { + return cloud.APITypeGlobal } // GetCloudProviderID returns the cloud provider ID for Shadeform -func (c *ShadeformClient) GetCloudProviderID() v1.CloudProviderID { +func (c *ShadeformClient) GetCloudProviderID() cloud.CloudProviderID { return CloudProviderID } // MakeClient creates a new client instance -func (c *ShadeformClient) MakeClient(_ context.Context, _ string) (v1.CloudClient, error) { +func (c *ShadeformClient) MakeClient(_ context.Context, _ string) (cloud.CloudClient, error) { return c, nil } diff --git a/internal/shadeform/v1/configuration.go b/cloud/shadeform/configuration.go similarity index 81% rename from internal/shadeform/v1/configuration.go rename to cloud/shadeform/configuration.go index 604a93ca..357a4d68 100644 --- a/internal/shadeform/v1/configuration.go +++ b/cloud/shadeform/configuration.go @@ -1,7 +1,7 @@ -package v1 +package shadeform import ( - openapi "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" + openapi "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" ) type Configuration struct { diff --git a/internal/shadeform/gen/shadeform/.gitignore b/cloud/shadeform/gen/shadeform/.gitignore similarity index 100% rename from internal/shadeform/gen/shadeform/.gitignore rename to cloud/shadeform/gen/shadeform/.gitignore diff --git a/internal/shadeform/gen/shadeform/.openapi-generator-ignore b/cloud/shadeform/gen/shadeform/.openapi-generator-ignore similarity index 100% rename from internal/shadeform/gen/shadeform/.openapi-generator-ignore rename to cloud/shadeform/gen/shadeform/.openapi-generator-ignore diff --git a/internal/shadeform/gen/shadeform/.openapi-generator/FILES b/cloud/shadeform/gen/shadeform/.openapi-generator/FILES similarity index 100% rename from internal/shadeform/gen/shadeform/.openapi-generator/FILES rename to cloud/shadeform/gen/shadeform/.openapi-generator/FILES diff --git a/internal/shadeform/gen/shadeform/.openapi-generator/VERSION b/cloud/shadeform/gen/shadeform/.openapi-generator/VERSION similarity index 100% rename from internal/shadeform/gen/shadeform/.openapi-generator/VERSION rename to cloud/shadeform/gen/shadeform/.openapi-generator/VERSION diff --git a/internal/shadeform/gen/shadeform/.travis.yml b/cloud/shadeform/gen/shadeform/.travis.yml similarity index 100% rename from internal/shadeform/gen/shadeform/.travis.yml rename to cloud/shadeform/gen/shadeform/.travis.yml diff --git a/internal/shadeform/gen/shadeform/README.md b/cloud/shadeform/gen/shadeform/README.md similarity index 100% rename from internal/shadeform/gen/shadeform/README.md rename to cloud/shadeform/gen/shadeform/README.md diff --git a/internal/shadeform/gen/shadeform/api/openapi.yaml b/cloud/shadeform/gen/shadeform/api/openapi.yaml similarity index 100% rename from internal/shadeform/gen/shadeform/api/openapi.yaml rename to cloud/shadeform/gen/shadeform/api/openapi.yaml diff --git a/internal/shadeform/gen/shadeform/api_default.go b/cloud/shadeform/gen/shadeform/api_default.go similarity index 100% rename from internal/shadeform/gen/shadeform/api_default.go rename to cloud/shadeform/gen/shadeform/api_default.go diff --git a/internal/shadeform/gen/shadeform/client.go b/cloud/shadeform/gen/shadeform/client.go similarity index 100% rename from internal/shadeform/gen/shadeform/client.go rename to cloud/shadeform/gen/shadeform/client.go diff --git a/internal/shadeform/gen/shadeform/configuration.go b/cloud/shadeform/gen/shadeform/configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/configuration.go rename to cloud/shadeform/gen/shadeform/configuration.go diff --git a/internal/shadeform/gen/shadeform/docs/AddSshKeyRequest.md b/cloud/shadeform/gen/shadeform/docs/AddSshKeyRequest.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/AddSshKeyRequest.md rename to cloud/shadeform/gen/shadeform/docs/AddSshKeyRequest.md diff --git a/internal/shadeform/gen/shadeform/docs/AddSshKeyResponse.md b/cloud/shadeform/gen/shadeform/docs/AddSshKeyResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/AddSshKeyResponse.md rename to cloud/shadeform/gen/shadeform/docs/AddSshKeyResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/Alert.md b/cloud/shadeform/gen/shadeform/docs/Alert.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Alert.md rename to cloud/shadeform/gen/shadeform/docs/Alert.md diff --git a/internal/shadeform/gen/shadeform/docs/AutoDelete.md b/cloud/shadeform/gen/shadeform/docs/AutoDelete.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/AutoDelete.md rename to cloud/shadeform/gen/shadeform/docs/AutoDelete.md diff --git a/internal/shadeform/gen/shadeform/docs/Availability.md b/cloud/shadeform/gen/shadeform/docs/Availability.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Availability.md rename to cloud/shadeform/gen/shadeform/docs/Availability.md diff --git a/internal/shadeform/gen/shadeform/docs/BootTime.md b/cloud/shadeform/gen/shadeform/docs/BootTime.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/BootTime.md rename to cloud/shadeform/gen/shadeform/docs/BootTime.md diff --git a/internal/shadeform/gen/shadeform/docs/Cloud.md b/cloud/shadeform/gen/shadeform/docs/Cloud.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Cloud.md rename to cloud/shadeform/gen/shadeform/docs/Cloud.md diff --git a/internal/shadeform/gen/shadeform/docs/CreateRequest.md b/cloud/shadeform/gen/shadeform/docs/CreateRequest.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/CreateRequest.md rename to cloud/shadeform/gen/shadeform/docs/CreateRequest.md diff --git a/internal/shadeform/gen/shadeform/docs/CreateResponse.md b/cloud/shadeform/gen/shadeform/docs/CreateResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/CreateResponse.md rename to cloud/shadeform/gen/shadeform/docs/CreateResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/CreateVolumeRequest.md b/cloud/shadeform/gen/shadeform/docs/CreateVolumeRequest.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/CreateVolumeRequest.md rename to cloud/shadeform/gen/shadeform/docs/CreateVolumeRequest.md diff --git a/internal/shadeform/gen/shadeform/docs/CreateVolumeResponse.md b/cloud/shadeform/gen/shadeform/docs/CreateVolumeResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/CreateVolumeResponse.md rename to cloud/shadeform/gen/shadeform/docs/CreateVolumeResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/DefaultAPI.md b/cloud/shadeform/gen/shadeform/docs/DefaultAPI.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/DefaultAPI.md rename to cloud/shadeform/gen/shadeform/docs/DefaultAPI.md diff --git a/internal/shadeform/gen/shadeform/docs/DockerConfiguration.md b/cloud/shadeform/gen/shadeform/docs/DockerConfiguration.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/DockerConfiguration.md rename to cloud/shadeform/gen/shadeform/docs/DockerConfiguration.md diff --git a/internal/shadeform/gen/shadeform/docs/Env.md b/cloud/shadeform/gen/shadeform/docs/Env.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Env.md rename to cloud/shadeform/gen/shadeform/docs/Env.md diff --git a/internal/shadeform/gen/shadeform/docs/FeaturedTemplate.md b/cloud/shadeform/gen/shadeform/docs/FeaturedTemplate.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/FeaturedTemplate.md rename to cloud/shadeform/gen/shadeform/docs/FeaturedTemplate.md diff --git a/internal/shadeform/gen/shadeform/docs/FeaturedTemplatesResponse.md b/cloud/shadeform/gen/shadeform/docs/FeaturedTemplatesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/FeaturedTemplatesResponse.md rename to cloud/shadeform/gen/shadeform/docs/FeaturedTemplatesResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/Instance.md b/cloud/shadeform/gen/shadeform/docs/Instance.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Instance.md rename to cloud/shadeform/gen/shadeform/docs/Instance.md diff --git a/internal/shadeform/gen/shadeform/docs/InstanceConfiguration.md b/cloud/shadeform/gen/shadeform/docs/InstanceConfiguration.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstanceConfiguration.md rename to cloud/shadeform/gen/shadeform/docs/InstanceConfiguration.md diff --git a/internal/shadeform/gen/shadeform/docs/InstanceInfoResponse.md b/cloud/shadeform/gen/shadeform/docs/InstanceInfoResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstanceInfoResponse.md rename to cloud/shadeform/gen/shadeform/docs/InstanceInfoResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/InstancePortMappings.md b/cloud/shadeform/gen/shadeform/docs/InstancePortMappings.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstancePortMappings.md rename to cloud/shadeform/gen/shadeform/docs/InstancePortMappings.md diff --git a/internal/shadeform/gen/shadeform/docs/InstanceType.md b/cloud/shadeform/gen/shadeform/docs/InstanceType.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstanceType.md rename to cloud/shadeform/gen/shadeform/docs/InstanceType.md diff --git a/internal/shadeform/gen/shadeform/docs/InstanceTypeConfiguration.md b/cloud/shadeform/gen/shadeform/docs/InstanceTypeConfiguration.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstanceTypeConfiguration.md rename to cloud/shadeform/gen/shadeform/docs/InstanceTypeConfiguration.md diff --git a/internal/shadeform/gen/shadeform/docs/InstanceTypesResponse.md b/cloud/shadeform/gen/shadeform/docs/InstanceTypesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstanceTypesResponse.md rename to cloud/shadeform/gen/shadeform/docs/InstanceTypesResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/InstancesResponse.md b/cloud/shadeform/gen/shadeform/docs/InstancesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/InstancesResponse.md rename to cloud/shadeform/gen/shadeform/docs/InstancesResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/LaunchConfiguration.md b/cloud/shadeform/gen/shadeform/docs/LaunchConfiguration.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/LaunchConfiguration.md rename to cloud/shadeform/gen/shadeform/docs/LaunchConfiguration.md diff --git a/internal/shadeform/gen/shadeform/docs/Networking.md b/cloud/shadeform/gen/shadeform/docs/Networking.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Networking.md rename to cloud/shadeform/gen/shadeform/docs/Networking.md diff --git a/internal/shadeform/gen/shadeform/docs/PortMappings.md b/cloud/shadeform/gen/shadeform/docs/PortMappings.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/PortMappings.md rename to cloud/shadeform/gen/shadeform/docs/PortMappings.md diff --git a/internal/shadeform/gen/shadeform/docs/RegistryCredentials.md b/cloud/shadeform/gen/shadeform/docs/RegistryCredentials.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/RegistryCredentials.md rename to cloud/shadeform/gen/shadeform/docs/RegistryCredentials.md diff --git a/internal/shadeform/gen/shadeform/docs/ScriptConfiguration.md b/cloud/shadeform/gen/shadeform/docs/ScriptConfiguration.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/ScriptConfiguration.md rename to cloud/shadeform/gen/shadeform/docs/ScriptConfiguration.md diff --git a/internal/shadeform/gen/shadeform/docs/SshKey.md b/cloud/shadeform/gen/shadeform/docs/SshKey.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/SshKey.md rename to cloud/shadeform/gen/shadeform/docs/SshKey.md diff --git a/internal/shadeform/gen/shadeform/docs/SshKeysResponse.md b/cloud/shadeform/gen/shadeform/docs/SshKeysResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/SshKeysResponse.md rename to cloud/shadeform/gen/shadeform/docs/SshKeysResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/Status.md b/cloud/shadeform/gen/shadeform/docs/Status.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Status.md rename to cloud/shadeform/gen/shadeform/docs/Status.md diff --git a/internal/shadeform/gen/shadeform/docs/Template.md b/cloud/shadeform/gen/shadeform/docs/Template.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Template.md rename to cloud/shadeform/gen/shadeform/docs/Template.md diff --git a/internal/shadeform/gen/shadeform/docs/TemplateCreateResponse.md b/cloud/shadeform/gen/shadeform/docs/TemplateCreateResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/TemplateCreateResponse.md rename to cloud/shadeform/gen/shadeform/docs/TemplateCreateResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/TemplateSaveRequest.md b/cloud/shadeform/gen/shadeform/docs/TemplateSaveRequest.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/TemplateSaveRequest.md rename to cloud/shadeform/gen/shadeform/docs/TemplateSaveRequest.md diff --git a/internal/shadeform/gen/shadeform/docs/TemplatesResponse.md b/cloud/shadeform/gen/shadeform/docs/TemplatesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/TemplatesResponse.md rename to cloud/shadeform/gen/shadeform/docs/TemplatesResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/UfwRule.md b/cloud/shadeform/gen/shadeform/docs/UfwRule.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/UfwRule.md rename to cloud/shadeform/gen/shadeform/docs/UfwRule.md diff --git a/internal/shadeform/gen/shadeform/docs/UpdateRequest.md b/cloud/shadeform/gen/shadeform/docs/UpdateRequest.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/UpdateRequest.md rename to cloud/shadeform/gen/shadeform/docs/UpdateRequest.md diff --git a/internal/shadeform/gen/shadeform/docs/Volume.md b/cloud/shadeform/gen/shadeform/docs/Volume.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/Volume.md rename to cloud/shadeform/gen/shadeform/docs/Volume.md diff --git a/internal/shadeform/gen/shadeform/docs/VolumeMount.md b/cloud/shadeform/gen/shadeform/docs/VolumeMount.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/VolumeMount.md rename to cloud/shadeform/gen/shadeform/docs/VolumeMount.md diff --git a/internal/shadeform/gen/shadeform/docs/VolumeMounts.md b/cloud/shadeform/gen/shadeform/docs/VolumeMounts.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/VolumeMounts.md rename to cloud/shadeform/gen/shadeform/docs/VolumeMounts.md diff --git a/internal/shadeform/gen/shadeform/docs/VolumeTypesInner.md b/cloud/shadeform/gen/shadeform/docs/VolumeTypesInner.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/VolumeTypesInner.md rename to cloud/shadeform/gen/shadeform/docs/VolumeTypesInner.md diff --git a/internal/shadeform/gen/shadeform/docs/VolumesResponse.md b/cloud/shadeform/gen/shadeform/docs/VolumesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/VolumesResponse.md rename to cloud/shadeform/gen/shadeform/docs/VolumesResponse.md diff --git a/internal/shadeform/gen/shadeform/docs/VolumesTypesResponse.md b/cloud/shadeform/gen/shadeform/docs/VolumesTypesResponse.md similarity index 100% rename from internal/shadeform/gen/shadeform/docs/VolumesTypesResponse.md rename to cloud/shadeform/gen/shadeform/docs/VolumesTypesResponse.md diff --git a/internal/shadeform/gen/shadeform/git_push.sh b/cloud/shadeform/gen/shadeform/git_push.sh similarity index 100% rename from internal/shadeform/gen/shadeform/git_push.sh rename to cloud/shadeform/gen/shadeform/git_push.sh diff --git a/internal/shadeform/gen/shadeform/model_add_ssh_key_request.go b/cloud/shadeform/gen/shadeform/model_add_ssh_key_request.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_add_ssh_key_request.go rename to cloud/shadeform/gen/shadeform/model_add_ssh_key_request.go diff --git a/internal/shadeform/gen/shadeform/model_add_ssh_key_response.go b/cloud/shadeform/gen/shadeform/model_add_ssh_key_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_add_ssh_key_response.go rename to cloud/shadeform/gen/shadeform/model_add_ssh_key_response.go diff --git a/internal/shadeform/gen/shadeform/model_alert.go b/cloud/shadeform/gen/shadeform/model_alert.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_alert.go rename to cloud/shadeform/gen/shadeform/model_alert.go diff --git a/internal/shadeform/gen/shadeform/model_auto_delete.go b/cloud/shadeform/gen/shadeform/model_auto_delete.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_auto_delete.go rename to cloud/shadeform/gen/shadeform/model_auto_delete.go diff --git a/internal/shadeform/gen/shadeform/model_availability.go b/cloud/shadeform/gen/shadeform/model_availability.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_availability.go rename to cloud/shadeform/gen/shadeform/model_availability.go diff --git a/internal/shadeform/gen/shadeform/model_boot_time.go b/cloud/shadeform/gen/shadeform/model_boot_time.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_boot_time.go rename to cloud/shadeform/gen/shadeform/model_boot_time.go diff --git a/internal/shadeform/gen/shadeform/model_cloud.go b/cloud/shadeform/gen/shadeform/model_cloud.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_cloud.go rename to cloud/shadeform/gen/shadeform/model_cloud.go diff --git a/internal/shadeform/gen/shadeform/model_create_request.go b/cloud/shadeform/gen/shadeform/model_create_request.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_create_request.go rename to cloud/shadeform/gen/shadeform/model_create_request.go diff --git a/internal/shadeform/gen/shadeform/model_create_response.go b/cloud/shadeform/gen/shadeform/model_create_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_create_response.go rename to cloud/shadeform/gen/shadeform/model_create_response.go diff --git a/internal/shadeform/gen/shadeform/model_create_volume_request.go b/cloud/shadeform/gen/shadeform/model_create_volume_request.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_create_volume_request.go rename to cloud/shadeform/gen/shadeform/model_create_volume_request.go diff --git a/internal/shadeform/gen/shadeform/model_create_volume_response.go b/cloud/shadeform/gen/shadeform/model_create_volume_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_create_volume_response.go rename to cloud/shadeform/gen/shadeform/model_create_volume_response.go diff --git a/internal/shadeform/gen/shadeform/model_docker_configuration.go b/cloud/shadeform/gen/shadeform/model_docker_configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_docker_configuration.go rename to cloud/shadeform/gen/shadeform/model_docker_configuration.go diff --git a/internal/shadeform/gen/shadeform/model_env.go b/cloud/shadeform/gen/shadeform/model_env.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_env.go rename to cloud/shadeform/gen/shadeform/model_env.go diff --git a/internal/shadeform/gen/shadeform/model_featured_template.go b/cloud/shadeform/gen/shadeform/model_featured_template.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_featured_template.go rename to cloud/shadeform/gen/shadeform/model_featured_template.go diff --git a/internal/shadeform/gen/shadeform/model_featured_templates_response.go b/cloud/shadeform/gen/shadeform/model_featured_templates_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_featured_templates_response.go rename to cloud/shadeform/gen/shadeform/model_featured_templates_response.go diff --git a/internal/shadeform/gen/shadeform/model_instance.go b/cloud/shadeform/gen/shadeform/model_instance.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance.go rename to cloud/shadeform/gen/shadeform/model_instance.go diff --git a/internal/shadeform/gen/shadeform/model_instance_configuration.go b/cloud/shadeform/gen/shadeform/model_instance_configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_configuration.go rename to cloud/shadeform/gen/shadeform/model_instance_configuration.go diff --git a/internal/shadeform/gen/shadeform/model_instance_info_response.go b/cloud/shadeform/gen/shadeform/model_instance_info_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_info_response.go rename to cloud/shadeform/gen/shadeform/model_instance_info_response.go diff --git a/internal/shadeform/gen/shadeform/model_instance_port_mappings.go b/cloud/shadeform/gen/shadeform/model_instance_port_mappings.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_port_mappings.go rename to cloud/shadeform/gen/shadeform/model_instance_port_mappings.go diff --git a/internal/shadeform/gen/shadeform/model_instance_type.go b/cloud/shadeform/gen/shadeform/model_instance_type.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_type.go rename to cloud/shadeform/gen/shadeform/model_instance_type.go diff --git a/internal/shadeform/gen/shadeform/model_instance_type_configuration.go b/cloud/shadeform/gen/shadeform/model_instance_type_configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_type_configuration.go rename to cloud/shadeform/gen/shadeform/model_instance_type_configuration.go diff --git a/internal/shadeform/gen/shadeform/model_instance_types_response.go b/cloud/shadeform/gen/shadeform/model_instance_types_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instance_types_response.go rename to cloud/shadeform/gen/shadeform/model_instance_types_response.go diff --git a/internal/shadeform/gen/shadeform/model_instances_response.go b/cloud/shadeform/gen/shadeform/model_instances_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_instances_response.go rename to cloud/shadeform/gen/shadeform/model_instances_response.go diff --git a/internal/shadeform/gen/shadeform/model_launch_configuration.go b/cloud/shadeform/gen/shadeform/model_launch_configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_launch_configuration.go rename to cloud/shadeform/gen/shadeform/model_launch_configuration.go diff --git a/internal/shadeform/gen/shadeform/model_networking.go b/cloud/shadeform/gen/shadeform/model_networking.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_networking.go rename to cloud/shadeform/gen/shadeform/model_networking.go diff --git a/internal/shadeform/gen/shadeform/model_port_mappings.go b/cloud/shadeform/gen/shadeform/model_port_mappings.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_port_mappings.go rename to cloud/shadeform/gen/shadeform/model_port_mappings.go diff --git a/internal/shadeform/gen/shadeform/model_registry_credentials.go b/cloud/shadeform/gen/shadeform/model_registry_credentials.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_registry_credentials.go rename to cloud/shadeform/gen/shadeform/model_registry_credentials.go diff --git a/internal/shadeform/gen/shadeform/model_script_configuration.go b/cloud/shadeform/gen/shadeform/model_script_configuration.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_script_configuration.go rename to cloud/shadeform/gen/shadeform/model_script_configuration.go diff --git a/internal/shadeform/gen/shadeform/model_ssh_key.go b/cloud/shadeform/gen/shadeform/model_ssh_key.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_ssh_key.go rename to cloud/shadeform/gen/shadeform/model_ssh_key.go diff --git a/internal/shadeform/gen/shadeform/model_ssh_keys_response.go b/cloud/shadeform/gen/shadeform/model_ssh_keys_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_ssh_keys_response.go rename to cloud/shadeform/gen/shadeform/model_ssh_keys_response.go diff --git a/internal/shadeform/gen/shadeform/model_status.go b/cloud/shadeform/gen/shadeform/model_status.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_status.go rename to cloud/shadeform/gen/shadeform/model_status.go diff --git a/internal/shadeform/gen/shadeform/model_template.go b/cloud/shadeform/gen/shadeform/model_template.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_template.go rename to cloud/shadeform/gen/shadeform/model_template.go diff --git a/internal/shadeform/gen/shadeform/model_template_create_response.go b/cloud/shadeform/gen/shadeform/model_template_create_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_template_create_response.go rename to cloud/shadeform/gen/shadeform/model_template_create_response.go diff --git a/internal/shadeform/gen/shadeform/model_template_save_request.go b/cloud/shadeform/gen/shadeform/model_template_save_request.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_template_save_request.go rename to cloud/shadeform/gen/shadeform/model_template_save_request.go diff --git a/internal/shadeform/gen/shadeform/model_templates_response.go b/cloud/shadeform/gen/shadeform/model_templates_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_templates_response.go rename to cloud/shadeform/gen/shadeform/model_templates_response.go diff --git a/internal/shadeform/gen/shadeform/model_ufw_rule.go b/cloud/shadeform/gen/shadeform/model_ufw_rule.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_ufw_rule.go rename to cloud/shadeform/gen/shadeform/model_ufw_rule.go diff --git a/internal/shadeform/gen/shadeform/model_update_request.go b/cloud/shadeform/gen/shadeform/model_update_request.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_update_request.go rename to cloud/shadeform/gen/shadeform/model_update_request.go diff --git a/internal/shadeform/gen/shadeform/model_volume.go b/cloud/shadeform/gen/shadeform/model_volume.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volume.go rename to cloud/shadeform/gen/shadeform/model_volume.go diff --git a/internal/shadeform/gen/shadeform/model_volume_mount.go b/cloud/shadeform/gen/shadeform/model_volume_mount.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volume_mount.go rename to cloud/shadeform/gen/shadeform/model_volume_mount.go diff --git a/internal/shadeform/gen/shadeform/model_volume_mounts.go b/cloud/shadeform/gen/shadeform/model_volume_mounts.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volume_mounts.go rename to cloud/shadeform/gen/shadeform/model_volume_mounts.go diff --git a/internal/shadeform/gen/shadeform/model_volume_types_inner.go b/cloud/shadeform/gen/shadeform/model_volume_types_inner.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volume_types_inner.go rename to cloud/shadeform/gen/shadeform/model_volume_types_inner.go diff --git a/internal/shadeform/gen/shadeform/model_volumes_response.go b/cloud/shadeform/gen/shadeform/model_volumes_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volumes_response.go rename to cloud/shadeform/gen/shadeform/model_volumes_response.go diff --git a/internal/shadeform/gen/shadeform/model_volumes_types_response.go b/cloud/shadeform/gen/shadeform/model_volumes_types_response.go similarity index 100% rename from internal/shadeform/gen/shadeform/model_volumes_types_response.go rename to cloud/shadeform/gen/shadeform/model_volumes_types_response.go diff --git a/internal/shadeform/gen/shadeform/response.go b/cloud/shadeform/gen/shadeform/response.go similarity index 100% rename from internal/shadeform/gen/shadeform/response.go rename to cloud/shadeform/gen/shadeform/response.go diff --git a/internal/shadeform/gen/shadeform/test/api_default_test.go b/cloud/shadeform/gen/shadeform/test/api_default_test.go similarity index 98% rename from internal/shadeform/gen/shadeform/test/api_default_test.go rename to cloud/shadeform/gen/shadeform/test/api_default_test.go index ed794883..2d18c7d9 100644 --- a/internal/shadeform/gen/shadeform/test/api_default_test.go +++ b/cloud/shadeform/gen/shadeform/test/api_default_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" + openapiclient "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/shadeform/gen/shadeform/utils.go b/cloud/shadeform/gen/shadeform/utils.go similarity index 100% rename from internal/shadeform/gen/shadeform/utils.go rename to cloud/shadeform/gen/shadeform/utils.go diff --git a/internal/shadeform/v1/instance.go b/cloud/shadeform/instance.go similarity index 81% rename from internal/shadeform/v1/instance.go rename to cloud/shadeform/instance.go index f98d5639..425469ee 100644 --- a/internal/shadeform/v1/instance.go +++ b/cloud/shadeform/instance.go @@ -1,4 +1,4 @@ -package v1 +package shadeform import ( "context" @@ -7,8 +7,8 @@ import ( "strings" "github.com/alecthomas/units" - openapi "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" "github.com/google/uuid" ) @@ -18,7 +18,7 @@ const ( cloudCredRefIDTagName = "cloudCredRefID" //nolint:gosec // not a secret ) -func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateInstanceAttrs) (*v1.Instance, error) { //nolint:gocyclo,funlen // ok +func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs cloud.CreateInstanceAttrs) (*cloud.Instance, error) { //nolint:gocyclo,funlen // ok authCtx := c.makeAuthContext(ctx) // Check if the instance type is allowed by configuration @@ -46,12 +46,12 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns } region := attrs.Location - cloud, shadeInstanceType, err := c.getShadeformCloudAndInstanceType(attrs.InstanceType) + shadeformCloud, shadeInstanceType, err := c.getShadeformCloudAndInstanceType(attrs.InstanceType) if err != nil { return nil, err } - cloudEnum, err := openapi.NewCloudFromValue(cloud) + shadeformCloudEnum, err := openapi.NewCloudFromValue(shadeformCloud) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns } req := openapi.CreateRequest{ - Cloud: *cloudEnum, + Cloud: *shadeformCloudEnum, Region: region, ShadeInstanceType: shadeInstanceType, Name: attrs.Name, @@ -113,7 +113,7 @@ func (c *ShadeformClient) CreateInstance(ctx context.Context, attrs v1.CreateIns // Since Shadeform doesn't return the full instance that's created, we need to make a second API call to get // the created instance after we call create - createdInstance, err := c.GetInstance(authCtx, v1.CloudProviderInstanceID(resp.Id)) + createdInstance, err := c.GetInstance(authCtx, cloud.CloudProviderInstanceID(resp.Id)) if err != nil { return nil, err } @@ -144,7 +144,7 @@ func (c *ShadeformClient) addSSHKey(ctx context.Context, keyPairName string, pub return resp.Id, nil } -func (c *ShadeformClient) GetInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) (*v1.Instance, error) { +func (c *ShadeformClient) GetInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) (*cloud.Instance, error) { authCtx := c.makeAuthContext(ctx) resp, httpResp, err := c.client.DefaultAPI.InstancesInfo(authCtx, string(instanceID)).Execute() @@ -167,7 +167,7 @@ func (c *ShadeformClient) GetInstance(ctx context.Context, instanceID v1.CloudPr return instance, nil } -func (c *ShadeformClient) TerminateInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error { +func (c *ShadeformClient) TerminateInstance(ctx context.Context, instanceID cloud.CloudProviderInstanceID) error { authCtx := c.makeAuthContext(ctx) httpResp, err := c.client.DefaultAPI.InstancesDelete(authCtx, string(instanceID)).Execute() @@ -181,7 +181,7 @@ func (c *ShadeformClient) TerminateInstance(ctx context.Context, instanceID v1.C return nil } -func (c *ShadeformClient) ListInstances(ctx context.Context, _ v1.ListInstancesArgs) ([]v1.Instance, error) { +func (c *ShadeformClient) ListInstances(ctx context.Context, _ cloud.ListInstancesArgs) ([]cloud.Instance, error) { authCtx := c.makeAuthContext(ctx) resp, httpResp, err := c.client.DefaultAPI.Instances(authCtx).Execute() @@ -192,7 +192,7 @@ func (c *ShadeformClient) ListInstances(ctx context.Context, _ v1.ListInstancesA return nil, fmt.Errorf("failed to list instances: %w", err) } - var instances []v1.Instance + var instances []cloud.Instance for _, instance := range resp.Instances { singleInstance, err := c.convertShadeformInstanceToV1Instance(instance) if err != nil { @@ -204,39 +204,39 @@ func (c *ShadeformClient) ListInstances(ctx context.Context, _ v1.ListInstancesA return instances, nil } -func (c *ShadeformClient) RebootInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented +func (c *ShadeformClient) RebootInstance(_ context.Context, _ cloud.CloudProviderInstanceID) error { + return cloud.ErrNotImplemented } -func (c *ShadeformClient) MergeInstanceForUpdate(currInst v1.Instance, _ v1.Instance) v1.Instance { +func (c *ShadeformClient) MergeInstanceForUpdate(currInst cloud.Instance, _ cloud.Instance) cloud.Instance { return currInst } -func (c *ShadeformClient) MergeInstanceTypeForUpdate(currIt v1.InstanceType, _ v1.InstanceType) v1.InstanceType { +func (c *ShadeformClient) MergeInstanceTypeForUpdate(currIt cloud.InstanceType, _ cloud.InstanceType) cloud.InstanceType { return currIt } -func (c *ShadeformClient) getLifecycleStatus(status string) v1.LifecycleStatus { - var lifecycleStatus v1.LifecycleStatus +func (c *ShadeformClient) getLifecycleStatus(status string) cloud.LifecycleStatus { + var lifecycleStatus cloud.LifecycleStatus switch status { case "creating": - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending case "pending_provider": - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending case "pending": - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending case "active": - lifecycleStatus = v1.LifecycleStatusRunning + lifecycleStatus = cloud.LifecycleStatusRunning case "error": - lifecycleStatus = v1.LifecycleStatusFailed + lifecycleStatus = cloud.LifecycleStatusFailed default: - lifecycleStatus = v1.LifecycleStatusPending + lifecycleStatus = cloud.LifecycleStatusPending } return lifecycleStatus } // convertInstanceInfoResponseToV1Instance - converts Instance Info to v1 instance -func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo openapi.InstanceInfoResponse) (*v1.Instance, error) { +func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo openapi.InstanceInfoResponse) (*cloud.Instance, error) { instanceType := c.getInstanceType(string(instanceInfo.Cloud), instanceInfo.ShadeInstanceType) lifeCycleStatus := c.getLifecycleStatus(string(instanceInfo.Status)) @@ -257,10 +257,10 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo o } delete(tags, cloudCredRefIDTagName) - instance := &v1.Instance{ + instance := &cloud.Instance{ Name: instanceInfo.Name, CreatedAt: instanceInfo.CreatedAt, - CloudID: v1.CloudProviderInstanceID(instanceInfo.Id), + CloudID: cloud.CloudProviderInstanceID(instanceInfo.Id), PublicIP: instanceInfo.Ip, Hostname: hostname, ImageID: instanceInfo.Configuration.Os, @@ -268,7 +268,7 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo o DiskSize: units.Base2Bytes(instanceInfo.Configuration.StorageInGb) * units.GiB, SSHUser: instanceInfo.SshUser, SSHPort: int(instanceInfo.SshPort), - Status: v1.Status{ + Status: cloud.Status{ LifecycleStatus: lifeCycleStatus, }, Spot: false, @@ -284,7 +284,7 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(instanceInfo o // convertInstanceInfoResponseToV1Instance - converts /instances response to v1 instance; the api struct is slightly // different from instance info response and expected to diverge so keeping it as a separate function for now -func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance openapi.Instance) (*v1.Instance, error) { +func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance openapi.Instance) (*cloud.Instance, error) { instanceType := c.getInstanceType(string(shadeformInstance.Cloud), shadeformInstance.ShadeInstanceType) lifeCycleStatus := c.getLifecycleStatus(string(shadeformInstance.Status)) @@ -305,10 +305,10 @@ func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance } delete(tags, cloudCredRefIDTagName) - instance := &v1.Instance{ + instance := &cloud.Instance{ Name: shadeformInstance.Name, CreatedAt: shadeformInstance.CreatedAt, - CloudID: v1.CloudProviderInstanceID(shadeformInstance.Id), + CloudID: cloud.CloudProviderInstanceID(shadeformInstance.Id), PublicIP: shadeformInstance.Ip, Hostname: hostname, ImageID: shadeformInstance.Configuration.Os, @@ -316,7 +316,7 @@ func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance DiskSize: units.Base2Bytes(shadeformInstance.Configuration.StorageInGb) * units.GiB, SSHUser: shadeformInstance.SshUser, SSHPort: int(shadeformInstance.SshPort), - Status: v1.Status{ + Status: cloud.Status{ LifecycleStatus: lifeCycleStatus, }, Spot: false, @@ -331,8 +331,8 @@ func (c *ShadeformClient) convertShadeformInstanceToV1Instance(shadeformInstance return instance, nil } -func (c *ShadeformClient) convertShadeformTagToV1Tag(shadeformTags []string) (v1.Tags, error) { - tags := v1.Tags{} +func (c *ShadeformClient) convertShadeformTagToV1Tag(shadeformTags []string) (cloud.Tags, error) { + tags := cloud.Tags{} for _, tag := range shadeformTags { key, value, err := c.getTag(tag) if err != nil { diff --git a/internal/shadeform/v1/instancetype.go b/cloud/shadeform/instancetype.go similarity index 87% rename from internal/shadeform/v1/instancetype.go rename to cloud/shadeform/instancetype.go index 10f6dc31..5541c011 100644 --- a/internal/shadeform/v1/instancetype.go +++ b/cloud/shadeform/instancetype.go @@ -1,4 +1,4 @@ -package v1 +package shadeform import ( "context" @@ -10,9 +10,9 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - openapi "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" + openapi "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" - "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) const ( @@ -22,7 +22,7 @@ const ( // TODO: We need to apply a filter to specifically limit the integration and api to selected clouds and shade instance types -func (c *ShadeformClient) GetInstanceTypes(ctx context.Context, args v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) { +func (c *ShadeformClient) GetInstanceTypes(ctx context.Context, args cloud.GetInstanceTypeArgs) ([]cloud.InstanceType, error) { authCtx := c.makeAuthContext(ctx) request := c.client.DefaultAPI.InstancesTypes(authCtx) @@ -39,7 +39,7 @@ func (c *ShadeformClient) GetInstanceTypes(ctx context.Context, args v1.GetInsta return nil, fmt.Errorf("failed to get instance types: %w", err) } - var instanceTypes []v1.InstanceType + var instanceTypes []cloud.InstanceType for _, sfInstanceType := range resp.InstanceTypes { instanceTypesFromShadeformInstanceType, err := c.convertShadeformInstanceTypeToV1InstanceType(sfInstanceType) if err != nil { @@ -60,7 +60,7 @@ func (c *ShadeformClient) GetInstanceTypePollTime() time.Duration { return 5 * time.Minute } -func (c *ShadeformClient) GetLocations(ctx context.Context, _ v1.GetLocationsArgs) ([]v1.Location, error) { +func (c *ShadeformClient) GetLocations(ctx context.Context, _ cloud.GetLocationsArgs) ([]cloud.Location, error) { authCtx := c.makeAuthContext(ctx) resp, httpResp, err := c.client.DefaultAPI.InstancesTypes(authCtx).Execute() @@ -75,14 +75,14 @@ func (c *ShadeformClient) GetLocations(ctx context.Context, _ v1.GetLocationsArg // Shadeform doesn't have a dedicated locations API but we can get the same result from using the // instance types API and formatting the output - dedupedLocations := map[string]v1.Location{} + dedupedLocations := map[string]cloud.Location{} if resp != nil { for _, instanceType := range resp.InstanceTypes { for _, availability := range instanceType.Availability { _, ok := dedupedLocations[availability.Region] if !ok { - dedupedLocations[availability.Region] = v1.Location{ + dedupedLocations[availability.Region] = cloud.Location{ Name: availability.Region, Description: availability.DisplayName, Available: availability.Available, @@ -92,7 +92,7 @@ func (c *ShadeformClient) GetLocations(ctx context.Context, _ v1.GetLocationsArg } } - locations := []v1.Location{} + locations := []cloud.Location{} for _, location := range dedupedLocations { locations = append(locations, location) @@ -143,10 +143,10 @@ func (c *ShadeformClient) getShadeformCloudAndInstanceType(instanceType string) } // convertShadeformInstanceTypeToV1InstanceTypes - converts a shadeform returned instance type to a specific instance type and region of availability -func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeformInstanceType openapi.InstanceType) ([]v1.InstanceType, error) { +func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeformInstanceType openapi.InstanceType) ([]cloud.InstanceType, error) { instanceType := c.getInstanceType(string(shadeformInstanceType.Cloud), shadeformInstanceType.ShadeInstanceType) - instanceTypes := []v1.InstanceType{} + instanceTypes := []cloud.InstanceType{} basePrice, err := convertHourlyPriceToAmount(shadeformInstanceType.HourlyPrice) if err != nil { @@ -154,12 +154,12 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform } for _, region := range shadeformInstanceType.Availability { - instanceTypes = append(instanceTypes, v1.InstanceType{ - ID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), + instanceTypes = append(instanceTypes, cloud.InstanceType{ + ID: cloud.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), Type: instanceType, VCPU: shadeformInstanceType.Configuration.Vcpus, Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, - SupportedGPUs: []v1.GPU{ + SupportedGPUs: []cloud.GPU{ { Count: shadeformInstanceType.Configuration.NumGpus, Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, diff --git a/internal/shadeform/v1/ufw.go b/cloud/shadeform/ufw.go similarity index 92% rename from internal/shadeform/v1/ufw.go rename to cloud/shadeform/ufw.go index 16e33334..34a30f9a 100644 --- a/internal/shadeform/v1/ufw.go +++ b/cloud/shadeform/ufw.go @@ -1,10 +1,10 @@ -package v1 +package shadeform import ( "encoding/base64" "fmt" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" ) const ( @@ -16,7 +16,7 @@ const ( ufwForceEnable = "ufw --force enable" ) -func (c *ShadeformClient) GenerateFirewallScript(firewallRules v1.FirewallRules) (string, error) { +func (c *ShadeformClient) GenerateFirewallScript(firewallRules cloud.FirewallRules) (string, error) { commands := []string{ufwForceReset, ufwDefaultDropIncoming, ufwDefaultAllowOutgoing, ufwDefaultAllowPort22, ufwDefaultAllowPort2222} for _, firewallRule := range firewallRules.IngressRules { @@ -39,7 +39,7 @@ func (c *ShadeformClient) GenerateFirewallScript(firewallRules v1.FirewallRules) return encoded, nil } -func (c *ShadeformClient) convertIngressFirewallRuleToUfwCommand(firewallRule v1.FirewallRule) []string { +func (c *ShadeformClient) convertIngressFirewallRuleToUfwCommand(firewallRule cloud.FirewallRule) []string { cmds := []string{} portSpecs := []string{} if firewallRule.FromPort == firewallRule.ToPort { @@ -64,7 +64,7 @@ func (c *ShadeformClient) convertIngressFirewallRuleToUfwCommand(firewallRule v1 return cmds } -func (c *ShadeformClient) convertEgressFirewallRuleToUfwCommand(firewallRule v1.FirewallRule) []string { +func (c *ShadeformClient) convertEgressFirewallRuleToUfwCommand(firewallRule cloud.FirewallRule) []string { cmds := []string{} portSpecs := []string{} if firewallRule.FromPort == firewallRule.ToPort { diff --git a/internal/shadeform/v1/validation_test.go b/cloud/shadeform/validation_test.go similarity index 79% rename from internal/shadeform/v1/validation_test.go rename to cloud/shadeform/validation_test.go index 71204fd9..477b9cbd 100644 --- a/internal/shadeform/v1/validation_test.go +++ b/cloud/shadeform/validation_test.go @@ -1,4 +1,4 @@ -package v1 +package shadeform import ( "context" @@ -6,10 +6,10 @@ import ( "testing" "time" - openapi "github.com/brevdev/cloud/internal/shadeform/gen/shadeform" - "github.com/brevdev/cloud/internal/validation" - "github.com/brevdev/cloud/pkg/ssh" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + openapi "github.com/brevdev/sdk/cloud/shadeform/gen/shadeform" + "github.com/brevdev/sdk/internal/ssh" + "github.com/brevdev/sdk/internal/validation" "github.com/google/uuid" "github.com/stretchr/testify/require" ) @@ -21,7 +21,7 @@ func TestValidationFunctions(t *testing.T) { config := validation.ProviderConfig{ Credential: NewShadeformCredential("validation-test", apiKey), - StableIDs: []v1.InstanceTypeID{"datacrunch_B200_helsinki-finland-5", "massedcompute_L40_desmoines-usa-1"}, + StableIDs: []cloud.InstanceTypeID{"datacrunch_B200_helsinki-finland-5", "massedcompute_L40_desmoines-usa-1"}, } validation.RunValidationSuite(t, config) @@ -56,7 +56,7 @@ func TestInstanceTypeFilter(t *testing.T) { }, }) - types, err := client.GetInstanceTypes(ctx, v1.GetInstanceTypeArgs{}) + types, err := client.GetInstanceTypes(ctx, cloud.GetInstanceTypeArgs{}) require.NoError(t, err) require.NotEmpty(t, types, "Should have instance types") require.True(t, len(types) == 1, "Instance types should return only one entry") @@ -66,14 +66,14 @@ func TestInstanceTypeFilter(t *testing.T) { return } - instance, err := client.CreateInstance(ctx, v1.CreateInstanceAttrs{ + instance, err := client.CreateInstance(ctx, cloud.CreateInstanceAttrs{ RefID: uuid.New().String(), InstanceType: types[0].Type, Location: types[0].Location, PublicKey: ssh.GetTestPublicKey(), Name: "test_name", - FirewallRules: v1.FirewallRules{ - EgressRules: []v1.FirewallRule{ + FirewallRules: cloud.FirewallRules{ + EgressRules: []cloud.FirewallRule{ { ID: "test-rule1", FromPort: 80, @@ -87,7 +87,7 @@ func TestInstanceTypeFilter(t *testing.T) { IPRanges: []string{"127.0.0.1", "10.0.0.0/24"}, }, }, - IngressRules: []v1.FirewallRule{ + IngressRules: []cloud.FirewallRule{ { ID: "test-rule3", FromPort: 80, @@ -110,13 +110,13 @@ func TestInstanceTypeFilter(t *testing.T) { t.Run("ValidateSSHAccessible", func(t *testing.T) { t.Parallel() - err := v1.ValidateInstanceSSHAccessible(ctx, client, instance, ssh.GetTestPrivateKey()) + err := cloud.ValidateInstanceSSHAccessible(ctx, client, instance, ssh.GetTestPrivateKey()) require.NoError(t, err, "ValidateSSHAccessible should pass") }) t.Run("ValidateTerminateInstance", func(t *testing.T) { t.Parallel() - err := v1.ValidateTerminateInstance(ctx, client, instance) + err := cloud.ValidateTerminateInstance(ctx, client, instance) require.NoError(t, err, "ValidateTerminateInstance should pass") }) } diff --git a/pkg/v1/storage.go b/cloud/storage.go similarity index 98% rename from pkg/v1/storage.go rename to cloud/storage.go index 05f7750d..c733133c 100644 --- a/pkg/v1/storage.go +++ b/cloud/storage.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/pkg/v1/utils.go b/cloud/utils.go similarity index 67% rename from pkg/v1/utils.go rename to cloud/utils.go index a5b3563f..59139000 100644 --- a/pkg/v1/utils.go +++ b/cloud/utils.go @@ -1,3 +1,3 @@ -package v1 +package cloud type Tags map[string]string diff --git a/pkg/v1/waiters.go b/cloud/waiters.go similarity index 99% rename from pkg/v1/waiters.go rename to cloud/waiters.go index baf3de4d..f21b3bac 100644 --- a/pkg/v1/waiters.go +++ b/cloud/waiters.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/pkg/v1/waiters_test.go b/cloud/waiters_test.go similarity index 99% rename from pkg/v1/waiters_test.go rename to cloud/waiters_test.go index 3339253b..dfeeea2c 100644 --- a/pkg/v1/waiters_test.go +++ b/cloud/waiters_test.go @@ -1,4 +1,4 @@ -package v1 +package cloud import ( "context" diff --git a/go.mod b/go.mod index c80bea05..c036f408 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/brevdev/cloud +module github.com/brevdev/sdk go 1.25.0 diff --git a/internal/fluidstack/v1/capabilities.go b/internal/fluidstack/v1/capabilities.go deleted file mode 100644 index 38c193e2..00000000 --- a/internal/fluidstack/v1/capabilities.go +++ /dev/null @@ -1,19 +0,0 @@ -package v1 - -import ( - "context" - - "github.com/brevdev/cloud/pkg/v1" -) - -func (c *FluidStackClient) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - capabilities := v1.Capabilities{ - v1.CapabilityCreateInstance, - v1.CapabilityTerminateInstance, - v1.CapabilityStopStartInstance, - v1.CapabilityTags, - v1.CapabilityInstanceUserData, - } - - return capabilities, nil -} diff --git a/internal/lambdalabs/v1/capabilities.go b/internal/lambdalabs/v1/capabilities.go deleted file mode 100644 index 99e1105c..00000000 --- a/internal/lambdalabs/v1/capabilities.go +++ /dev/null @@ -1,38 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -// getLambdaLabsCapabilities returns the unified capabilities for Lambda Labs -// Based on API documentation at https://cloud.lambda.ai/api/v1/openapi.json -func getLambdaLabsCapabilities() v1.Capabilities { - return v1.Capabilities{ - // SUPPORTED FEATURES (with API evidence): - - // Instance Management - v1.CapabilityCreateInstance, // POST /api/v1/instance-operations/launch - v1.CapabilityTerminateInstance, // POST /api/v1/instance-operations/terminate - v1.CapabilityCreateTerminateInstance, // Combined create/terminate capability - v1.CapabilityRebootInstance, // POST /api/v1/instance-operations/restart - - // UNSUPPORTED FEATURES (no API evidence found): - // - v1.CapabilityModifyFirewall // Firewall management is project-level, not instance-level - // - v1.CapabilityStopStartInstance // No stop/start endpoints - // - v1.CapabilityResizeInstanceVolume // No volume resizing endpoints - // - v1.CapabilityMachineImage // No image endpoints - // - v1.CapabilityTags // No tagging endpoints - } -} - -// GetCapabilities returns the capabilities of Lambda Labs client -func (c *LambdaLabsClient) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - return getLambdaLabsCapabilities(), nil -} - -// GetCapabilities returns the capabilities for Lambda Labs credential -func (c *LambdaLabsCredential) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - return getLambdaLabsCapabilities(), nil -} diff --git a/internal/lambdalabs/v1/capabilities_test.go b/internal/lambdalabs/v1/capabilities_test.go deleted file mode 100644 index d76181f5..00000000 --- a/internal/lambdalabs/v1/capabilities_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package v1 - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func TestLambdaLabsClient_GetCapabilities(t *testing.T) { - client := &LambdaLabsClient{} - capabilities, err := client.GetCapabilities(context.Background()) - require.NoError(t, err) - - assert.Contains(t, capabilities, v1.CapabilityCreateInstance) - assert.Contains(t, capabilities, v1.CapabilityTerminateInstance) - assert.Contains(t, capabilities, v1.CapabilityRebootInstance) - assert.NotContains(t, capabilities, v1.CapabilityStopStartInstance) -} - -func TestLambdaLabsCredential_GetCapabilities(t *testing.T) { - cred := &LambdaLabsCredential{} - capabilities, err := cred.GetCapabilities(context.Background()) - require.NoError(t, err) - - assert.Contains(t, capabilities, v1.CapabilityCreateInstance) - assert.Contains(t, capabilities, v1.CapabilityTerminateInstance) - assert.Contains(t, capabilities, v1.CapabilityRebootInstance) - assert.NotContains(t, capabilities, v1.CapabilityStopStartInstance) -} diff --git a/internal/lambdalabs/v1/location_test.go b/internal/lambdalabs/v1/location_test.go deleted file mode 100644 index b7b1f993..00000000 --- a/internal/lambdalabs/v1/location_test.go +++ /dev/null @@ -1 +0,0 @@ -package v1 diff --git a/internal/nebius/v1/capabilities.go b/internal/nebius/v1/capabilities.go deleted file mode 100644 index da76b410..00000000 --- a/internal/nebius/v1/capabilities.go +++ /dev/null @@ -1,37 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func getNebiusCapabilities() v1.Capabilities { - return v1.Capabilities{ - // SUPPORTED FEATURES (with API evidence): - - // Instance Management - v1.CapabilityCreateInstance, // Nebius compute API supports instance creation - v1.CapabilityTerminateInstance, // Nebius compute API supports instance deletion - v1.CapabilityCreateTerminateInstance, // Combined create/terminate capability - v1.CapabilityRebootInstance, // Nebius supports instance restart operations - v1.CapabilityStopStartInstance, // Nebius supports instance stop/start operations - - v1.CapabilityModifyFirewall, // Nebius has Security Groups for firewall management - v1.CapabilityMachineImage, // Nebius supports custom machine images - v1.CapabilityResizeInstanceVolume, // Nebius supports disk resizing - v1.CapabilityTags, // Nebius supports resource tagging - v1.CapabilityInstanceUserData, // Nebius supports user data in instance creation - - } -} - -// GetCapabilities returns the capabilities of Nebius client -func (c *NebiusClient) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - return getNebiusCapabilities(), nil -} - -// GetCapabilities returns the capabilities for Nebius credential -func (c *NebiusCredential) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - return getNebiusCapabilities(), nil -} diff --git a/internal/nebius/v1/image.go b/internal/nebius/v1/image.go deleted file mode 100644 index f3540bf0..00000000 --- a/internal/nebius/v1/image.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) GetImages(_ context.Context, _ v1.GetImageArgs) ([]v1.Image, error) { - return nil, v1.ErrNotImplemented -} diff --git a/internal/nebius/v1/instance.go b/internal/nebius/v1/instance.go deleted file mode 100644 index 7fc2824a..00000000 --- a/internal/nebius/v1/instance.go +++ /dev/null @@ -1,49 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) CreateInstance(_ context.Context, _ v1.CreateInstanceAttrs) (*v1.Instance, error) { - return nil, v1.ErrNotImplemented -} - -func (c *NebiusClient) GetInstance(_ context.Context, _ v1.CloudProviderInstanceID) (*v1.Instance, error) { - return nil, v1.ErrNotImplemented -} - -func (c *NebiusClient) TerminateInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented -} - -func (c *NebiusClient) ListInstances(_ context.Context, _ v1.ListInstancesArgs) ([]v1.Instance, error) { - return nil, v1.ErrNotImplemented -} - -func (c *NebiusClient) StopInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented -} - -func (c *NebiusClient) StartInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented -} - -func (c *NebiusClient) RebootInstance(_ context.Context, _ v1.CloudProviderInstanceID) error { - return v1.ErrNotImplemented -} - -func (c *NebiusClient) MergeInstanceForUpdate(currInst v1.Instance, newInst v1.Instance) v1.Instance { - merged := newInst - - merged.Name = currInst.Name - merged.RefID = currInst.RefID - merged.CloudCredRefID = currInst.CloudCredRefID - merged.CreatedAt = currInst.CreatedAt - merged.CloudID = currInst.CloudID - merged.Location = currInst.Location - merged.SubLocation = currInst.SubLocation - - return merged -} diff --git a/internal/nebius/v1/instancetype.go b/internal/nebius/v1/instancetype.go deleted file mode 100644 index 80b6e83b..00000000 --- a/internal/nebius/v1/instancetype.go +++ /dev/null @@ -1,24 +0,0 @@ -package v1 - -import ( - "context" - "time" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) GetInstanceTypes(_ context.Context, _ v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) { - return nil, v1.ErrNotImplemented -} - -func (c *NebiusClient) GetInstanceTypePollTime() time.Duration { - return 5 * time.Minute -} - -func (c *NebiusClient) MergeInstanceTypeForUpdate(currIt v1.InstanceType, newIt v1.InstanceType) v1.InstanceType { - merged := newIt - - merged.ID = currIt.ID - - return merged -} diff --git a/internal/nebius/v1/location.go b/internal/nebius/v1/location.go deleted file mode 100644 index 3491e0bb..00000000 --- a/internal/nebius/v1/location.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) GetLocations(_ context.Context, _ v1.GetLocationsArgs) ([]v1.Location, error) { - return nil, v1.ErrNotImplemented -} diff --git a/internal/nebius/v1/networking.go b/internal/nebius/v1/networking.go deleted file mode 100644 index d31c39f6..00000000 --- a/internal/nebius/v1/networking.go +++ /dev/null @@ -1,15 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) AddFirewallRulesToInstance(_ context.Context, _ v1.AddFirewallRulesToInstanceArgs) error { - return v1.ErrNotImplemented -} - -func (c *NebiusClient) RevokeSecurityGroupRules(_ context.Context, _ v1.RevokeSecurityGroupRuleArgs) error { - return v1.ErrNotImplemented -} diff --git a/internal/nebius/v1/quota.go b/internal/nebius/v1/quota.go deleted file mode 100644 index 40601edb..00000000 --- a/internal/nebius/v1/quota.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) GetInstanceTypeQuotas(_ context.Context, _ v1.GetInstanceTypeQuotasArgs) (v1.Quota, error) { - return v1.Quota{}, v1.ErrNotImplemented -} diff --git a/internal/nebius/v1/storage.go b/internal/nebius/v1/storage.go deleted file mode 100644 index b642e184..00000000 --- a/internal/nebius/v1/storage.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) ResizeInstanceVolume(_ context.Context, _ v1.ResizeInstanceVolumeArgs) error { - return v1.ErrNotImplemented -} diff --git a/internal/nebius/v1/tags.go b/internal/nebius/v1/tags.go deleted file mode 100644 index d79bae1d..00000000 --- a/internal/nebius/v1/tags.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *NebiusClient) UpdateInstanceTags(_ context.Context, _ v1.UpdateInstanceTagsArgs) error { - return v1.ErrNotImplemented -} diff --git a/internal/shadeform/v1/capabilities.go b/internal/shadeform/v1/capabilities.go deleted file mode 100644 index 1971f363..00000000 --- a/internal/shadeform/v1/capabilities.go +++ /dev/null @@ -1,19 +0,0 @@ -package v1 - -import ( - "context" - - v1 "github.com/brevdev/cloud/pkg/v1" -) - -func (c *ShadeformClient) GetCapabilities(_ context.Context) (v1.Capabilities, error) { - capabilities := v1.Capabilities{ - v1.CapabilityCreateInstance, - v1.CapabilityTerminateInstance, - v1.CapabilityTags, - v1.CapabilityRebootInstance, - v1.CapabilityMachineImage, - } - - return capabilities, nil -} diff --git a/pkg/ssh/ssh.go b/internal/ssh/ssh.go similarity index 100% rename from pkg/ssh/ssh.go rename to internal/ssh/ssh.go diff --git a/pkg/ssh/ssh_test.go b/internal/ssh/ssh_test.go similarity index 100% rename from pkg/ssh/ssh_test.go rename to internal/ssh/ssh_test.go diff --git a/internal/validation/suite.go b/internal/validation/suite.go index ee9b9dae..144dfdb0 100644 --- a/internal/validation/suite.go +++ b/internal/validation/suite.go @@ -5,15 +5,15 @@ import ( "testing" "time" - "github.com/brevdev/cloud/pkg/ssh" - v1 "github.com/brevdev/cloud/pkg/v1" + "github.com/brevdev/sdk/cloud" + "github.com/brevdev/sdk/internal/ssh" "github.com/stretchr/testify/require" ) type ProviderConfig struct { Location string - StableIDs []v1.InstanceTypeID - Credential v1.CloudCredential + StableIDs []cloud.InstanceTypeID + Credential cloud.CloudCredential } func RunValidationSuite(t *testing.T, config ProviderConfig) { @@ -30,22 +30,22 @@ func RunValidationSuite(t *testing.T, config ProviderConfig) { } t.Run("ValidateGetLocations", func(t *testing.T) { - err := v1.ValidateGetLocations(ctx, client) + err := cloud.ValidateGetLocations(ctx, client) require.NoError(t, err, "ValidateGetLocations should pass") }) t.Run("ValidateGetInstanceTypes", func(t *testing.T) { - err := v1.ValidateGetInstanceTypes(ctx, client) + err := cloud.ValidateGetInstanceTypes(ctx, client) require.NoError(t, err, "ValidateGetInstanceTypes should pass") }) t.Run("ValidateRegionalInstanceTypes", func(t *testing.T) { - err := v1.ValidateLocationalInstanceTypes(ctx, client) + err := cloud.ValidateLocationalInstanceTypes(ctx, client) require.NoError(t, err, "ValidateRegionalInstanceTypes should pass") }) t.Run("ValidateStableInstanceTypeIDs", func(t *testing.T) { - err = v1.ValidateStableInstanceTypeIDs(ctx, client, config.StableIDs) + err = cloud.ValidateStableInstanceTypeIDs(ctx, client, config.StableIDs) require.NoError(t, err, "ValidateStableInstanceTypeIDs should pass") }) } @@ -65,16 +65,16 @@ func RunInstanceLifecycleValidation(t *testing.T, config ProviderConfig) { capabilities, err := client.GetCapabilities(ctx) require.NoError(t, err) - types, err := client.GetInstanceTypes(ctx, v1.GetInstanceTypeArgs{}) + types, err := client.GetInstanceTypes(ctx, cloud.GetInstanceTypeArgs{}) require.NoError(t, err) require.NotEmpty(t, types, "Should have instance types") - locations, err := client.GetLocations(ctx, v1.GetLocationsArgs{}) + locations, err := client.GetLocations(ctx, cloud.GetLocationsArgs{}) require.NoError(t, err) require.NotEmpty(t, locations, "Should have locations") t.Run("ValidateCreateInstance", func(t *testing.T) { - attrs := v1.CreateInstanceAttrs{} + attrs := cloud.CreateInstanceAttrs{} for _, typ := range types { if typ.IsAvailable { attrs.InstanceType = typ.Type @@ -83,7 +83,7 @@ func RunInstanceLifecycleValidation(t *testing.T, config ProviderConfig) { break } } - instance, err := v1.ValidateCreateInstance(ctx, client, attrs) + instance, err := cloud.ValidateCreateInstance(ctx, client, attrs) if err != nil { t.Fatalf("ValidateCreateInstance failed: %v", err) } @@ -96,12 +96,12 @@ func RunInstanceLifecycleValidation(t *testing.T, config ProviderConfig) { }() t.Run("ValidateListCreatedInstance", func(t *testing.T) { - err := v1.ValidateListCreatedInstance(ctx, client, instance) + err := cloud.ValidateListCreatedInstance(ctx, client, instance) require.NoError(t, err, "ValidateListCreatedInstance should pass") }) t.Run("ValidateSSHAccessible", func(t *testing.T) { - err := v1.ValidateInstanceSSHAccessible(ctx, client, instance, ssh.GetTestPrivateKey()) + err := cloud.ValidateInstanceSSHAccessible(ctx, client, instance, ssh.GetTestPrivateKey()) require.NoError(t, err, "ValidateSSHAccessible should pass") }) @@ -109,19 +109,19 @@ func RunInstanceLifecycleValidation(t *testing.T, config ProviderConfig) { require.NoError(t, err) t.Run("ValidateInstanceImage", func(t *testing.T) { - err := v1.ValidateInstanceImage(ctx, *instance, ssh.GetTestPrivateKey()) + err := cloud.ValidateInstanceImage(ctx, *instance, ssh.GetTestPrivateKey()) require.NoError(t, err, "ValidateInstanceImage should pass") }) - if capabilities.IsCapable(v1.CapabilityStopStartInstance) && instance.Stoppable { + if capabilities.IsCapable(cloud.CapabilityStopStartInstance) && instance.Stoppable { t.Run("ValidateStopStartInstance", func(t *testing.T) { - err := v1.ValidateStopStartInstance(ctx, client, instance) + err := cloud.ValidateStopStartInstance(ctx, client, instance) require.NoError(t, err, "ValidateStopStartInstance should pass") }) } t.Run("ValidateTerminateInstance", func(t *testing.T) { - err := v1.ValidateTerminateInstance(ctx, client, instance) + err := cloud.ValidateTerminateInstance(ctx, client, instance) require.NoError(t, err, "ValidateTerminateInstance should pass") }) })