diff --git a/api/instance/v1/instance_sdk.go b/api/instance/v1/instance_sdk.go index c6e40ccf9..009d912f6 100644 --- a/api/instance/v1/instance_sdk.go +++ b/api/instance/v1/instance_sdk.go @@ -615,6 +615,8 @@ type Bootscript struct { Kernel string `json:"kernel"` // Organization: the bootscript organization Organization string `json:"organization"` + // Project: the bootscript project ID + Project string `json:"project"` // Public: provide information if the bootscript is public Public bool `json:"public"` // Title: the bootscript title @@ -787,6 +789,8 @@ type Image struct { // Default value: available State ImageState `json:"state"` + Project string `json:"project"` + Zone scw.Zone `json:"zone"` } @@ -878,6 +882,8 @@ type PlacementGroup struct { Name string `json:"name"` // Organization: the placement group organization Organization string `json:"organization"` + // Project: the placement group project ID + Project string `json:"project"` // PolicyMode: select the failling mode when the placement cannot be respected, either optional or enforced // // Default value: optional @@ -920,8 +926,12 @@ type SecurityGroup struct { OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy"` // Organization: the security groups organization ID Organization string `json:"organization"` + // Project: the project ID of the security group + Project string `json:"project"` // OrganizationDefault: true if it is your default security group for this organization OrganizationDefault bool `json:"organization_default"` + // ProjectDefault: true if it is your default security group for this project id + ProjectDefault bool `json:"project_default"` // CreationDate: the security group creation date CreationDate time.Time `json:"creation_date"` // ModificationDate: the security group modification date @@ -982,6 +992,8 @@ type Server struct { Name string `json:"name"` // Organization: the server organization Organization string `json:"organization"` + // Project: the server project ID + Project string `json:"project"` // AllowedActions: provide as list of allowed actions on the server AllowedActions []ServerAction `json:"allowed_actions"` // Tags: the server associated tags @@ -1166,6 +1178,8 @@ type Snapshot struct { ModificationDate time.Time `json:"modification_date"` + Project string `json:"project"` + Zone scw.Zone `json:"zone"` } @@ -1239,6 +1253,8 @@ type Volume struct { ModificationDate time.Time `json:"modification_date"` // Organization: the volumes organization Organization string `json:"organization"` + // Project: the volumes project ID + Project string `json:"project"` // Server: the server attached to the volume Server *ServerSummary `json:"server"` // State: the volumes state @@ -1275,6 +1291,8 @@ type VolumeTemplate struct { VolumeType VolumeVolumeType `json:"volume_type,omitempty"` // Organization: organization ID of the volume Organization string `json:"organization,omitempty"` + // Project: project ID of the volume + Project string `json:"project,omitempty"` } type VolumeType struct { @@ -1476,6 +1494,8 @@ type ListServersRequest struct { Page *int32 `json:"-"` // Organization: list only servers of this organization Organization *string `json:"-"` + // Project: list only servers of this project ID + Project *string `json:"-"` // Name: filter servers by name (for eg. "server1" will return "server100" and "server1" but not "foo") Name *string `json:"-"` // PrivateIP: list servers by private_ip @@ -1510,6 +1530,7 @@ func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (* parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) + parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "private_ip", req.PrivateIP) parameter.AddToQuery(query, "without_ip", req.WithoutIP) @@ -1581,7 +1602,11 @@ type CreateServerRequest struct { // Bootscript: the bootscript ID to use when `boot_type` is set to `bootscript` Bootscript *string `json:"bootscript,omitempty"` // Organization: the server organization ID - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` + // Project: the server project ID + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` // Tags: the server tags Tags []string `json:"tags,omitempty"` // SecurityGroup: the security group ID @@ -1594,9 +1619,14 @@ type CreateServerRequest struct { func (s *API) createServer(req *CreateServerRequest, opts ...scw.RequestOption) (*CreateServerResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -1718,6 +1748,8 @@ type setServerRequest struct { Name string `json:"name"` // Organization: the server organization Organization string `json:"organization"` + // Project: the server project ID + Project string `json:"project"` // AllowedActions: provide as list of allowed actions on the server AllowedActions []ServerAction `json:"allowed_actions"` // Tags: the server associated tags @@ -1775,6 +1807,11 @@ type setServerRequest struct { func (s *API) setServer(req *setServerRequest, opts ...scw.RequestOption) (*setServerResponse, error) { var err error + if req.Project == "" { + defaultProject, _ := s.client.GetDefaultProjectID() + req.Project = defaultProject + } + if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization @@ -2071,6 +2108,8 @@ type ListImagesRequest struct { Public *bool `json:"-"` Arch *string `json:"-"` + + Project *string `json:"-"` } // ListImages: list instance images @@ -2096,6 +2135,7 @@ func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*Li parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "public", req.Public) parameter.AddToQuery(query, "arch", req.Arch) + parameter.AddToQuery(query, "project", req.Project) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") @@ -2191,7 +2231,11 @@ type CreateImageRequest struct { // ExtraVolumes: additional volumes of the image ExtraVolumes map[string]*VolumeTemplate `json:"extra_volumes,omitempty"` // Organization: organization ID of the image - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` + // Project: project ID of the image + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` // Public: true to create a public image Public bool `json:"public,omitempty"` } @@ -2200,9 +2244,14 @@ type CreateImageRequest struct { func (s *API) CreateImage(req *CreateImageRequest, opts ...scw.RequestOption) (*CreateImageResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -2268,6 +2317,8 @@ type SetImageRequest struct { // // Default value: available State ImageState `json:"state"` + + Project string `json:"project"` } // setImage: update image @@ -2276,6 +2327,11 @@ type SetImageRequest struct { func (s *API) setImage(req *SetImageRequest, opts ...scw.RequestOption) (*setImageResponse, error) { var err error + if req.Project == "" { + defaultProject, _ := s.client.GetDefaultProjectID() + req.Project = defaultProject + } + if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization @@ -2362,6 +2418,8 @@ type ListSnapshotsRequest struct { Page *int32 `json:"-"` Name *string `json:"-"` + + Project *string `json:"-"` } // ListSnapshots: list snapshots @@ -2383,6 +2441,7 @@ func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "name", req.Name) + parameter.AddToQuery(query, "project", req.Project) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") @@ -2430,16 +2489,25 @@ type CreateSnapshotRequest struct { // VolumeID: UUID of the volume VolumeID string `json:"volume_id,omitempty"` - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` + + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` } // CreateSnapshot: create a snapshot from a given volume func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*CreateSnapshotResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -2539,6 +2607,8 @@ type SetSnapshotRequest struct { CreationDate time.Time `json:"creation_date"` ModificationDate time.Time `json:"modification_date"` + + Project string `json:"project"` } // setSnapshot: update snapshot @@ -2547,6 +2617,11 @@ type SetSnapshotRequest struct { func (s *API) setSnapshot(req *SetSnapshotRequest, opts ...scw.RequestOption) (*setSnapshotResponse, error) { var err error + if req.Project == "" { + defaultProject, _ := s.client.GetDefaultProjectID() + req.Project = defaultProject + } + if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization @@ -2637,6 +2712,8 @@ type ListVolumesRequest struct { Page *int32 `json:"-"` // Organization: filter volume by organization Organization *string `json:"-"` + // Project: filter volume by project ID + Project *string `json:"-"` // Name: filter volume by name (for eg. "vol" will return "myvolume" but not "data") Name *string `json:"-"` } @@ -2660,6 +2737,7 @@ func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (* parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) + parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { @@ -2706,7 +2784,8 @@ type CreateVolumeRequest struct { Name string `json:"name,omitempty"` - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` // VolumeType: // // Default value: l_ssd @@ -2720,15 +2799,23 @@ type CreateVolumeRequest struct { // Precisely one of BaseSnapshot, BaseVolume, Size must be set. BaseSnapshot *string `json:"base_snapshot,omitempty"` + + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` } // CreateVolume: create a volume func (s *API) CreateVolume(req *CreateVolumeRequest, opts ...scw.RequestOption) (*CreateVolumeResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -2893,6 +2980,8 @@ type ListSecurityGroupsRequest struct { Name *string `json:"-"` // Organization: the security group organization ID Organization *string `json:"-"` + // Project: the security group project ID + Project *string `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return // // Default value: 50 @@ -2920,6 +3009,7 @@ func (s *API) ListSecurityGroups(req *ListSecurityGroupsRequest, opts ...scw.Req query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization", req.Organization) + parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) @@ -2969,11 +3059,21 @@ type CreateSecurityGroupRequest struct { // Description: description of the security group Description string `json:"description,omitempty"` // Organization: organization the security group belongs to - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` + // Project: project ID the security group belong to + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` // OrganizationDefault: whether this security group becomes the default security group for new instances // // Default value: false - OrganizationDefault bool `json:"organization_default,omitempty"` + // Precisely one of OrganizationDefault, ProjectDefault must be set. + OrganizationDefault *bool `json:"organization_default,omitempty"` + // ProjectDefault: whether this security group becomes the default security group for new instances + // + // Default value: false + // Precisely one of OrganizationDefault, ProjectDefault must be set. + ProjectDefault *bool `json:"project_default,omitempty"` // Stateful: whether the security group is stateful or not // // Default value: false @@ -2992,9 +3092,14 @@ type CreateSecurityGroupRequest struct { func (s *API) CreateSecurityGroup(req *CreateSecurityGroupRequest, opts ...scw.RequestOption) (*CreateSecurityGroupResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -3136,6 +3241,10 @@ type setSecurityGroupRequest struct { Servers []*ServerSummary `json:"servers"` Stateful bool `json:"stateful"` + + Project string `json:"project"` + + ProjectDefault bool `json:"project_default"` } // setSecurityGroup: update a security group @@ -3144,6 +3253,11 @@ type setSecurityGroupRequest struct { func (s *API) setSecurityGroup(req *setSecurityGroupRequest, opts ...scw.RequestOption) (*setSecurityGroupResponse, error) { var err error + if req.Project == "" { + defaultProject, _ := s.client.GetDefaultProjectID() + req.Project = defaultProject + } + if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization @@ -3493,6 +3607,8 @@ type ListPlacementGroupsRequest struct { Page *int32 `json:"-"` // Organization: list only placement groups of this organization Organization *string `json:"-"` + // Project: list only placement groups of this project ID + Project *string `json:"-"` // Name: filter placement groups by name (for eg. "cluster1" will return "cluster100" and "cluster1" but not "foo") Name *string `json:"-"` } @@ -3517,6 +3633,7 @@ func (s *API) ListPlacementGroups(req *ListPlacementGroupsRequest, opts ...scw.R parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) + parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { @@ -3563,7 +3680,11 @@ type CreatePlacementGroupRequest struct { // Name: name of the placement group Name string `json:"name,omitempty"` - Organization string `json:"organization,omitempty"` + // Precisely one of Organization, Project must be set. + Organization *string `json:"organization,omitempty"` + + // Precisely one of Organization, Project must be set. + Project *string `json:"project,omitempty"` // PolicyMode: // // Default value: optional @@ -3580,9 +3701,14 @@ type CreatePlacementGroupRequest struct { func (s *API) CreatePlacementGroup(req *CreatePlacementGroupRequest, opts ...scw.RequestOption) (*CreatePlacementGroupResponse, error) { var err error - if req.Organization == "" { - defaultOrganization, _ := s.client.GetDefaultOrganizationID() - req.Organization = defaultOrganization + defaultProject, exist := s.client.GetDefaultProjectID() + if exist && req.Organization == nil && req.Project == nil { + req.Project = &defaultProject + } + + defaultOrganization, exist := s.client.GetDefaultOrganizationID() + if exist && req.Organization == nil && req.Project == nil { + req.Organization = &defaultOrganization } if req.Zone == "" { @@ -3674,6 +3800,8 @@ type SetPlacementGroupRequest struct { // // Default value: max_availability PolicyType PlacementGroupPolicyType `json:"policy_type"` + + Project string `json:"project"` } // SetPlacementGroup: set placement group @@ -3682,6 +3810,11 @@ type SetPlacementGroupRequest struct { func (s *API) SetPlacementGroup(req *SetPlacementGroupRequest, opts ...scw.RequestOption) (*SetPlacementGroupResponse, error) { var err error + if req.Project == "" { + defaultProject, _ := s.client.GetDefaultProjectID() + req.Project = defaultProject + } + if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization @@ -4328,6 +4461,8 @@ type GetDashboardRequest struct { Zone scw.Zone `json:"-"` Organization *string `json:"-"` + + Project *string `json:"-"` } func (s *API) GetDashboard(req *GetDashboardRequest, opts ...scw.RequestOption) (*GetDashboardResponse, error) { @@ -4340,6 +4475,7 @@ func (s *API) GetDashboard(req *GetDashboardRequest, opts ...scw.RequestOption) query := url.Values{} parameter.AddToQuery(query, "organization", req.Organization) + parameter.AddToQuery(query, "project", req.Project) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") diff --git a/api/instance/v1/instance_sdk_server_test.go b/api/instance/v1/instance_sdk_server_test.go index 8b07e65c6..717a14132 100644 --- a/api/instance/v1/instance_sdk_server_test.go +++ b/api/instance/v1/instance_sdk_server_test.go @@ -28,7 +28,7 @@ func TestServerUpdate(t *testing.T) { enableIPv6 = true bootType = BootTypeLocal tags = []string{"foo", "bar"} - organization = "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3" + project = "14d2f7ae-9775-414c-9bed-6810e060d500" ) t.Run("create server", func(t *testing.T) { @@ -36,12 +36,13 @@ func TestServerUpdate(t *testing.T) { createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, Name: name, - Organization: organization, + Project: &project, Image: image, EnableIPv6: enableIPv6, CommercialType: commercialType, Tags: tags, DynamicIPRequired: dynamicIPRequired, + BootType: &bootType, }) testhelpers.AssertNoError(t, err) serverID = createServerResponse.Server.ID @@ -53,7 +54,8 @@ func TestServerUpdate(t *testing.T) { } testhelpers.Equals(t, name, createServerResponse.Server.Name) - testhelpers.Equals(t, organization, createServerResponse.Server.Organization) + testhelpers.Equals(t, project, createServerResponse.Server.Project) + testhelpers.Equals(t, project, createServerResponse.Server.Organization) testhelpers.Equals(t, image, createServerResponse.Server.Image.ID) testhelpers.Equals(t, enableIPv6, createServerResponse.Server.EnableIPv6) testhelpers.Equals(t, bootType, createServerResponse.Server.BootType) @@ -62,6 +64,27 @@ func TestServerUpdate(t *testing.T) { testhelpers.Equals(t, *dynamicIPRequired, createServerResponse.Server.DynamicIPRequired) }) + t.Run("create server with orga (deprecated)", func(t *testing.T) { + // Create server + createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ + Zone: zone, + Name: name, + Organization: &project, + Image: image, + }) + testhelpers.AssertNoError(t, err) + + testhelpers.Equals(t, project, createServerResponse.Server.Project) + testhelpers.Equals(t, project, createServerResponse.Server.Organization) + + // Delete Server + err = instanceAPI.DeleteServer(&DeleteServerRequest{ + Zone: zone, + ServerID: createServerResponse.Server.ID, + }) + testhelpers.AssertNoError(t, err) + }) + t.Run("update server", func(t *testing.T) { var ( newName = "some_new_name_for_server" @@ -79,7 +102,8 @@ func TestServerUpdate(t *testing.T) { testhelpers.AssertNoError(t, err) // Initial values that are not altered in the above request should remaining the same - testhelpers.Equals(t, organization, updateServerResponse.Server.Organization) + testhelpers.Equals(t, project, updateServerResponse.Server.Project) + testhelpers.Equals(t, project, updateServerResponse.Server.Organization) testhelpers.Equals(t, image, updateServerResponse.Server.Image.ID) testhelpers.Equals(t, enableIPv6, updateServerResponse.Server.EnableIPv6) testhelpers.Equals(t, bootType, updateServerResponse.Server.BootType) diff --git a/api/instance/v1/instance_utils_test.go b/api/instance/v1/instance_utils_test.go index eb685a882..09caf0189 100644 --- a/api/instance/v1/instance_utils_test.go +++ b/api/instance/v1/instance_utils_test.go @@ -18,22 +18,22 @@ func TestInstanceHelpers(t *testing.T) { instanceAPI := NewAPI(client) var ( - serverID string - ipID string - volumeID string - zone = scw.ZoneFrPar1 - organization = "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3" - image = "f974feac-abae-4365-b988-8ec7d1cec10d" - reverse = &NullableStringValue{Value: "1.1.1.1"} - nullReverse = &NullableStringValue{Null: true} + serverID string + ipID string + volumeID string + zone = scw.ZoneFrPar1 + project = "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3" + image = "f974feac-abae-4365-b988-8ec7d1cec10d" + reverse = &NullableStringValue{Value: "1.1.1.1"} + nullReverse = &NullableStringValue{Null: true} ) t.Run("create server", func(t *testing.T) { createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ - Zone: zone, - Name: "instance_utils_test", - Organization: organization, - Image: image, + Zone: zone, + Name: "instance_utils_test", + Project: &project, + Image: image, }) testhelpers.AssertNoError(t, err) serverID = createServerResponse.Server.ID @@ -45,8 +45,8 @@ func TestInstanceHelpers(t *testing.T) { t.Run("test ip related functions", func(t *testing.T) { // Create IP createIPResponse, err := instanceAPI.CreateIP(&CreateIPRequest{ - Zone: zone, - Organization: &organization, + Zone: zone, + Project: &project, }) testhelpers.AssertNoError(t, err) ipID = createIPResponse.IP.ID diff --git a/api/instance/v1/security_group_utils.go b/api/instance/v1/security_group_utils.go index 250df5df2..1645c54ec 100644 --- a/api/instance/v1/security_group_utils.go +++ b/api/instance/v1/security_group_utils.go @@ -18,6 +18,7 @@ type UpdateSecurityGroupRequest struct { OutboundDefaultPolicy *SecurityGroupPolicy `json:"outbound_default_policy,omitempty"` Stateful *bool `json:"stateful,omitempty"` OrganizationDefault *bool `json:"organization_default,omitempty"` + ProjectDefault *bool `json:"project_default,omitempty"` } type UpdateSecurityGroupResponse struct { @@ -54,7 +55,9 @@ func (s *API) UpdateSecurityGroup(req *UpdateSecurityGroupRequest, opts ...scw.R Name: getSGResponse.SecurityGroup.Name, Description: getSGResponse.SecurityGroup.Description, Organization: getSGResponse.SecurityGroup.Organization, + Project: getSGResponse.SecurityGroup.Project, OrganizationDefault: getSGResponse.SecurityGroup.OrganizationDefault, + ProjectDefault: getSGResponse.SecurityGroup.ProjectDefault, OutboundDefaultPolicy: getSGResponse.SecurityGroup.OutboundDefaultPolicy, InboundDefaultPolicy: getSGResponse.SecurityGroup.InboundDefaultPolicy, Stateful: getSGResponse.SecurityGroup.Stateful, @@ -84,6 +87,9 @@ func (s *API) UpdateSecurityGroup(req *UpdateSecurityGroupRequest, opts ...scw.R if req.OrganizationDefault != nil { setRequest.OrganizationDefault = *req.OrganizationDefault } + if req.ProjectDefault != nil { + setRequest.ProjectDefault = *req.ProjectDefault + } setRes, err := s.setSecurityGroup(setRequest, opts...) if err != nil { diff --git a/api/instance/v1/security_group_utils_test.go b/api/instance/v1/security_group_utils_test.go index 0e0ef08c8..fd1a516e7 100644 --- a/api/instance/v1/security_group_utils_test.go +++ b/api/instance/v1/security_group_utils_test.go @@ -19,8 +19,8 @@ func TestAPI_UpdateSecurityGroup(t *testing.T) { instanceAPI := NewAPI(client) var ( - zone = scw.ZoneFrPar1 - organization = "b3ba839a-dcf2-4b0a-ac81-fc32370052a0" + zone = scw.ZoneFrPar1 + project = "b3ba839a-dcf2-4b0a-ac81-fc32370052a0" ) createResponse, err := instanceAPI.CreateSecurityGroup(&CreateSecurityGroupRequest{ @@ -30,7 +30,7 @@ func TestAPI_UpdateSecurityGroup(t *testing.T) { Stateful: true, InboundDefaultPolicy: SecurityGroupPolicyAccept, OutboundDefaultPolicy: SecurityGroupPolicyDrop, - Organization: organization, + Project: &project, }) testhelpers.AssertNoError(t, err) @@ -47,7 +47,7 @@ func TestAPI_UpdateSecurityGroup(t *testing.T) { InboundDefaultPolicy: &drop, OutboundDefaultPolicy: &accept, // Keep false here, switch it to true is too dangerous for the one who update the test cassette. - OrganizationDefault: scw.BoolPtr(false), + ProjectDefault: scw.BoolPtr(false), }) testhelpers.AssertNoError(t, err) @@ -56,6 +56,7 @@ func TestAPI_UpdateSecurityGroup(t *testing.T) { testhelpers.Equals(t, SecurityGroupPolicyDrop, updateResponse.SecurityGroup.InboundDefaultPolicy) testhelpers.Equals(t, SecurityGroupPolicyAccept, updateResponse.SecurityGroup.OutboundDefaultPolicy) testhelpers.Equals(t, false, updateResponse.SecurityGroup.Stateful) + testhelpers.Equals(t, false, updateResponse.SecurityGroup.ProjectDefault) testhelpers.Equals(t, false, updateResponse.SecurityGroup.OrganizationDefault) err = instanceAPI.DeleteSecurityGroup(&DeleteSecurityGroupRequest{ @@ -75,8 +76,8 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) { instanceAPI := NewAPI(client) var ( - zone = scw.ZoneFrPar1 - organization = "b3ba839a-dcf2-4b0a-ac81-fc32370052a0" + zone = scw.ZoneFrPar1 + project = "b3ba839a-dcf2-4b0a-ac81-fc32370052a0" ) bootstrap := func(t *testing.T) (*SecurityGroup, *SecurityGroupRule, func()) { @@ -87,7 +88,7 @@ func TestAPI_UpdateSecurityGroupRule(t *testing.T) { Stateful: true, InboundDefaultPolicy: SecurityGroupPolicyAccept, OutboundDefaultPolicy: SecurityGroupPolicyDrop, - Organization: organization, + Project: &project, }) testhelpers.AssertNoError(t, err) diff --git a/api/instance/v1/server_utils_test.go b/api/instance/v1/server_utils_test.go index b35d4de31..5360f433e 100644 --- a/api/instance/v1/server_utils_test.go +++ b/api/instance/v1/server_utils_test.go @@ -49,7 +49,7 @@ func TestAPI_ServerUserData(t *testing.T) { CommercialType: "DEV1-S", Name: namegenerator.GetRandomName("srv"), Image: "f974feac-abae-4365-b988-8ec7d1cec10d", - Organization: "14d2f7ae-9775-414c-9bed-6810e060d500", + Project: scw.StringPtr("14d2f7ae-9775-414c-9bed-6810e060d500"), }) testhelpers.AssertNoError(t, err) @@ -88,7 +88,7 @@ func TestAPI_AllServerUserData(t *testing.T) { CommercialType: "DEV1-S", Name: namegenerator.GetRandomName("srv"), Image: "f974feac-abae-4365-b988-8ec7d1cec10d", - Organization: "14d2f7ae-9775-414c-9bed-6810e060d500", + Project: scw.StringPtr("14d2f7ae-9775-414c-9bed-6810e060d500"), }) testhelpers.AssertNoError(t, err) diff --git a/api/instance/v1/testdata/server-test.yaml b/api/instance/v1/testdata/server-test.yaml index 8ce009034..07fe8163f 100644 --- a/api/instance/v1/testdata/server-test.yaml +++ b/api/instance/v1/testdata/server-test.yaml @@ -2,71 +2,182 @@ version: 1 interactions: - request: - body: '{"name":"instance_sdk_server_test","dynamic_ip_required":true,"commercial_type":"START1-S","image":"f974feac-abae-4365-b988-8ec7d1cec10d","enable_ipv6":true,"organization":"d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3","tags":["foo","bar"]}' + body: '{"name":"instance_sdk_server_test","dynamic_ip_required":true,"commercial_type":"START1-S","image":"f974feac-abae-4365-b988-8ec7d1cec10d","enable_ipv6":true,"boot_type":"local","project":"14d2f7ae-9775-414c-9bed-6810e060d500","tags":["foo","bar"]}' form: {} headers: Content-Type: - application/json User-Agent: - - scaleway-sdk-go/0.0.0 + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: - body: '{"server": {"allowed_actions": ["poweron", "backup"], "maintenances": [], - "state_detail": "", "image": {"creation_date": "2019-03-05T10:13:15.974944+00:00", - "default_bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "from_server": null, "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", - "root_volume": {"size": 10000000000, "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", - "volume_type": "l_ssd", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, - "name": "Ubuntu Bionic Beaver", "modification_date": "2019-03-05T13:32:29.274319+00:00", - "state": "available", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", - "extra_volumes": {}, "public": true}, "creation_date": "2019-05-23T15:49:32.273002+00:00", - "public_ip": null, "private_ip": null, "id": "781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb", - "dynamic_ip_required": true, "modification_date": "2019-05-23T15:49:32.632361+00:00", - "enable_ipv6": true, "hostname": "instance-sdk-server-test", "state": "stopped", - "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "location": null, "boot_type": "local", "ipv6": null, "commercial_type": - "START1-S", "tags": ["foo", "bar"], "arch": "x86_64", "extra_networks": [], - "compute_cluster": null, "name": "instance_sdk_server_test", "protected": false, - "volumes": {"0": {"size": 50000000000, "state": "available", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", - "modification_date": "2019-05-23T15:49:32.560489+00:00", "organization": "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3", - "export_uri": null, "creation_date": "2019-05-23T15:49:32.273002+00:00", "id": - "d3f8260f-8715-484d-8269-34b4ae16f9db", "volume_type": "l_ssd", "server": {"id": - "781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb", "name": "instance_sdk_server_test"}}}, - "security_group": {"id": "9f073e03-5511-4863-ae23-9cb0deb82426", "name": "Default - security group"}, "organization": "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3"}}' + body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "instance_sdk_server_test", + "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": + "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", + "hostname": "instance-sdk-server-test", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", + "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": + "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": + "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", + "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", + "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": + "fr-par-1"}, "volumes": {"0": {"id": "c6b29ca6-8895-42fb-a498-a89011c29ff7", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", + "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", + "name": "instance_sdk_server_test"}, "size": 50000000000, "state": "available", + "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:02.990859+00:00", + "zone": "fr-par-1"}}, "tags": ["foo", "bar"], "state": "stopped", "protected": + false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": + [], "dynamic_ip_required": true, "enable_ipv6": true, "private_ip": null, "creation_date": + "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:03.095139+00:00", + "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, + "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": + "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", + "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": + ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": + "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - - "2737" + - "3112" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - - Thu, 23 May 2019 15:49:32 GMT + - Fri, 14 Aug 2020 13:02:02 GMT Location: - - https://cp-par1.scaleway.com/servers/781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb + - https://cp-par1.scaleway.com/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 Server: - - scaleway_api + - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY + X-Request-Id: + - ec8ac5f5-cbda-4d28-92b7-76365f6dcc97 status: 201 Created code: 201 duration: "" +- request: + body: '{"name":"instance_sdk_server_test","image":"f974feac-abae-4365-b988-8ec7d1cec10d","organization":"14d2f7ae-9775-414c-9bed-6810e060d500"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers + method: POST + response: + body: '{"server": {"id": "12be8295-263f-4f71-9c7d-a33ef31f3887", "name": "instance_sdk_server_test", + "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "bootscript", + "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", + "hostname": "instance-sdk-server-test", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", + "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": + "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": + "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", + "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", + "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": + "fr-par-1"}, "volumes": {"0": {"id": "a7f56913-ba01-42b7-9d88-f12d42ea309b", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", + "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "12be8295-263f-4f71-9c7d-a33ef31f3887", + "name": "instance_sdk_server_test"}, "size": 50000000000, "state": "available", + "creation_date": "2020-08-14T13:02:03.527628+00:00", "modification_date": "2020-08-14T13:02:03.845180+00:00", + "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": + "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": + true, "enable_ipv6": false, "private_ip": null, "creation_date": "2020-08-14T13:02:03.527628+00:00", + "modification_date": "2020-08-14T13:02:03.928001+00:00", "bootscript": {"id": + "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline + 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", + "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", + "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": + ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": + "fr-par-1"}}' + headers: + Cache-Control: + - no-cache + Content-Length: + - "3106" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 14 Aug 2020 13:02:03 GMT + Location: + - https://cp-par1.scaleway.com/servers/12be8295-263f-4f71-9c7d-a33ef31f3887 + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f12de65b-8e0e-402d-bdfe-8c76b7837d8d + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/12be8295-263f-4f71-9c7d-a33ef31f3887 + method: DELETE + response: + body: "" + headers: + Cache-Control: + - no-cache + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 14 Aug 2020 13:02:04 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f0a5c1f4-25a5-4273-8df5-2bf73062bea1 + status: 204 No Content + code: 204 + duration: "" - request: body: '{"name":"some_new_name_for_server","tags":[]}' form: {} @@ -74,60 +185,66 @@ interactions: Content-Type: - application/json User-Agent: - - scaleway-sdk-go/0.0.0 - url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: PATCH response: - body: '{"server": {"allowed_actions": ["poweron", "backup"], "maintenances": [], - "state_detail": "", "image": {"creation_date": "2019-03-05T10:13:15.974944+00:00", - "default_bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "from_server": null, "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", - "root_volume": {"size": 10000000000, "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", - "volume_type": "l_ssd", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, - "name": "Ubuntu Bionic Beaver", "modification_date": "2019-03-05T13:32:29.274319+00:00", - "state": "available", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", - "extra_volumes": {}, "public": true}, "creation_date": "2019-05-23T15:49:32.273002+00:00", - "public_ip": null, "private_ip": null, "id": "781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb", - "dynamic_ip_required": true, "modification_date": "2019-05-23T15:49:32.827811+00:00", - "enable_ipv6": true, "hostname": "some-new-name-for-server", "state": "stopped", - "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "location": null, "boot_type": "local", "ipv6": null, "commercial_type": - "START1-S", "tags": [], "arch": "x86_64", "extra_networks": [], "compute_cluster": - null, "name": "some_new_name_for_server", "protected": false, "volumes": {"0": - {"size": 50000000000, "state": "available", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", - "modification_date": "2019-05-23T15:49:32.560489+00:00", "organization": "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3", - "export_uri": null, "creation_date": "2019-05-23T15:49:32.273002+00:00", "id": - "d3f8260f-8715-484d-8269-34b4ae16f9db", "volume_type": "l_ssd", "server": {"id": - "781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb", "name": "some_new_name_for_server"}}}, - "security_group": {"id": "9f073e03-5511-4863-ae23-9cb0deb82426", "name": "Default - security group"}, "organization": "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3"}}' + body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "some_new_name_for_server", + "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": + "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", + "hostname": "some-new-name-for-server", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", + "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": + "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": + "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", + "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", + "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": + "fr-par-1"}, "volumes": {"0": {"id": "c6b29ca6-8895-42fb-a498-a89011c29ff7", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", + "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", + "name": "some_new_name_for_server"}, "size": 50000000000, "state": "available", + "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:02.990859+00:00", + "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": + "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": + true, "enable_ipv6": true, "private_ip": null, "creation_date": "2020-08-14T13:02:02.652219+00:00", + "modification_date": "2020-08-14T13:02:04.847138+00:00", "bootscript": {"id": + "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline + 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", + "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", + "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": + ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": + "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - - "2725" + - "3100" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - - Thu, 23 May 2019 15:49:32 GMT + - Fri, 14 Aug 2020 13:02:04 GMT Server: - - scaleway_api + - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY + X-Request-Id: + - 10bdaf49-c624-42a6-8523-2fa6ecdf9409 status: 200 OK code: 200 duration: "" @@ -138,55 +255,60 @@ interactions: Content-Type: - application/json User-Agent: - - scaleway-sdk-go/0.0.0 - url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: PATCH response: - body: '{"server": {"allowed_actions": ["poweron", "backup"], "maintenances": [], - "state_detail": "", "image": {"creation_date": "2019-03-05T10:13:15.974944+00:00", - "default_bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "from_server": null, "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", - "root_volume": {"size": 10000000000, "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", - "volume_type": "l_ssd", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, - "name": "Ubuntu Bionic Beaver", "modification_date": "2019-03-05T13:32:29.274319+00:00", - "state": "available", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", - "extra_volumes": {}, "public": true}, "creation_date": "2019-05-23T15:49:32.273002+00:00", - "public_ip": null, "private_ip": null, "id": "781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb", - "dynamic_ip_required": true, "modification_date": "2019-05-23T15:49:32.827811+00:00", - "enable_ipv6": true, "hostname": "some-new-name-for-server", "state": "stopped", - "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", - "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": - false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": - "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": - "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", - "public": false}, "location": null, "boot_type": "local", "ipv6": null, "commercial_type": - "START1-S", "tags": [], "arch": "x86_64", "extra_networks": [], "compute_cluster": - null, "name": "some_new_name_for_server", "protected": false, "volumes": {}, - "security_group": {"id": "9f073e03-5511-4863-ae23-9cb0deb82426", "name": "Default - security group"}, "organization": "d429f6a1-c0a6-48cf-8b5a-1f9dfe76ffd3"}}' + body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "some_new_name_for_server", + "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": + "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", + "hostname": "some-new-name-for-server", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", + "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", + "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", + "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": + "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": + "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": + "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", + "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", + "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", + "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": + "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, + "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": + true, "enable_ipv6": true, "private_ip": null, "creation_date": "2020-08-14T13:02:02.652219+00:00", + "modification_date": "2020-08-14T13:02:04.847138+00:00", "bootscript": {"id": + "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline + 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", + "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", + "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", + "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": + false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", + "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": + ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": + "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - - "2253" + - "2557" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - - Thu, 23 May 2019 15:49:33 GMT + - Fri, 14 Aug 2020 13:02:04 GMT Server: - - scaleway_api + - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY + X-Request-Id: + - b5c48b57-5bd7-419a-ace2-a5f4348a6691 status: 200 OK code: 200 duration: "" @@ -195,8 +317,8 @@ interactions: form: {} headers: User-Agent: - - scaleway-sdk-go/0.0.0 - url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/781d9e3a-be7e-4d8a-9a6d-a8f15703d8fb + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: DELETE response: body: "" @@ -208,15 +330,17 @@ interactions: Content-Type: - application/json Date: - - Thu, 23 May 2019 15:49:33 GMT + - Fri, 14 Aug 2020 13:02:05 GMT Server: - - scaleway_api + - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY + X-Request-Id: + - 45a4d549-f633-4d1c-a08c-d7a0039fdfe5 status: 204 No Content code: 204 duration: "" @@ -225,8 +349,8 @@ interactions: form: {} headers: User-Agent: - - scaleway-sdk-go/0.0.0 - url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/d3f8260f-8715-484d-8269-34b4ae16f9db + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) + url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/c6b29ca6-8895-42fb-a498-a89011c29ff7 method: DELETE response: body: "" @@ -238,15 +362,17 @@ interactions: Content-Type: - application/json Date: - - Thu, 23 May 2019 15:49:33 GMT + - Fri, 14 Aug 2020 13:02:05 GMT Server: - - scaleway_api + - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY + X-Request-Id: + - caf7c95e-21e8-4e6e-8679-e632096c6cac status: 204 No Content code: 204 duration: "" diff --git a/api/instance/v1/volume_utils_test.go b/api/instance/v1/volume_utils_test.go index b80e9c553..5e67236d1 100644 --- a/api/instance/v1/volume_utils_test.go +++ b/api/instance/v1/volume_utils_test.go @@ -19,7 +19,7 @@ func TestUpdateVolume(t *testing.T) { var ( zone = scw.ZoneFrPar1 - organization = "951df375-e094-4d26-97c1-ba548eeb9c42" + project = "951df375-e094-4d26-97c1-ba548eeb9c42" volumeName = "test volume" volumeSize = 20 * scw.GB volumeType = VolumeVolumeTypeLSSD @@ -30,11 +30,11 @@ func TestUpdateVolume(t *testing.T) { // Create volume createVolumeResponse, err := instanceAPI.CreateVolume(&CreateVolumeRequest{ - Zone: zone, - Name: volumeName, - Organization: organization, - Size: &volumeSize, - VolumeType: volumeType, + Zone: zone, + Name: volumeName, + Project: &project, + Size: &volumeSize, + VolumeType: volumeType, }) testhelpers.AssertNoError(t, err)