Skip to content

Commit

Permalink
Merge branch 'master' into domain/add_waiters_for_registar_api
Browse files Browse the repository at this point in the history
  • Loading branch information
jremy42 authored Feb 13, 2025
2 parents 86de12b + 428f1d2 commit 69ad007
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 62 deletions.
52 changes: 36 additions & 16 deletions api/applesilicon/v1alpha1/apple_silicon_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption
return server.(*Server), nil
}

func (s *API) WaitForPossibleDeletion(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) {
server, err := s.WaitForServer(&WaitForServerRequest{
ServerID: req.ServerID,
Zone: req.Zone,
Timeout: scw.TimeDurationPtr(defaultTimeout),
RetryInterval: scw.TimeDurationPtr(defaultRetryInterval),
}, opts...,
)
if err != nil {
return nil, errors.Wrap(err, "waiting for server failed")
}
timeToDelete := *server.DeletableAt
time.Sleep(time.Until(timeToDelete))
return server, nil
}

func (s *PrivateNetworkAPI) WaitForServerPrivateNetworks(req *WaitForServerRequest, opts ...scw.RequestOption) ([]*ServerPrivateNetwork, error) {
timeout := defaultTimeout
if req.Timeout != nil {
Expand Down Expand Up @@ -119,3 +103,39 @@ func (s *PrivateNetworkAPI) WaitForServerPrivateNetworks(req *WaitForServerReque

return serverPrivateNetworks.([]*ServerPrivateNetwork), nil
}

func (s *API) WaitForServerVPCOptionTerminalState(req *WaitForServerRequest, opts ...scw.RequestOption) error {
timeout := defaultTimeout
if req.Timeout != nil {
timeout = *req.Timeout
}
retryInterval := defaultRetryInterval
if req.RetryInterval != nil {
retryInterval = *req.RetryInterval
}

terminalStatus := map[ServerPrivateNetworkStatus]struct{}{
ServerPrivateNetworkStatusVpcEnabled: {},
ServerPrivateNetworkStatusVpcDisabled: {},
}
_, err := async.WaitSync(&async.WaitSyncConfig{
Get: func() (interface{}, bool, error) {
res, err := s.GetServer(&GetServerRequest{
ServerID: req.ServerID,
Zone: req.Zone,
}, opts...)
if err != nil {
return nil, false, err
}
_, isTerminal := terminalStatus[res.VpcStatus]

return res, isTerminal, nil
},
Timeout: timeout,
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
})
if err != nil {
return errors.Wrap(err, "waiting for vpc option terminal state failed")
}
return nil
}
21 changes: 15 additions & 6 deletions api/audit_trail/v1alpha1/audit_trail_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const (
ResourceTypeKubePool = ResourceType("kube_pool")
ResourceTypeKubeNode = ResourceType("kube_node")
ResourceTypeKubeACL = ResourceType("kube_acl")
ResourceTypeKeymKey = ResourceType("keym_key")
)

func (enum ResourceType) String() string {
Expand All @@ -105,6 +106,7 @@ func (enum ResourceType) Values() []ResourceType {
"kube_pool",
"kube_node",
"kube_acl",
"keym_key",
}
}

Expand All @@ -123,6 +125,10 @@ func (enum *ResourceType) UnmarshalJSON(data []byte) error {
return nil
}

// KeyManagerKeyInfo: key manager key info.
type KeyManagerKeyInfo struct {
}

// KubernetesACLInfo: kubernetes acl info.
type KubernetesACLInfo struct {
}
Expand Down Expand Up @@ -175,23 +181,26 @@ type Resource struct {

Name *string `json:"name"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
SecmSecretInfo *SecretManagerSecretInfo `json:"secm_secret_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
SecmSecretVersionInfo *SecretManagerSecretVersionInfo `json:"secm_secret_version_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
KubeClusterInfo *KubernetesClusterInfo `json:"kube_cluster_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
KubePoolInfo *KubernetesPoolInfo `json:"kube_pool_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
KubeNodeInfo *KubernetesNodeInfo `json:"kube_node_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo must be set.
// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
KubeACLInfo *KubernetesACLInfo `json:"kube_acl_info,omitempty"`

// Precisely one of SecmSecretInfo, SecmSecretVersionInfo, KubeClusterInfo, KubePoolInfo, KubeNodeInfo, KubeACLInfo, KeymKeyInfo must be set.
KeymKeyInfo *KeyManagerKeyInfo `json:"keym_key_info,omitempty"`
}

// ProductService: product service.
Expand Down
61 changes: 60 additions & 1 deletion api/cockpit/v1/cockpit_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,11 @@ type ContactPoint struct {
// Precisely one of Email must be set.
Email *ContactPointEmail `json:"email,omitempty"`

// Region: region to target. If none is passed will use default region from the config.
// Region: region.
Region scw.Region `json:"region"`

// ReceiveResolvedNotifications: send an email notification when an alert is marked as resolved.
ReceiveResolvedNotifications bool `json:"receive_resolved_notifications"`
}

// DataSource: Data source.
Expand Down Expand Up @@ -1076,6 +1079,9 @@ type RegionalAPICreateContactPointRequest struct {
// Email: email address of the contact point to create.
// Precisely one of Email must be set.
Email *ContactPointEmail `json:"email,omitempty"`

// ReceiveResolvedNotifications: send an email notification when an alert is marked as resolved.
ReceiveResolvedNotifications *bool `json:"receive_resolved_notifications,omitempty"`
}

// RegionalAPICreateDataSourceRequest: Create a data source.
Expand Down Expand Up @@ -1313,6 +1319,22 @@ type RegionalAPITriggerTestAlertRequest struct {
ProjectID string `json:"project_id"`
}

// RegionalAPIUpdateContactPointRequest: Update a contact point.
type RegionalAPIUpdateContactPointRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`

// ProjectID: ID of the Project containing the contact point to update.
ProjectID string `json:"project_id"`

// Email: email address of the contact point to update.
// Precisely one of Email must be set.
Email *ContactPointEmail `json:"email,omitempty"`

// ReceiveResolvedNotifications: enable or disable notifications when alert is resolved.
ReceiveResolvedNotifications *bool `json:"receive_resolved_notifications,omitempty"`
}

// RegionalAPIUpdateDataSourceRequest: Update a data source name.
type RegionalAPIUpdateDataSourceRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -2287,6 +2309,43 @@ func (s *RegionalAPI) ListContactPoints(req *RegionalAPIListContactPointsRequest
return &resp, nil
}

// UpdateContactPoint:
func (s *RegionalAPI) UpdateContactPoint(req *RegionalAPIUpdateContactPointRequest, opts ...scw.RequestOption) (*ContactPoint, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

if req.ProjectID == "" {
defaultProjectID, _ := s.client.GetDefaultProjectID()
req.ProjectID = defaultProjectID
}

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "PATCH",
Path: "/cockpit/v1/regions/" + fmt.Sprint(req.Region) + "/alert-manager/contact-points",
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp ContactPoint

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

// DeleteContactPoint: Delete a contact point associated with the default receiver.
func (s *RegionalAPI) DeleteContactPoint(req *RegionalAPIDeleteContactPointRequest, opts ...scw.RequestOption) error {
var err error
Expand Down
8 changes: 3 additions & 5 deletions api/instance/v1/instance_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ type IPType string

const (
IPTypeUnknownIptype = IPType("unknown_iptype")
IPTypeNat = IPType("nat")
IPTypeRoutedIPv4 = IPType("routed_ipv4")
IPTypeRoutedIPv6 = IPType("routed_ipv6")
)
Expand All @@ -223,7 +222,6 @@ func (enum IPType) String() string {
func (enum IPType) Values() []IPType {
return []IPType{
"unknown_iptype",
"nat",
"routed_ipv4",
"routed_ipv6",
}
Expand Down Expand Up @@ -2136,7 +2134,7 @@ type CreateIPRequest struct {
// Server: UUID of the Instance you want to attach the IP to.
Server *string `json:"server,omitempty"`

// Type: IP type to reserve (either 'routed_ipv4' or 'routed_ipv6', use of 'nat' is deprecated).
// Type: IP type to reserve (either 'routed_ipv4' or 'routed_ipv6').
// Default value: unknown_iptype
Type IPType `json:"type,omitempty"`
}
Expand Down Expand Up @@ -2837,7 +2835,7 @@ type ListIPsRequest struct {
// Page: a positive integer to choose the page to return.
Page *int32 `json:"-"`

// Type: filter on the IP Mobility IP type (whose value should be either 'routed_ipv4', 'routed_ipv6' or 'nat').
// Type: filter on the IP Mobility IP type (whose value should be either 'routed_ipv4' or 'routed_ipv6').
Type *string `json:"-"`
}

Expand Down Expand Up @@ -3587,7 +3585,7 @@ type UpdateIPRequest struct {
// Reverse: reverse domain name.
Reverse *NullableStringValue `json:"reverse,omitempty"`

// Type: convert a 'nat' IP to a 'routed_ipv4'.
// Type: should have no effect.
// Default value: unknown_iptype
Type IPType `json:"type,omitempty"`

Expand Down
4 changes: 4 additions & 0 deletions api/ipam/v1/ipam_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ const (
ResourceTypeMgdbInstance = ResourceType("mgdb_instance")
ResourceTypeAppleSiliconServer = ResourceType("apple_silicon_server")
ResourceTypeAppleSiliconPrivateNic = ResourceType("apple_silicon_private_nic")
ResourceTypeServerlessContainer = ResourceType("serverless_container")
ResourceTypeServerlessFunction = ResourceType("serverless_function")
)

func (enum ResourceType) String() string {
Expand Down Expand Up @@ -137,6 +139,8 @@ func (enum ResourceType) Values() []ResourceType {
"mgdb_instance",
"apple_silicon_server",
"apple_silicon_private_nic",
"serverless_container",
"serverless_function",
}
}

Expand Down
4 changes: 4 additions & 0 deletions api/ipam/v1alpha1/ipam_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ const (
ResourceTypeMgdbInstance = ResourceType("mgdb_instance")
ResourceTypeAppleSiliconServer = ResourceType("apple_silicon_server")
ResourceTypeAppleSiliconPrivateNic = ResourceType("apple_silicon_private_nic")
ResourceTypeServerlessContainer = ResourceType("serverless_container")
ResourceTypeServerlessFunction = ResourceType("serverless_function")
)

func (enum ResourceType) String() string {
Expand Down Expand Up @@ -137,6 +139,8 @@ func (enum ResourceType) Values() []ResourceType {
"mgdb_instance",
"apple_silicon_server",
"apple_silicon_private_nic",
"serverless_container",
"serverless_function",
}
}

Expand Down
2 changes: 2 additions & 0 deletions api/k8s/v1/k8s_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,8 @@ type ExternalNode struct {
NodeLabels map[string]string `json:"node_labels"`

NodeTaints []*ExternalNodeCoreV1Taint `json:"node_taints"`

IamToken string `json:"iam_token"`
}

// ExternalNodeAuth: external node auth.
Expand Down
Loading

0 comments on commit 69ad007

Please sign in to comment.