Skip to content

Commit

Permalink
add sanity check to configlet create/update public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Jan 24, 2025
1 parent dac05c4 commit 76dba50
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apstra/two_stage_l3_clos_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,25 @@ func (o *TwoStageL3ClosClient) ImportConfigletById(ctx context.Context, cid Obje
// CreateConfiglet creates a configlet described by a TwoStageL3ClosConfigletData structure
// in a blueprint.
func (o *TwoStageL3ClosClient) CreateConfiglet(ctx context.Context, c *TwoStageL3ClosConfigletData) (ObjectId, error) {
if c.Data == nil {
return "", errors.New("cannot create configlet with nil data")
}
if len(c.Data.RefArchs) != 0 {
return "", errors.New("RefArchs not permitted when creating configlet")
}

return o.createConfiglet(ctx, c)
}

// UpdateConfiglet updates a configlet imported into a blueprint.
func (o *TwoStageL3ClosClient) UpdateConfiglet(ctx context.Context, id ObjectId, c *TwoStageL3ClosConfigletData) error {
if c.Data == nil {
return errors.New("cannot update configlet with nil data")
}
if len(c.Data.RefArchs) != 0 {
return errors.New("RefArchs not permitted when updating configlet")
}

return o.updateConfiglet(ctx, id, c)
}

Expand Down

0 comments on commit 76dba50

Please sign in to comment.