@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
246 lines (225 loc) • 6.68 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { smartUnion } from "../types/smartUnion.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export type ListAccessGroupsRequest = {
/**
* Filter access groups by project.
*/
projectId?: string | undefined;
/**
* Search for access groups by name.
*/
search?: string | undefined;
/**
* Number of members to include in the response.
*/
membersLimit?: number | undefined;
/**
* Number of projects to include in the response.
*/
projectsLimit?: number | undefined;
/**
* Limit how many access group should be returned.
*/
limit?: number | undefined;
/**
* Continuation cursor to retrieve the next page of results.
*/
next?: string | undefined;
/**
* The Team identifier to perform the request on behalf of.
*/
teamId?: string | undefined;
/**
* The Team slug to perform the request on behalf of.
*/
slug?: string | undefined;
};
export type AccessGroups = {
members?: Array<string> | undefined;
projects?: Array<string> | undefined;
entitlements?: Array<string> | undefined;
teamPermissions?: Array<string> | undefined;
isDsyncManaged: boolean;
/**
* The name of this access group.
*/
name: string;
/**
* Timestamp in milliseconds when the access group was created.
*/
createdAt: string;
/**
* ID of the team that this access group belongs to.
*/
teamId: string;
/**
* Timestamp in milliseconds when the access group was last updated.
*/
updatedAt: string;
/**
* ID of the access group.
*/
accessGroupId: string;
/**
* Number of members in the access group.
*/
membersCount: number;
/**
* Number of projects in the access group.
*/
projectsCount: number;
/**
* Roles that the team has in the access group.
*/
teamRoles?: Array<string> | undefined;
};
export type ResponseBodyPagination = {
count: number;
next: string | null;
};
export type ListAccessGroupsResponseBody2 = {
accessGroups: Array<AccessGroups>;
pagination: ResponseBodyPagination;
};
export type ListAccessGroupsResponseBody1 = {};
export type ListAccessGroupsResponseBody =
| ListAccessGroupsResponseBody2
| ListAccessGroupsResponseBody1;
/** @internal */
export type ListAccessGroupsRequest$Outbound = {
projectId?: string | undefined;
search?: string | undefined;
membersLimit?: number | undefined;
projectsLimit?: number | undefined;
limit?: number | undefined;
next?: string | undefined;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const ListAccessGroupsRequest$outboundSchema: z.ZodType<
ListAccessGroupsRequest$Outbound,
z.ZodTypeDef,
ListAccessGroupsRequest
> = z.object({
projectId: z.string().optional(),
search: z.string().optional(),
membersLimit: z.number().int().optional(),
projectsLimit: z.number().int().optional(),
limit: z.number().int().optional(),
next: z.string().optional(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function listAccessGroupsRequestToJSON(
listAccessGroupsRequest: ListAccessGroupsRequest,
): string {
return JSON.stringify(
ListAccessGroupsRequest$outboundSchema.parse(listAccessGroupsRequest),
);
}
/** @internal */
export const AccessGroups$inboundSchema: z.ZodType<
AccessGroups,
z.ZodTypeDef,
unknown
> = z.object({
members: types.optional(z.array(types.string())),
projects: types.optional(z.array(types.string())),
entitlements: types.optional(z.array(types.string())),
teamPermissions: types.optional(z.array(types.string())),
isDsyncManaged: types.boolean(),
name: types.string(),
createdAt: types.string(),
teamId: types.string(),
updatedAt: types.string(),
accessGroupId: types.string(),
membersCount: types.number(),
projectsCount: types.number(),
teamRoles: types.optional(z.array(types.string())),
});
export function accessGroupsFromJSON(
jsonString: string,
): SafeParseResult<AccessGroups, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccessGroups$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccessGroups' from JSON`,
);
}
/** @internal */
export const ResponseBodyPagination$inboundSchema: z.ZodType<
ResponseBodyPagination,
z.ZodTypeDef,
unknown
> = z.object({
count: types.number(),
next: types.nullable(types.string()),
});
export function responseBodyPaginationFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyPagination, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyPagination$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyPagination' from JSON`,
);
}
/** @internal */
export const ListAccessGroupsResponseBody2$inboundSchema: z.ZodType<
ListAccessGroupsResponseBody2,
z.ZodTypeDef,
unknown
> = z.object({
accessGroups: z.array(z.lazy(() => AccessGroups$inboundSchema)),
pagination: z.lazy(() => ResponseBodyPagination$inboundSchema),
});
export function listAccessGroupsResponseBody2FromJSON(
jsonString: string,
): SafeParseResult<ListAccessGroupsResponseBody2, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAccessGroupsResponseBody2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAccessGroupsResponseBody2' from JSON`,
);
}
/** @internal */
export const ListAccessGroupsResponseBody1$inboundSchema: z.ZodType<
ListAccessGroupsResponseBody1,
z.ZodTypeDef,
unknown
> = z.object({});
export function listAccessGroupsResponseBody1FromJSON(
jsonString: string,
): SafeParseResult<ListAccessGroupsResponseBody1, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAccessGroupsResponseBody1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAccessGroupsResponseBody1' from JSON`,
);
}
/** @internal */
export const ListAccessGroupsResponseBody$inboundSchema: z.ZodType<
ListAccessGroupsResponseBody,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => ListAccessGroupsResponseBody2$inboundSchema),
z.lazy(() => ListAccessGroupsResponseBody1$inboundSchema),
]);
export function listAccessGroupsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<ListAccessGroupsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListAccessGroupsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListAccessGroupsResponseBody' from JSON`,
);
}