Skip to content

Commit

Permalink
Merge pull request #41 from ukfast/draas-support
Browse files Browse the repository at this point in the history
add DRaaS service
  • Loading branch information
0x4c6565 authored May 15, 2020
2 parents fa73b2c + ca3beff commit b839c32
Show file tree
Hide file tree
Showing 12 changed files with 2,625 additions and 0 deletions.
57 changes: 57 additions & 0 deletions pkg/service/draas/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package draas

import "fmt"

// SolutionNotFoundError indicates a solution was not found
type SolutionNotFoundError struct {
ID string
}

func (e *SolutionNotFoundError) Error() string {
return fmt.Sprintf("Solution not found with ID [%s]", e.ID)
}

// IOPSTierNotFoundError indicates an IOPS tier was not found
type IOPSTierNotFoundError struct {
ID string
}

func (e *IOPSTierNotFoundError) Error() string {
return fmt.Sprintf("IOPS tier not found with ID [%s]", e.ID)
}

// FailoverPlanNotFoundError indicates a failover plan was not found
type FailoverPlanNotFoundError struct {
ID string
}

func (e *FailoverPlanNotFoundError) Error() string {
return fmt.Sprintf("Failover plan not found with ID [%s]", e.ID)
}

// ComputeResourceNotFoundError indicates compute resources was not found
type ComputeResourceNotFoundError struct {
ID string
}

func (e *ComputeResourceNotFoundError) Error() string {
return fmt.Sprintf("Compute resources not found with ID [%s]", e.ID)
}

// HardwarePlanNotFoundError indicates hardware plan was not found
type HardwarePlanNotFoundError struct {
ID string
}

func (e *HardwarePlanNotFoundError) Error() string {
return fmt.Sprintf("Hardware plan not found with ID [%s]", e.ID)
}

// BillingTypeNotFoundError indicates billing type was not found
type BillingTypeNotFoundError struct {
ID string
}

func (e *BillingTypeNotFoundError) Error() string {
return fmt.Sprintf("Billing type not found with ID [%s]", e.ID)
}
106 changes: 106 additions & 0 deletions pkg/service/draas/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//go:generate go run ../../gen/model_paginated_gen.go -package draas -typename Solution,BackupResource,IOPSTier,FailoverPlan,ComputeResource,HardwarePlan,Replica,BillingType -destination model_paginated.go
package draas

// Solution represents a solution
type Solution struct {
ID string `json:"id"`
Name string `json:"name"`
IOPSTierID string `json:"iops_tier_id"`
BillingTypeID string `json:"billing_type_id"`
}

// BackupResource represents backup resources for a solution
type BackupResource struct {
ID string `json:"id"`
Name string `json:"name"`
// Quota in DB
Quota int `json:"quota"`
// Used quota in DB
UsedQuota int `json:"used_quota"`
}

// IOPSTier represents an IOPS tier
type IOPSTier struct {
ID string `json:"id"`
IOPSLimit string `json:"iops_limit"`
}

// BackupService represents the backup service for a solution
type BackupService struct {
Service string `json:"service"`
AccountName string `json:"account_name"`
Gateway string `json:"gateway"`
Port int `json:"port"`
}

// FailoverPlan represents a failover plan
type FailoverPlan struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"`
VMs struct {
Name string `json:"name"`
} `json:"vms"`
}

// ComputeResource represents compute resources for a solution
type ComputeResource struct {
ID string `json:"id"`
HardwarePlanID string `json:"hardware_plan_id"`
Memory struct {
// Used memory in GB
Used float32 `json:"used"`
// Memory limit in GB
Limit float32 `json:"limit"`
} `json:"memory"`
CPU struct {
Used int `json:"used"`
} `json:"cpu"`
Storage []struct {
Name string `json:"name"`
// Used storage in GB
Used int `json:"used"`
// Storage limit in GB
Limit int `json:"limit"`
} `json:"storage"`
}

// HardwarePlan represents a hardware plan
type HardwarePlan struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Limits struct {
Processor int `json:"processor"`
Memory int `json:"memory"`
} `json:"limits"`
Networks struct {
Public int `json:"public"`
Private int `json:"private"`
} `json:"networks"`
Storage struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"Type"`
Quota int `json:"quota"`
} `json:"storage"`
}

// Replica represents a replica
type Replica struct {
ID string `json:"id"`
Name string `json:"name"`
Platform string `json:"platform"`
CPU int `json:"cpu"`
RAM int `json:"ram"`
HDD int `json:"hdd"`
IOPS int `json:"iops"`
Power bool `json:"power"`
}

// BillingType represents a billing type
type BillingType struct {
ID string `json:"id"`
Type string `json:"type"`
}
124 changes: 124 additions & 0 deletions pkg/service/draas/model_paginated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pkg/service/draas/request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package draas

// PatchSolutionRequest represents a request to patch a solution
type PatchSolutionRequest struct {
Name string `json:"name,omitempty"`
IOPSTierID string `json:"iops_tier_id,omitempty"`
}

type ResetBackupServiceCredentialsRequest struct {
Password string `json:"password"`
}
Loading

0 comments on commit b839c32

Please sign in to comment.