Skip to content

Commit

Permalink
Revert "fix(LH-72951): Handle FTD license update (#107)" (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
weilueluo authored Nov 21, 2023
1 parent af16243 commit 8c5a448
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 692 deletions.
10 changes: 4 additions & 6 deletions client/device/cloudfmc/fmcappliance/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
type UpdateInput struct {
FmcApplianceUid string
QueueTriggerState string
StateMachineContext *map[string]string
StateMachineContext map[string]string
}

func NewUpdateInput(FmcApplianceUid, queueTriggerState string, stateMachineContext *map[string]string) UpdateInput {
func NewUpdateInput(FmcApplianceUid, queueTriggerState string, stateMachineContext map[string]string) UpdateInput {
return UpdateInput{
FmcApplianceUid: FmcApplianceUid,
QueueTriggerState: queueTriggerState,
Expand All @@ -27,17 +27,15 @@ type UpdateOutput struct {
}

type updateRequestBody struct {
QueueTriggerState string `json:"queueTriggerState"`
StateMachineContext *map[string]string `json:"stateMachineContext,omitempty"`
Uid string `json:"uid,omitempty"`
QueueTriggerState string `json:"queueTriggerState"`
StateMachineContext map[string]string `json:"stateMachineContext"`
}

func Update(ctx context.Context, client http.Client, updateInp UpdateInput) (*UpdateOutput, error) {
updateUrl := url.UpdateFmcAppliance(client.BaseUrl(), updateInp.FmcApplianceUid)
updateBody := newUpdateRequestBodyBuilder().
QueueTriggerState(updateInp.QueueTriggerState).
StateMachineContext(updateInp.StateMachineContext).
Uid(updateInp.FmcApplianceUid).
Build()
req := client.NewPut(ctx, updateUrl, updateBody)
var updateOup UpdateOutput
Expand Down
2 changes: 1 addition & 1 deletion client/device/cloudfmc/fmcappliance/update_inputbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (b *UpdateInputBuilder) QueueTriggerState(queueTriggerState string) *Update
return b
}

func (b *UpdateInputBuilder) StateMachineContext(stateMachineContext *map[string]string) *UpdateInputBuilder {
func (b *UpdateInputBuilder) StateMachineContext(stateMachineContext map[string]string) *UpdateInputBuilder {
b.updateInput.StateMachineContext = stateMachineContext
return b
}
Expand Down
7 changes: 1 addition & 6 deletions client/device/cloudfmc/fmcappliance/update_outputbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ func (b *updateRequestBodyBuilder) QueueTriggerState(queueTriggerState string) *
return b
}

func (b *updateRequestBodyBuilder) StateMachineContext(stateMachineContext *map[string]string) *updateRequestBodyBuilder {
func (b *updateRequestBodyBuilder) StateMachineContext(stateMachineContext map[string]string) *updateRequestBodyBuilder {
b.updateRequestBody.StateMachineContext = stateMachineContext
return b
}

func (b *updateRequestBodyBuilder) Uid(uid string) *updateRequestBodyBuilder {
b.updateRequestBody.Uid = uid
return b
}

func (b *updateRequestBodyBuilder) Build() updateRequestBody {
return *b.updateRequestBody
}
4 changes: 2 additions & 2 deletions client/device/cloudfmc/fmcappliance/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestUpdate(t *testing.T) {
}{
{
testName: "successfully updates FMC Appliance name",
input: fmcappliance.NewUpdateInput(fmcApplianceUid, queueTriggerState, &stateMachineContext),
input: fmcappliance.NewUpdateInput(fmcApplianceUid, queueTriggerState, stateMachineContext),

setupFunc: func() {
httpmock.RegisterResponder(
Expand All @@ -50,7 +50,7 @@ func TestUpdate(t *testing.T) {

{
testName: "error when update FMC Appliance name error",
input: fmcappliance.NewUpdateInput(fmcApplianceUid, queueTriggerState, &stateMachineContext),
input: fmcappliance.NewUpdateInput(fmcApplianceUid, queueTriggerState, stateMachineContext),

setupFunc: func() {
httpmock.RegisterResponder(
Expand Down
43 changes: 0 additions & 43 deletions client/device/cloudfmc/fmcplatform/read_devicelicenses.go

This file was deleted.

This file was deleted.

50 changes: 0 additions & 50 deletions client/device/cloudfmc/fmcplatform/update_devicelicenses.go

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions client/device/cloudfmc/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ func NewReadInput() ReadInput {

type ReadOutput = device.ReadOutput

var NewReadOutputBuilder = device.NewReadOutputBuilder

func Read(ctx context.Context, client http.Client, readInp ReadInput) (*ReadOutput, error) {

client.Logger.Println("reading cloud FMC")
Expand Down
12 changes: 4 additions & 8 deletions client/device/cloudfmc/readspecific.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/device"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/internal/http"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/model/statemachine"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/model/statemachine/state"
)

Expand All @@ -13,11 +12,10 @@ type ReadSpecificInput struct {
}

type ReadSpecificOutput struct {
SpecificUid string `json:"uid"`
DomainUid string `json:"domainUid"`
State state.Type `json:"state"`
Status string `json:"status"`
StateMachineDetails statemachine.Details `json:"stateMachineDetails"`
SpecificUid string `json:"uid"`
DomainUid string `json:"domainUid"`
State state.Type `json:"state"`
Status string `json:"status"`
}

func NewReadSpecificInput(fmcId string) ReadSpecificInput {
Expand All @@ -28,8 +26,6 @@ func NewReadSpecificInput(fmcId string) ReadSpecificInput {

func ReadSpecific(ctx context.Context, client http.Client, inp ReadSpecificInput) (*ReadSpecificOutput, error) {

client.Logger.Println("reading Cloud FMC specific")

req := device.NewReadSpecificRequest(ctx, client, *device.NewReadSpecificInput(inp.FmcId))

var readSpecificOutp ReadSpecificOutput
Expand Down
25 changes: 0 additions & 25 deletions client/device/cloudfmc/retry.go

This file was deleted.

2 changes: 1 addition & 1 deletion client/device/cloudftd/cloudftdonboarding/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Create(ctx context.Context, client http.Client, createInp CreateInput) (*Cr

// 3.1 read ftd metadata
// 3.1.5 handle license
licenseCaps, err := license.StringToCdoLicenses(readFtdOutp.Metadata.LicenseCaps)
licenseCaps, err := license.DeserializeAllFromCdo(readFtdOutp.Metadata.LicenseCaps)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion client/device/cloudftd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func Create(ctx context.Context, client http.Client, createInp CreateInput) (*Cr
Metadata: &Metadata{
AccessPolicyName: selectedPolicy.Name,
AccessPolicyUid: selectedPolicy.Id,
LicenseCaps: license.LicensesToString(*createInp.Licenses),
LicenseCaps: license.SerializeAllAsCdo(*createInp.Licenses),
PerformanceTier: performanceTier,
},
State: "NEW",
Expand Down
2 changes: 1 addition & 1 deletion client/device/cloudftd/create_metadatabuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (b *MetadataBuilder) GeneratedCommand(generatedCommand string) *MetadataBui
}

func (b *MetadataBuilder) LicenseCaps(licenseCaps *[]license.Type) *MetadataBuilder {
b.metadata.LicenseCaps = license.LicensesToString(*licenseCaps)
b.metadata.LicenseCaps = license.SerializeAllAsCdo(*licenseCaps)
return b
}

Expand Down
2 changes: 1 addition & 1 deletion client/device/cloudftd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Delete(ctx context.Context, client http.Client, deleteInp DeleteInput) (*De
fmcappliance.NewUpdateInputBuilder().
FmcApplianceUid(fmcReadSpecificRes.SpecificUid).
QueueTriggerState("PENDING_DELETE_FTDC").
StateMachineContext(&map[string]string{"ftdCDeviceIDs": deleteInp.Uid}).
StateMachineContext(map[string]string{"ftdCDeviceIDs": deleteInp.Uid}).
Build(),
)
if err != nil {
Expand Down
Loading

0 comments on commit 8c5a448

Please sign in to comment.