Skip to content

Commit 48165fb

Browse files
committed
feat(api): add SentryTeam type and listTeams API function
Adds the SentryTeam Zod schema, type export, and listTeams() API client function needed by the team list command.
1 parent a490bcf commit 48165fb

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

plugins/sentry-cli/skills/sentry-cli/SKILL.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,33 @@ List repositories
440440
- `-n, --limit <value> - Maximum number of repositories to list - (default: "30")`
441441
- `--json - Output JSON`
442442

443+
### Team
444+
445+
Work with Sentry teams
446+
447+
#### `sentry team list <org>`
448+
449+
List teams
450+
451+
**Flags:**
452+
- `-n, --limit <value> - Maximum number of teams to list - (default: "30")`
453+
- `--json - Output JSON`
454+
455+
**Examples:**
456+
457+
```bash
458+
# Auto-detect organization or list all
459+
sentry team list
460+
461+
# List teams in a specific organization
462+
sentry team list <org-slug>
463+
464+
# Limit results
465+
sentry team list --limit 10
466+
467+
sentry team list --json
468+
```
469+
443470
### Log
444471

445472
View Sentry logs
@@ -594,6 +621,18 @@ List repositories
594621
- `-n, --limit <value> - Maximum number of repositories to list - (default: "30")`
595622
- `--json - Output JSON`
596623

624+
### Teams
625+
626+
List teams
627+
628+
#### `sentry teams <org>`
629+
630+
List teams
631+
632+
**Flags:**
633+
- `-n, --limit <value> - Maximum number of teams to list - (default: "30")`
634+
- `--json - Output JSON`
635+
597636
### Logs
598637

599638
List logs from a project

src/lib/api-client.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
SentryProjectSchema,
2828
type SentryRepository,
2929
SentryRepositorySchema,
30+
type SentryTeam,
31+
SentryTeamSchema,
3032
type SentryUser,
3133
SentryUserSchema,
3234
type TraceSpan,
@@ -602,6 +604,16 @@ export function listRepositories(orgSlug: string): Promise<SentryRepository[]> {
602604
);
603605
}
604606

607+
/**
608+
* List teams in an organization.
609+
* Uses region-aware routing for multi-region support.
610+
*/
611+
export function listTeams(orgSlug: string): Promise<SentryTeam[]> {
612+
return orgScopedRequest<SentryTeam[]>(`/organizations/${orgSlug}/teams/`, {
613+
schema: z.array(SentryTeamSchema),
614+
});
615+
}
616+
605617
/**
606618
* Search for projects matching a slug across all accessible organizations.
607619
*

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export type {
7474
SentryOrganization,
7575
SentryProject,
7676
SentryRepository,
77+
SentryTeam,
7778
SentryUser,
7879
Span,
7980
StackFrame,
@@ -114,6 +115,7 @@ export {
114115
SentryOrganizationSchema,
115116
SentryProjectSchema,
116117
SentryRepositorySchema,
118+
SentryTeamSchema,
117119
SentryUserSchema,
118120
SpanSchema,
119121
StackFrameSchema,

src/types/sentry.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,3 +810,22 @@ export const SentryRepositorySchema = z
810810
.passthrough();
811811

812812
export type SentryRepository = z.infer<typeof SentryRepositorySchema>;
813+
814+
// Team
815+
816+
/** A team in a Sentry organization */
817+
export const SentryTeamSchema = z
818+
.object({
819+
// Core identifiers (required)
820+
id: z.string(),
821+
slug: z.string(),
822+
name: z.string(),
823+
// Optional metadata
824+
dateCreated: z.string().optional(),
825+
isMember: z.boolean().optional(),
826+
teamRole: z.string().nullable().optional(),
827+
memberCount: z.number().optional(),
828+
})
829+
.passthrough();
830+
831+
export type SentryTeam = z.infer<typeof SentryTeamSchema>;

0 commit comments

Comments
 (0)