chore(apptoken): Remove unused function & query

dkanney-get-token
dkanney 1 week ago
parent 922d65e6eb
commit 218f7eff19

@ -380,22 +380,6 @@ left join iam_scope_project
app_token_org.public_id;
`
// TODO: This will be properly implemented with the Create method
// getAppTokenByIdQuery retrieves an AppToken by its public ID
getAppTokenByIdQuery = `
select public_id, scope_id
from app_token_global
where public_id = $1
union all
select public_id, scope_id
from app_token_org
where public_id = $1
union all
select public_id, scope_id
from app_token_project
where public_id = $1
`
// estimateCountAppTokens estimates the total number of app tokens in the three app token tables
estimateCountAppTokens = `
select sum(reltuples::bigint) as estimate

@ -420,35 +420,6 @@ func createAppTokenProject(ctx context.Context, token *AppToken) (*appTokenProje
return tokenToCreate, projectInserts, nil
}
// TODO: Implement additional fields in AppToken and complete this method
// getAppTokenById retrieves an AppToken by its public ID
func (r *Repository) getAppTokenById(ctx context.Context, id string) (*AppToken, error) {
const op = "apptoken.(Repository).getAppTokenById"
if id == "" {
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing id")
}
rows, err := r.reader.Query(ctx, getAppTokenByIdQuery, []any{id})
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
defer rows.Close()
var at AppToken
if rows.Next() {
if err := rows.Scan(&at.PublicId, &at.ScopeId); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
}
if err := rows.Err(); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if at.PublicId == "" {
return nil, errors.New(ctx, errors.NotFound, op, "app token not found")
}
return &at, nil
}
// processPermissionGrants validates grants and creates grant objects for insertion
func processPermissionGrants(ctx context.Context, permId string, grants []string) ([]*appTokenPermissionGrant, error) {
const op = "apptoken.processPermissionGrants"

Loading…
Cancel
Save