Skip to content

Commit

Permalink
Remove unused types and functions
Browse files Browse the repository at this point in the history
Signed-off-by: John Schaeffer <[email protected]>
  • Loading branch information
jnschaeffer committed Sep 7, 2023
1 parent 46115b2 commit a206de7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
37 changes: 0 additions & 37 deletions internal/api/relationships.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,12 @@ package api
import (
"net/http"

"go.infratographer.com/permissions-api/internal/types"

"github.com/labstack/echo/v4"
"go.infratographer.com/x/gidx"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

func (r *Router) buildRelationship(resource types.Resource, item createRelationshipItem) (types.Relationship, error) {
itemID, err := gidx.Parse(item.SubjectID)
if err != nil {
return types.Relationship{}, err
}

itemResource, err := r.engine.NewResourceFromID(itemID)
if err != nil {
return types.Relationship{}, err
}

out := types.Relationship{
Subject: itemResource,
Relation: item.Relation,
Resource: resource,
}

return out, nil
}

func (r *Router) buildRelationships(subjResource types.Resource, items []createRelationshipItem) ([]types.Relationship, error) {
out := make([]types.Relationship, len(items))

for i, item := range items {
rel, err := r.buildRelationship(subjResource, item)
if err != nil {
return nil, err
}

out[i] = rel
}

return out, nil
}

func (r *Router) relationshipListFrom(c echo.Context) error {
resourceIDStr := c.Param("id")

Expand Down
22 changes: 0 additions & 22 deletions internal/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ type listRolesResponse struct {
Data []roleResponse `json:"data"`
}

type createRelationshipItem struct {
Relation string `json:"relation" binding:"required"`
SubjectID string `json:"subject_id" binding:"required"`
}

type createRelationshipsRequest struct {
Relationships []createRelationshipItem `json:"relationships" binding:"required"`
}

type createRelationshipsResponse struct {
Success bool `json:"success"`
}

type deleteRelationshipRequest struct {
Relation string `json:"relation" binding:"required"`
SubjectID string `json:"subject_id" binding:"required"`
}

type deleteRelationshipsResponse struct {
Success bool `json:"success"`
}

type relationshipItem struct {
ResourceID string `json:"resource_id,omitempty"`
Relation string `json:"relation"`
Expand Down

0 comments on commit a206de7

Please sign in to comment.