Skip to content

Commit

Permalink
rename ApstraClientErr -> ClientErr
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Aug 21, 2023
1 parent 540627d commit 42e2468
Show file tree
Hide file tree
Showing 34 changed files with 103 additions and 103 deletions.
10 changes: 5 additions & 5 deletions apstra/api_blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (o *Client) getBlueprintIdByName(ctx context.Context, name string) (ObjectI
for i, bps := range blueprintStatuses {
if bps.Label == name {
if found > 0 {
return "", ApstraClientErr{
return "", ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("multiple blueprints have name '%s'", name),
}
Expand All @@ -320,7 +320,7 @@ func (o *Client) getBlueprintIdByName(ctx context.Context, name string) (ObjectI
if found >= 0 {
return blueprintStatuses[found].Id, nil
}
return "", ApstraClientErr{
return "", ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("found %d blueprints but one named '%s' wasn't among them", len(blueprintStatuses), name),
}
Expand Down Expand Up @@ -369,7 +369,7 @@ func (o *Client) getBlueprintStatus(ctx context.Context, id ObjectId) (*rawBluep
return &bps, nil
}
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("found %d blueprints but one with id '%s' wasn't among them", len(blueprintStatuses), id),
}
Expand Down Expand Up @@ -403,14 +403,14 @@ func (o *Client) getBlueprintStatusByName(ctx context.Context, desired string) (

switch len(blueprintStatuses) {
case 0:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("blueprint with name '%s' not found", desired),
}
case 1:
return &blueprintStatuses[0], nil
default:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("multiple blueprints with name '%s' found", desired),
}
Expand Down
4 changes: 2 additions & 2 deletions apstra/api_design_configlets.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (o *Client) getConfigletByName(ctx context.Context, name string) (*rawConfi
for i, configlet := range configlets {
if configlet.DisplayName == name {
if foundIdx >= 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("multiple Configlets have name %q", name),
}
Expand All @@ -209,7 +209,7 @@ func (o *Client) getConfigletByName(ctx context.Context, name string) (*rawConfi
return &configlets[foundIdx], nil
}

return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no Configlet with name '%s' found", name),
}
Expand Down
4 changes: 2 additions & 2 deletions apstra/api_design_interface_maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ func (o *Client) getInterfaceMapByName(ctx context.Context, desired string) (*ra
}
switch len(interfaceMaps) {
case 0:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no interface map named '%s' found", desired),
}
case 1:
return &interfaceMaps[0], nil
default:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple interface maps named '%s' found", desired),
}
Expand Down
4 changes: 2 additions & 2 deletions apstra/api_design_logical_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (o *Client) getLogicalDeviceByName(ctx context.Context, name string) (*Logi
_ = foo
if ld.Data.DisplayName == name {
if found {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple logical devices named '%s' found", name),
}
Expand All @@ -461,7 +461,7 @@ func (o *Client) getLogicalDeviceByName(ctx context.Context, name string) (*Logi
if found {
return &result, nil
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no logical device named '%s' found", name),
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/api_design_logical_devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestGetLogicalDeviceByName(t *testing.T) {
test := logicalDevices[i]
log.Printf("testing GetLogicalDeviceByName(%s) against %s %s (%s)", test.Data.DisplayName, client.clientType, clientName, client.client.ApiVersion())
logicalDevice, err := client.client.GetLogicalDeviceByName(context.TODO(), test.Data.DisplayName)
var ace ApstraClientErr
var ace ClientErr
if err != nil {
if !(errors.As(err, &ace) && ace.Type() == ErrMultipleMatch) {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion apstra/api_design_rack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ func (o *Client) getRackTypeByName(ctx context.Context, name string) (*RackType,
return &rackType, nil
}
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("rack type with name '%s' not found", name),
}
Expand Down
4 changes: 2 additions & 2 deletions apstra/api_design_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (o *Client) getTagByLabel(ctx context.Context, label string) (*rawDesignTag
}
}

return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("tag with label '%s' not found", label),
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (o *Client) getTagsByLabels(ctx context.Context, labels []string) ([]rawDes
if tag, ok := allTagsMap[requestedLabel]; ok {
result = append(result, tag)
} else {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("tag with label '%s' not found", requestedLabel),
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/api_design_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCreateTagCollision(t *testing.T) {
}
_ = client.client.deleteTag(context.Background(), id1)

var ace ApstraClientErr
var ace ClientErr
if errors.As(err, &ace) && ace.errType == ErrExists { // this is the error we want
continue
}
Expand Down
14 changes: 7 additions & 7 deletions apstra/api_design_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ func (o *Client) getRackBasedTemplate(ctx context.Context, id ObjectId) (*rawTem
}

if tType != templateTypeRackBased {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrWrongType,
err: fmt.Errorf("template '%s' is of type '%s', not '%s'", id, tType, templateTypeRackBased),
}
Expand Down Expand Up @@ -1192,7 +1192,7 @@ func (o *Client) getPodBasedTemplate(ctx context.Context, id ObjectId) (*rawTemp
}

if tType != templateTypePodBased {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrWrongType,
err: fmt.Errorf("template '%s' is of type '%s', not '%s'", id, tType, templateTypePodBased),
}
Expand Down Expand Up @@ -1269,7 +1269,7 @@ func (o *Client) getTemplateByTypeAndName(ctx context.Context, desiredType templ
}

if found != nil { // multiple matches!
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple %s templates named '%s'", desiredType, desiredName),
}
Expand All @@ -1280,7 +1280,7 @@ func (o *Client) getTemplateByTypeAndName(ctx context.Context, desiredType templ
}

if found == nil { // not found!
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no %s templates named '%s'", desiredType, desiredName),
}
Expand All @@ -1301,7 +1301,7 @@ func (o *Client) getL3CollapsedTemplate(ctx context.Context, id ObjectId) (*rawT
}

if tType != templateTypeL3Collapsed {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrWrongType,
err: fmt.Errorf("template '%s' is of type '%s', not '%s'", id, tType, templateTypeL3Collapsed),
}
Expand Down Expand Up @@ -1701,7 +1701,7 @@ func (o *Client) getTemplateIdTypeByName(ctx context.Context, desired string) (O

switch len(idToType) {
case 0:
return "", -1, ApstraClientErr{
return "", -1, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("template named '%s' not found", desired),
}
Expand All @@ -1710,7 +1710,7 @@ func (o *Client) getTemplateIdTypeByName(ctx context.Context, desired string) (O
return k, v, nil
}
}
return "", -1, ApstraClientErr{
return "", -1, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple templates named '%s'", desired),
}
Expand Down
14 changes: 7 additions & 7 deletions apstra/api_device_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (o *PortInfo) Transformation(desired int) (*Transformation, error) {
return &t, nil
}
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("transform id %d not found", desired),
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func (o *Transformation) Interface(desired int) (*TransformInterface, error) {
return &intf, nil
}
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("interface %d not found in transformation", desired),
}
Expand Down Expand Up @@ -305,14 +305,14 @@ func (o *DeviceProfileData) PortByInterfaceName(desired string) (*PortInfo, erro
ports := o.PortsByInterfaceName(desired)
switch len(ports) {
case 0:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no port matching name '%s' could be found", desired),
}
case 1:
return &ports[0], nil
default:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("multiple ports matching name '%s' found", desired),
}
Expand All @@ -325,7 +325,7 @@ func (o *DeviceProfileData) PortById(desired int) (*PortInfo, error) {
return &portInfo, nil
}
}
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no port with ID %d found", desired),
}
Expand Down Expand Up @@ -474,14 +474,14 @@ func (o *Client) getDeviceProfileByName(ctx context.Context, desired string) (*r
}
switch len(deviceProfiles) {
case 0:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no device profile named '%s' found", desired),
}
case 1:
return &deviceProfiles[0], nil
default:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple device profiles named '%s'", desired),
}
Expand Down
4 changes: 2 additions & 2 deletions apstra/api_property_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (o *Client) getPropertySetByLabel(ctx context.Context, label string) (*rawP
}

if len(propertySets) > 1 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("found multiple (%d) property sets with label %q", len(propertySets), label),
}
Expand All @@ -117,7 +117,7 @@ func (o *Client) getPropertySetsByLabel(ctx context.Context, label string) ([]ra
}

if len(result) == 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("property set with label '%s' not found", label),
}
Expand Down
12 changes: 6 additions & 6 deletions apstra/api_resources_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (o *Client) getAsnPoolByName(ctx context.Context, desired string) (*AsnPool
for i, pool := range pools {
if pool.DisplayName == desired {
if found >= 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("name '%s' does not uniquely identify an ASN pool", desired),
}
Expand All @@ -86,7 +86,7 @@ func (o *Client) getAsnPoolByName(ctx context.Context, desired string) (*AsnPool
}
}
if found < 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("pool named '%s' not found", desired),
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (o *Client) getIntPoolByName(ctx context.Context, desired string) (*rawIntP
for i, pool := range pools {
if pool.DisplayName == desired {
if found >= 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("name '%s' does not uniquely identify an Integer Pool", desired),
}
Expand All @@ -140,7 +140,7 @@ func (o *Client) getIntPoolByName(ctx context.Context, desired string) (*rawIntP
}
}
if found < 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("pool named '%s' not found", desired),
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func (o *Client) getVniPoolByName(ctx context.Context, desired string) (*VniPool
for i, pool := range pools {
if pool.DisplayName == desired {
if found >= 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("name '%s' does not uniquely identify an VNI pool", desired),
}
Expand All @@ -215,7 +215,7 @@ func (o *Client) getVniPoolByName(ctx context.Context, desired string) (*VniPool
}
}
if found < 0 {
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("pool named '%s' not found", desired),
}
Expand Down
6 changes: 3 additions & 3 deletions apstra/api_resources_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ func (o *Client) getIpPoolByName(ctx context.Context, urlStr string, desired str
}
switch len(pools) {
case 0:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no pool named '%s' found", desired),
}
case 1:
return &pools[0], nil
default:
return nil, ApstraClientErr{
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("name '%s' does not uniquely identify a single IPv4 pool", desired),
}
Expand Down Expand Up @@ -361,7 +361,7 @@ func (o *Client) deleteSubnetFromIpPool(ctx context.Context, poolId ObjectId, ta

if !targetFound {
// nothing to do
return ApstraClientErr{
return ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("target '%s' not found in pool '%s'", target.String(), poolId),
}
Expand Down
Loading

0 comments on commit 42e2468

Please sign in to comment.