Skip to content

Commit

Permalink
Orbital resources: bump API version from 2022-03-01 to 2022-11-01 (#2…
Browse files Browse the repository at this point in the history
…1405)

* Orbital resources: Change API version from 2022-03-01 to 2022-11-01

* Fix incorrect error
  • Loading branch information
jiaweitao001 authored Apr 17, 2023
1 parent cba118a commit f5c8bfc
Show file tree
Hide file tree
Showing 78 changed files with 138 additions and 352 deletions.
8 changes: 4 additions & 4 deletions internal/services/orbital/client/client.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package client

import (
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contact"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/groundstation"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/spacecraft"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contact"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/groundstation"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/services/orbital/contact_profile_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
Expand Down Expand Up @@ -145,7 +145,7 @@ func (r ContactProfileResource) Create() sdk.ResourceFunc {
Id: utils.String(id.ID()),
Location: model.Location,
Name: utils.String(model.Name),
Properties: &contactProfilesProperties,
Properties: contactProfilesProperties,
Tags: &model.Tags,
}

Expand Down Expand Up @@ -259,7 +259,7 @@ func (r ContactProfileResource) Update() sdk.ResourceFunc {
if metadata.ResourceData.HasChangesExcept("name", "resource_group_name") {
contactProfile := contactprofile.ContactProfile{
Location: state.Location,
Properties: &contactprofile.ContactProfilesProperties{
Properties: contactprofile.ContactProfilesProperties{
AutoTrackingConfiguration: &autoTrackingConfiguration,
EventHubUri: &state.EventHubUri,
Links: contactProfileLinks,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/orbital/contact_profile_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
26 changes: 9 additions & 17 deletions internal/services/orbital/contact_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contact"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/spacecraft"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contact"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -112,7 +112,7 @@ func (r ContactResource) Create() sdk.ResourceFunc {
}

contactProfile := contact.ResourceReference{
Id: &model.ContactProfileId,
Id: model.ContactProfileId,
}

contactProperties := contact.ContactsProperties{
Expand All @@ -125,7 +125,7 @@ func (r ContactResource) Create() sdk.ResourceFunc {
contact := contact.Contact{
Id: utils.String(id.ID()),
Name: utils.String(model.Name),
Properties: &contactProperties,
Properties: contactProperties,
}
if _, err = client.Create(ctx, id, contact); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
Expand Down Expand Up @@ -162,18 +162,10 @@ func (r ContactResource) Read() sdk.ResourceFunc {
Spacecraft: spacecraftId.ID(),
}

if props != nil {
state.ReservationStartTime = props.ReservationStartTime
state.ReservationEndTime = props.ReservationEndTime
state.GroundStationName = props.GroundStationName
if props.ContactProfile.Id != nil {
state.ContactProfileId = *props.ContactProfile.Id
} else {
return fmt.Errorf("contact profile id is missing %s", *id)
}
} else {
return fmt.Errorf("required properties are missing %s", *id)
}
state.ReservationStartTime = props.ReservationStartTime
state.ReservationEndTime = props.ReservationEndTime
state.GroundStationName = props.GroundStationName
state.ContactProfileId = props.ContactProfile.Id

return metadata.Encode(&state)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/orbital/contact_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contact"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contact"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
4 changes: 2 additions & 2 deletions internal/services/orbital/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package orbital
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/spacecraft"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
34 changes: 17 additions & 17 deletions internal/services/orbital/spacecraft_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/spacecraft"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
Expand Down Expand Up @@ -111,18 +111,18 @@ func (r SpacecraftResource) Create() sdk.ResourceFunc {
return fmt.Errorf("expanding `links`: %+v", err)
}
spacecraftProperties := spacecraft.SpacecraftsProperties{
Links: &links,
NoradId: model.NoradId,
TleLine1: &model.TwoLineElements[0],
TleLine2: &model.TwoLineElements[1],
TitleLine: &model.TitleLine,
Links: links,
NoradId: utils.String(model.NoradId),
TleLine1: model.TwoLineElements[0],
TleLine2: model.TwoLineElements[1],
TitleLine: model.TitleLine,
}

spacecraft := spacecraft.Spacecraft{
Id: utils.String(id.ID()),
Location: model.Location,
Name: utils.String(model.Name),
Properties: &spacecraftProperties,
Properties: spacecraftProperties,
Tags: &model.Tags,
}
if err = client.CreateOrUpdateThenPoll(ctx, id, spacecraft); err != nil {
Expand Down Expand Up @@ -154,19 +154,19 @@ func (r SpacecraftResource) Read() sdk.ResourceFunc {

if model := resp.Model; model != nil {
props := model.Properties
twoLineElements := []string{*props.TleLine1, *props.TleLine2}
twoLineElements := []string{props.TleLine1, props.TleLine2}
state := SpacecraftResourceModel{
Name: id.SpacecraftName,
ResourceGroup: id.ResourceGroupName,
Location: model.Location,
NoradId: props.NoradId,
NoradId: *props.NoradId,
TwoLineElements: twoLineElements,
TitleLine: *props.TitleLine,
TitleLine: props.TitleLine,
}
if model.Tags != nil {
state.Tags = *model.Tags
}
spacecraftLinks, err := flattenSpacecraftLinks(*props.Links)
spacecraftLinks, err := flattenSpacecraftLinks(props.Links)
if err != nil {
return err
}
Expand Down Expand Up @@ -227,12 +227,12 @@ func (r SpacecraftResource) Update() sdk.ResourceFunc {
if metadata.ResourceData.HasChangesExcept("name", "resource_group_name") {
spacecraft := spacecraft.Spacecraft{
Location: state.Location,
Properties: &spacecraft.SpacecraftsProperties{
Links: &spacecraftLinks,
NoradId: state.NoradId,
TitleLine: &state.TitleLine,
TleLine1: &state.TwoLineElements[0],
TleLine2: &state.TwoLineElements[1],
Properties: spacecraft.SpacecraftsProperties{
Links: spacecraftLinks,
NoradId: utils.String(state.NoradId),
TitleLine: state.TitleLine,
TleLine1: state.TwoLineElements[0],
TleLine2: state.TwoLineElements[1],
},
Tags: &state.Tags,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/orbital/spacecraft_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-03-01/spacecraft"
"github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit f5c8bfc

Please sign in to comment.