Skip to content

Commit

Permalink
feat(objsto): add custom domains support
Browse files Browse the repository at this point in the history
  • Loading branch information
kangasta committed Sep 4, 2024
1 parent ea556df commit 8bab751
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions upcloud/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,7 @@ type LoadBalancerNodeNetwork struct {
type LoadBalancerFrontendNetwork struct {
Name string `json:"name,omitempty"`
}

type LoadBalancerDNSChallengeDomain struct {
Domain string `json:"domain"`
}
5 changes: 5 additions & 0 deletions upcloud/managed_object_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,8 @@ type ManagedObjectStorageMetrics struct {
TotalObjects int `json:"total_objects"`
TotalSizeBytes int `json:"total_size_bytes"`
}

type ManagedObjectStorageCustomDomain struct {
DomainName string `json:"domain_name"`
Type string `json:"type"`
}
7 changes: 7 additions & 0 deletions upcloud/request/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,10 @@ func (r *ModifyLoadBalancerNetworkRequest) RequestURL() string {
func (r *ModifyLoadBalancerNetworkRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(r.Network)
}

// GetLoadBalancerDNSChallengeDomainRequest represents a request to get domain for DNS challenge
type GetLoadBalancerDNSChallengeDomainRequest struct{}

func (r *GetLoadBalancerDNSChallengeDomainRequest) RequestURL() string {
return "load-balancer/certificate-bundles/dns-challenge-domain"
}
44 changes: 44 additions & 0 deletions upcloud/request/managed_object_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,50 @@ func (r *DetachManagedObjectStorageUserPolicyRequest) RequestURL() string {
return fmt.Sprintf("%s/%s/users/%s/policies/%s", managedObjectStorageBasePath, r.ServiceUUID, r.Username, r.Name)
}

// CreateManagedObjectStorageCustomDomainRequest represents a request for creating a policy
type CreateManagedObjectStorageCustomDomainRequest struct {
DomainName string `json:"domain_name"`
Type string `json:"type"`
ServiceUUID string `json:"-"`
}

// RequestURL implements the Request interface
func (r *CreateManagedObjectStorageCustomDomainRequest) RequestURL() string {
return fmt.Sprintf("%s/%s/custom-domains", managedObjectStorageBasePath, r.ServiceUUID)
}

// GetManagedObjectStorageCustomDomainsRequest represents a request for retrieving policies
type GetManagedObjectStorageCustomDomainsRequest struct {
ServiceUUID string `json:"-"`
}

// RequestURL implements the Request interface
func (r *GetManagedObjectStorageCustomDomainsRequest) RequestURL() string {
return fmt.Sprintf("%s/%s/custom-domains", managedObjectStorageBasePath, r.ServiceUUID)
}

// GetManagedObjectStorageCustomDomainRequest represents a request for retrieving details about a policy
type GetManagedObjectStorageCustomDomainRequest struct {
DomainName string `json:"-"`
ServiceUUID string `json:"-"`
}

// RequestURL implements the Request interface
func (r *GetManagedObjectStorageCustomDomainRequest) RequestURL() string {
return fmt.Sprintf("%s/%s/custom-domains/%s", managedObjectStorageBasePath, r.ServiceUUID, r.DomainName)
}

// DeleteManagedObjectStorageCustomDomainRequest represents a request to delete a policy
type DeleteManagedObjectStorageCustomDomainRequest struct {
ServiceUUID string `json:"-"`
DomainName string `json:"-"`
}

// RequestURL implements the Request interface
func (r *DeleteManagedObjectStorageCustomDomainRequest) RequestURL() string {
return fmt.Sprintf("%s/%s/custom-domains/%s", managedObjectStorageBasePath, r.ServiceUUID, r.DomainName)
}

// WaitForManagedObjectStorageOperationalStateRequest represents a request to wait for a Managed Object Storage service
// to enter a desired state
type WaitForManagedObjectStorageOperationalStateRequest struct {
Expand Down
6 changes: 6 additions & 0 deletions upcloud/service/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type LoadBalancer interface {
DeleteLoadBalancerCertificateBundle(ctx context.Context, r *request.DeleteLoadBalancerCertificateBundleRequest) error
// Networks
ModifyLoadBalancerNetwork(ctx context.Context, r *request.ModifyLoadBalancerNetworkRequest) (*upcloud.LoadBalancerNetwork, error)
GetLoadBalancerDNSChallengeDomain(ctx context.Context, r *request.GetLoadBalancerDNSChallengeDomainRequest) (*upcloud.LoadBalancerDNSChallengeDomain, error)
}

// GetLoadBalancers retrieves a list of load balancers.
Expand Down Expand Up @@ -422,3 +423,8 @@ func (s *Service) ModifyLoadBalancerNetwork(ctx context.Context, r *request.Modi
n := upcloud.LoadBalancerNetwork{}
return &n, s.modify(ctx, r, &n)
}

func (s *Service) GetLoadBalancerDNSChallengeDomain(ctx context.Context, r *request.GetLoadBalancerDNSChallengeDomainRequest) (*upcloud.LoadBalancerDNSChallengeDomain, error) {
var domain upcloud.LoadBalancerDNSChallengeDomain
return &domain, s.get(ctx, r.RequestURL(), &domain)
}
22 changes: 22 additions & 0 deletions upcloud/service/managed_object_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ type ManagedObjectStorage interface {
AttachManagedObjectStorageUserPolicy(ctx context.Context, r *request.AttachManagedObjectStorageUserPolicyRequest) error
GetManagedObjectStorageUserPolicies(ctx context.Context, r *request.GetManagedObjectStorageUserPoliciesRequest) ([]upcloud.ManagedObjectStorageUserPolicy, error)
DetachManagedObjectStorageUserPolicy(ctx context.Context, r *request.DetachManagedObjectStorageUserPolicyRequest) error
CreateManagedObjectStorageCustomDomain(ctx context.Context, r *request.CreateManagedObjectStorageCustomDomainRequest) error
GetManagedObjectStorageCustomDomains(ctx context.Context, r *request.GetManagedObjectStorageCustomDomainsRequest) ([]upcloud.ManagedObjectStorageCustomDomain, error)
GetManagedObjectStorageCustomDomain(ctx context.Context, r *request.GetManagedObjectStorageCustomDomainRequest) (*upcloud.ManagedObjectStorageCustomDomain, error)
DeleteManagedObjectStorageCustomDomain(ctx context.Context, r *request.DeleteManagedObjectStorageCustomDomainRequest) error
WaitForManagedObjectStorageOperationalState(ctx context.Context, r *request.WaitForManagedObjectStorageOperationalStateRequest) (*upcloud.ManagedObjectStorage, error)
WaitForManagedObjectStorageDeletion(ctx context.Context, r *request.WaitForManagedObjectStorageDeletionRequest) error
}
Expand Down Expand Up @@ -187,6 +191,24 @@ func (s *Service) DetachManagedObjectStorageUserPolicy(ctx context.Context, r *r
return s.delete(ctx, r)
}

func (s *Service) CreateManagedObjectStorageCustomDomain(ctx context.Context, r *request.CreateManagedObjectStorageCustomDomainRequest) error {
return s.create(ctx, r, nil)
}

func (s *Service) GetManagedObjectStorageCustomDomains(ctx context.Context, r *request.GetManagedObjectStorageCustomDomainsRequest) ([]upcloud.ManagedObjectStorageCustomDomain, error) {
domains := make([]upcloud.ManagedObjectStorageCustomDomain, 0)
return domains, s.get(ctx, r.RequestURL(), &domains)
}

func (s *Service) GetManagedObjectStorageCustomDomain(ctx context.Context, r *request.GetManagedObjectStorageCustomDomainRequest) (*upcloud.ManagedObjectStorageCustomDomain, error) {
domain := upcloud.ManagedObjectStorageCustomDomain{}
return &domain, s.get(ctx, r.RequestURL(), &domain)
}

func (s *Service) DeleteManagedObjectStorageCustomDomain(ctx context.Context, r *request.DeleteManagedObjectStorageCustomDomainRequest) error {
return s.delete(ctx, r)
}

// WaitForManagedObjectStorageOperationalState blocks execution until the specified Managed Object Storage service
// has entered the specified state. If the state changes favorably, service details is returned. The method will give up
// after the specified timeout
Expand Down

0 comments on commit 8bab751

Please sign in to comment.