Skip to content

Commit

Permalink
api: Remove total_count from List response
Browse files Browse the repository at this point in the history
  • Loading branch information
halimi committed Nov 25, 2024
1 parent 3d4e2b8 commit 0db6fa5
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 143 deletions.
1 change: 0 additions & 1 deletion api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9395,7 +9395,6 @@ The NsEndDeviceRegistry service allows clients to manage their end devices on th
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `mac_settings_profiles` | [`MACSettingsProfile`](#ttn.lorawan.v3.MACSettingsProfile) | repeated | The MAC settings profiles. |
| `total_count` | [`uint32`](#uint32) | | The total number of MAC settings profiles that match the request. |

### <a name="ttn.lorawan.v3.UpdateMACSettingsProfileRequest">Message `UpdateMACSettingsProfileRequest`</a>

Expand Down
5 changes: 0 additions & 5 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -25910,11 +25910,6 @@
"$ref": "#/definitions/v3MACSettingsProfile"
},
"description": "The MAC settings profiles."
},
"total_count": {
"type": "integer",
"format": "int64",
"description": "The total number of MAC settings profiles that match the request."
}
}
},
Expand Down
2 changes: 0 additions & 2 deletions api/ttn/lorawan/v3/networkserver_mac_settings_profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ message ListMACSettingsProfilesRequest {
message ListMACSettingsProfilesResponse {
// The MAC settings profiles.
repeated MACSettingsProfile mac_settings_profiles = 1;
// The total number of MAC settings profiles that match the request.
uint32 total_count = 2;
}

// The NsMACSettingsProfileRegistry service allows clients to manage MAC settings profiles on the Network Server.
Expand Down
15 changes: 9 additions & 6 deletions pkg/networkserver/grpc_mac_settings_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ package networkserver

import (
"context"
"strconv"

"go.thethings.network/lorawan-stack/v3/pkg/auth/rights"
"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)

var (
errProfileAlreadyExists = errors.DefineAlreadyExists("mac_settings_profile_already_exists", "MAC settings profile already exists") // nolint: lll
errProfileNotFound = errors.DefineNotFound("mac_settings_profile_not_found", "MAC settings profile not found")
errMACSettingsProfileAlreadyExists = errors.DefineAlreadyExists("mac_settings_profile_already_exists", "MAC settings profile already exists") // nolint: lll
errMACSettingsProfileNotFound = errors.DefineNotFound("mac_settings_profile_not_found", "MAC settings profile not found") // nolint: lll
)

// NsMACSettingsProfileRegistry implements the MAC settings profile registry grpc service.
Expand All @@ -50,7 +53,7 @@ func (m *NsMACSettingsProfileRegistry) Create(ctx context.Context, req *ttnpb.Cr
paths,
func(_ context.Context, profile *ttnpb.MACSettingsProfile) (*ttnpb.MACSettingsProfile, []string, error) {
if profile != nil {
return nil, nil, errProfileAlreadyExists.New()
return nil, nil, errMACSettingsProfileAlreadyExists.New()
}
return req.MacSettingsProfile, paths, nil
})
Expand Down Expand Up @@ -105,7 +108,7 @@ func (m *NsMACSettingsProfileRegistry) Update(ctx context.Context, req *ttnpb.Up
paths,
func(_ context.Context, profile *ttnpb.MACSettingsProfile) (*ttnpb.MACSettingsProfile, []string, error) {
if profile == nil {
return nil, nil, errProfileNotFound.New()
return nil, nil, errMACSettingsProfileNotFound.New()
}
return req.MacSettingsProfile, paths, nil
})
Expand Down Expand Up @@ -134,7 +137,7 @@ func (m *NsMACSettingsProfileRegistry) Delete(ctx context.Context, req *ttnpb.De
paths,
func(_ context.Context, profile *ttnpb.MACSettingsProfile) (*ttnpb.MACSettingsProfile, []string, error) {
if profile == nil {
return nil, nil, errProfileNotFound.New()
return nil, nil, errMACSettingsProfileNotFound.New()
}
return nil, nil, nil
})
Expand Down Expand Up @@ -164,8 +167,8 @@ func (m *NsMACSettingsProfileRegistry) List(ctx context.Context, req *ttnpb.List
return nil, err
}

grpc.SetHeader(ctx, metadata.Pairs("x-total-count", strconv.FormatInt(int64(len(profiles)), 10))) // nolint: errcheck
return &ttnpb.ListMACSettingsProfilesResponse{
MacSettingsProfiles: profiles,
TotalCount: uint32(len(profiles)), // nolint: gosec
}, nil
}
1 change: 0 additions & 1 deletion pkg/networkserver/grpc_mac_settings_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,6 @@ func TestMACSettingsProfileRegistryList(t *testing.T) {
a := assertions.New(t)
a.So(profile, should.NotBeNil)
a.So(profile.MacSettingsProfiles, should.HaveLength, 1)
a.So(profile.TotalCount, should.Equal, 1)
return a.So(profile.MacSettingsProfiles, should.Resemble, []*ttnpb.MACSettingsProfile{{
Ids: &ttnpb.MACSettingsProfileIdentifiers{
ApplicationIds: &ttnpb.ApplicationIdentifiers{
Expand Down
177 changes: 83 additions & 94 deletions pkg/ttnpb/networkserver_mac_settings_profile.pb.go

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pkg/ttnpb/networkserver_mac_settings_profile.pb.paths.fm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions pkg/ttnpb/networkserver_mac_settings_profile.pb.setters.fm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/ttnpb/networkserver_mac_settings_profile.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions pkg/ttnpb/networkserver_mac_settings_profile_json.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions sdk/js/generated/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -42200,18 +42200,6 @@
"isoneof": false,
"oneofdecl": "",
"defaultValue": ""
},
{
"name": "total_count",
"description": "The total number of MAC settings profiles that match the request.",
"label": "",
"type": "uint32",
"longType": "uint32",
"fullType": "uint32",
"ismap": false,
"isoneof": false,
"oneofdecl": "",
"defaultValue": ""
}
]
},
Expand Down

0 comments on commit 0db6fa5

Please sign in to comment.