Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCLOUD2-16462 resource list method #67

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

type ResourceService interface {
Create(ctx context.Context, req *CreateRequest) (*Resource, error)
List(ctx context.Context) ([]Resource, error)
Get(ctx context.Context, id int64) (*Resource, error)
Update(ctx context.Context, id int64, req *UpdateRequest) (*Resource, error)
Delete(ctx context.Context, resourceID int64) error
Expand Down
9 changes: 9 additions & 0 deletions resources/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ func (s *Service) Create(ctx context.Context, req *CreateRequest) (*Resource, er
return &resource, nil
}

func (s *Service) List(ctx context.Context) ([]Resource, error) {
var resources []Resource
if err := s.r.Request(ctx, http.MethodGet, "/cdn/resources", nil, &resources); err != nil {
vvelikodny marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("request: %w", err)
}

return resources, nil
}

func (s *Service) Get(ctx context.Context, id int64) (*Resource, error) {
var resource Resource
if err := s.r.Request(ctx, http.MethodGet, fmt.Sprintf("/cdn/resources/%d", id), nil, &resource); err != nil {
Expand Down
Loading