Skip to content

Commit

Permalink
Merge pull request #48 from alrayyes/chore/update-documentation
Browse files Browse the repository at this point in the history
feat: implement region.location field
  • Loading branch information
alrayyes authored Aug 27, 2024
2 parents ab2b15c + 39c3342 commit 0a42c4e
Show file tree
Hide file tree
Showing 44 changed files with 1,115 additions and 589 deletions.
44 changes: 40 additions & 4 deletions docs/data-sources/public_cloud_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Read-Only:
- `private_network` (Attributes) (see [below for nested schema](#nestedatt--instances--private_network))
- `product_type` (String) The product type
- `reference` (String) The identifying name set to the instance
- `region` (String) The region where the instance was launched
- `region` (Attributes) (see [below for nested schema](#nestedatt--instances--region))
- `resources` (Attributes) Available resources (see [below for nested schema](#nestedatt--instances--resources))
- `root_disk_size` (Number) The root disk's size in GB. Must be at least 5 GB for Linux and FreeBSD instances and 50 GB for Windows instances
- `root_disk_storage_type` (String) The root disk's storage type
Expand All @@ -65,7 +65,7 @@ Read-Only:
- `maximum_amount` (Number) Only for "CPU_BASED" auto scaling group. The maximum number of instances that can be running
- `minimum_amount` (Number) The minimum number of instances that should be running
- `reference` (String) The identifying name set to the auto scaling group
- `region` (String) The region in which the Auto Scaling Group was launched
- `region` (Attributes) (see [below for nested schema](#nestedatt--instances--auto_scaling_group--region))
- `starts_at` (String) Only for "SCHEDULED" auto scaling group. Date and time (UTC) that the instances need to be launched
- `state` (String) The Auto Scaling Group's current state.
- `type` (String) Auto Scaling Group type
Expand All @@ -83,7 +83,7 @@ Read-Only:
- `load_balancer_configuration` (Attributes) (see [below for nested schema](#nestedatt--instances--auto_scaling_group--load_balancer--load_balancer_configuration))
- `private_network` (Attributes) (see [below for nested schema](#nestedatt--instances--auto_scaling_group--load_balancer--private_network))
- `reference` (String) The identifying name set to the load balancer
- `region` (String) The region where the load balancer was launched into
- `region` (Attributes) (see [below for nested schema](#nestedatt--instances--auto_scaling_group--load_balancer--region))
- `resources` (Attributes) Available resources (see [below for nested schema](#nestedatt--instances--auto_scaling_group--load_balancer--resources))
- `started_at` (String) Date and time when the load balancer was started for the first time, right after launching it
- `state` (String) The load balancers current state
Expand Down Expand Up @@ -170,6 +170,15 @@ Read-Only:
- `subnet` (String)


<a id="nestedatt--instances--auto_scaling_group--load_balancer--region"></a>
### Nested Schema for `instances.auto_scaling_group.load_balancer.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)


<a id="nestedatt--instances--auto_scaling_group--load_balancer--resources"></a>
### Nested Schema for `instances.auto_scaling_group.load_balancer.resources`

Expand Down Expand Up @@ -323,6 +332,15 @@ Read-Only:



<a id="nestedatt--instances--auto_scaling_group--region"></a>
### Nested Schema for `instances.auto_scaling_group.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)



<a id="nestedatt--instances--contract"></a>
### Nested Schema for `instances.contract`
Expand Down Expand Up @@ -351,14 +369,23 @@ Read-Only:
- `id` (String) Image ID
- `market_apps` (List of String)
- `name` (String)
- `region` (String)
- `region` (Attributes) (see [below for nested schema](#nestedatt--instances--image--region))
- `state` (String)
- `state_reason` (String)
- `storage_size` (Attributes) (see [below for nested schema](#nestedatt--instances--image--storage_size))
- `storage_types` (List of String) The supported storage types
- `updated_at` (String)
- `version` (String)

<a id="nestedatt--instances--image--region"></a>
### Nested Schema for `instances.image.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)


<a id="nestedatt--instances--image--storage_size"></a>
### Nested Schema for `instances.image.storage_size`

Expand Down Expand Up @@ -412,6 +439,15 @@ Read-Only:
- `subnet` (String)


<a id="nestedatt--instances--region"></a>
### Nested Schema for `instances.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)


<a id="nestedatt--instances--resources"></a>
### Nested Schema for `instances.resources`

Expand Down
53 changes: 47 additions & 6 deletions docs/resources/public_cloud_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ resource "leaseweb_public_cloud_instance" "example" {
image = {
id = "UBUNTU_22_04_64BIT"
}
reference = "my webserver"
region = "eu-west-3"
reference = "my webserver"
region = {
name = "eu-west-3"
}
root_disk_storage_type = "CENTRAL"
type = {
name = "lsw.m3.large"
Expand All @@ -39,7 +41,7 @@ resource "leaseweb_public_cloud_instance" "example" {

- `contract` (Attributes) (see [below for nested schema](#nestedatt--contract))
- `image` (Attributes) (see [below for nested schema](#nestedatt--image))
- `region` (String) Region to launch the instance into.**WARNING!** Changing this value once running will cause this instance to be destroyed and a new one to be created.
- `region` (Attributes) (see [below for nested schema](#nestedatt--region))
- `root_disk_storage_type` (String) The root disk's storage type.**WARNING!** Changing this value once running will cause this instance to be destroyed and a new one to be created.
- `type` (Attributes) (see [below for nested schema](#nestedatt--type))

Expand Down Expand Up @@ -97,14 +99,23 @@ Read-Only:
- `flavour` (String)
- `market_apps` (List of String)
- `name` (String)
- `region` (String)
- `region` (Attributes) (see [below for nested schema](#nestedatt--image--region))
- `state` (String)
- `state_reason` (String)
- `storage_size` (Attributes) (see [below for nested schema](#nestedatt--image--storage_size))
- `storage_types` (List of String) The supported storage types for the instance type
- `updated_at` (String)
- `version` (String)

<a id="nestedatt--image--region"></a>
### Nested Schema for `image.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)


<a id="nestedatt--image--storage_size"></a>
### Nested Schema for `image.storage_size`

Expand All @@ -115,6 +126,18 @@ Read-Only:



<a id="nestedatt--region"></a>
### Nested Schema for `region`

Required:

- `name` (String) **WARNING!** Changing this value once running will cause this instance to be destroyed and a new one to be created.

Read-Only:

- `location` (String) The city where the region is located


<a id="nestedatt--type"></a>
### Nested Schema for `type`

Expand Down Expand Up @@ -238,7 +261,7 @@ Read-Only:
- `maximum_amount` (Number) Only for "CPU_BASED" auto scaling group. The maximum number of instances that can be running
- `minimum_amount` (Number) The minimum number of instances that should be running
- `reference` (String) The identifying name set to the auto scaling group
- `region` (String) The region in which the Auto Scaling Group was launched
- `region` (Attributes) (see [below for nested schema](#nestedatt--auto_scaling_group--region))
- `starts_at` (String) Only for "SCHEDULED" auto scaling group. Date and time (UTC) that the instances need to be launched
- `state` (String) The Auto Scaling Group's current state.
- `type` (String) Auto Scaling Group type
Expand All @@ -256,7 +279,7 @@ Read-Only:
- `load_balancer_configuration` (Attributes) (see [below for nested schema](#nestedatt--auto_scaling_group--load_balancer--load_balancer_configuration))
- `private_network` (Attributes) (see [below for nested schema](#nestedatt--auto_scaling_group--load_balancer--private_network))
- `reference` (String) The identifying name set to the load balancer
- `region` (String) The region where the load balancer was launched into
- `region` (Attributes) (see [below for nested schema](#nestedatt--auto_scaling_group--load_balancer--region))
- `resources` (Attributes) Available resources (see [below for nested schema](#nestedatt--auto_scaling_group--load_balancer--resources))
- `started_at` (String) Date and time when the load balancer was started for the first time, right after launching it
- `state` (String) The load balancers current state
Expand Down Expand Up @@ -343,6 +366,15 @@ Read-Only:
- `subnet` (String)


<a id="nestedatt--auto_scaling_group--load_balancer--region"></a>
### Nested Schema for `auto_scaling_group.load_balancer.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)


<a id="nestedatt--auto_scaling_group--load_balancer--resources"></a>
### Nested Schema for `auto_scaling_group.load_balancer.resources`

Expand Down Expand Up @@ -496,6 +528,15 @@ Read-Only:



<a id="nestedatt--auto_scaling_group--region"></a>
### Nested Schema for `auto_scaling_group.region`

Read-Only:

- `location` (String) The city where the region is located
- `name` (String)



<a id="nestedatt--ips"></a>
### Nested Schema for `ips`
Expand Down
6 changes: 4 additions & 2 deletions examples/resources/leaseweb_public_cloud_instance/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ resource "leaseweb_public_cloud_instance" "example" {
image = {
id = "UBUNTU_22_04_64BIT"
}
reference = "my webserver"
region = "eu-west-3"
reference = "my webserver"
region = {
name = "eu-west-3"
}
root_disk_storage_type = "CENTRAL"
type = {
name = "lsw.m3.large"
Expand Down
4 changes: 2 additions & 2 deletions internal/core/domain/public_cloud/auto_scaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type AutoScalingGroup struct {
Id string
Type enum.AutoScalingGroupType
State enum.AutoScalingGroupState
Region string
Region Region
Reference value_object.AutoScalingGroupReference
CreatedAt time.Time
UpdatedAt time.Time
Expand Down Expand Up @@ -42,7 +42,7 @@ func NewAutoScalingGroup(
id string,
autoScalingGroupType enum.AutoScalingGroupType,
state enum.AutoScalingGroupState,
region string,
region Region,
reference value_object.AutoScalingGroupReference,
createdAt time.Time,
updatedAt time.Time,
Expand Down
11 changes: 6 additions & 5 deletions internal/core/domain/public_cloud/auto_scaling_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ func TestNewAutoScalingGroup(t *testing.T) {
createdAt := time.Now()
updatedAt := time.Now()
reference, _ := value_object.NewAutoScalingGroupReference("reference")
region := Region{Name: "region"}

got := NewAutoScalingGroup(
"id",
enum.AutoScalingGroupTypeCpuBased,
enum.AutoScalingGroupStateScaling,
"region",
region,
*reference,
createdAt,
updatedAt,
Expand All @@ -28,7 +29,7 @@ func TestNewAutoScalingGroup(t *testing.T) {
assert.Equal(t, "id", got.Id)
assert.Equal(t, enum.AutoScalingGroupTypeCpuBased, got.Type)
assert.Equal(t, enum.AutoScalingGroupStateScaling, got.State)
assert.Equal(t, "region", got.Region)
assert.Equal(t, region, got.Region)
assert.Equal(t, "reference", got.Reference.String())
assert.Equal(t, createdAt, got.CreatedAt)
assert.Equal(t, updatedAt, got.UpdatedAt)
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestNewAutoScalingGroup(t *testing.T) {
"",
enum.AutoScalingGroupTypeCpuBased,
enum.AutoScalingGroupStateScaling,
"region",
Region{},
*reference,
time.Now(),
time.Now(),
Expand All @@ -73,7 +74,7 @@ func TestNewAutoScalingGroup(t *testing.T) {
CpuThreshold: &cpuThreshold,
WarmupTime: &WarmupTime,
CoolDownTime: &CoolDownTime,
LoadBalancer: &LoadBalancer{Region: "loadBalancerRegion"},
LoadBalancer: &LoadBalancer{Region: Region{Name: "loadBalancerRegion"}},
})

assert.Equal(t, desiredAmount, *got.DesiredAmount)
Expand All @@ -84,7 +85,7 @@ func TestNewAutoScalingGroup(t *testing.T) {
assert.Equal(t, cpuThreshold, *got.CpuThreshold)
assert.Equal(t, WarmupTime, *got.WarmupTime)
assert.Equal(t, CoolDownTime, *got.CooldownTime)
assert.Equal(t, "loadBalancerRegion", got.LoadBalancer.Region)
assert.Equal(t, Region{Name: "loadBalancerRegion"}, got.LoadBalancer.Region)
})

}
4 changes: 2 additions & 2 deletions internal/core/domain/public_cloud/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Image struct {
Architecture *string
State *string
StateReason *string
Region *string
Region *Region
CreatedAt *time.Time
UpdatedAt *time.Time
Custom bool
Expand All @@ -31,7 +31,7 @@ func NewImage(
architecture *string,
State *string,
stateReason *string,
region *string,
region *Region,
createdAt *time.Time,
updatedAt *time.Time,
custom bool,
Expand Down
5 changes: 2 additions & 3 deletions internal/core/domain/public_cloud/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
func TestNewImage(t *testing.T) {
state := "state"
stateReason := "stateReason"
region := "region"
createdAt := time.Now()
updatedAt := time.Now()
storageSize := StorageSize{Unit: "unit"}
Expand All @@ -26,7 +25,7 @@ func TestNewImage(t *testing.T) {
&architecture,
&state,
&stateReason,
&region,
&Region{Name: "region"},
&createdAt,
&updatedAt,
false,
Expand All @@ -43,7 +42,7 @@ func TestNewImage(t *testing.T) {
Architecture: &architecture,
State: &state,
StateReason: &stateReason,
Region: &region,
Region: &Region{Name: "region"},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
Custom: false,
Expand Down
6 changes: 3 additions & 3 deletions internal/core/domain/public_cloud/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ReasonInstanceCannotBeTerminated string

type Instance struct {
Id string
Region string
Region Region
Reference *string
StartedAt *time.Time
Resources Resources
Expand Down Expand Up @@ -99,7 +99,7 @@ type OptionalUpdateInstanceValues struct {
// NewInstance creates a new instance with all supported options.
func NewInstance(
id string,
region string,
region Region,
resources Resources,
image Image,
state enum.State,
Expand Down Expand Up @@ -160,7 +160,7 @@ func NewCreateInstance(
}

instance := Instance{
Region: region,
Region: Region{Name: region},
Type: InstanceType{Name: instanceType},
RootDiskStorageType: rootDiskStorageType,
Image: Image{Id: imageId},
Expand Down
Loading

0 comments on commit 0a42c4e

Please sign in to comment.