import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdPhraseMatchersArgs = {projectsId: string, locationsId: string, filter?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdPhraseMatchersOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudContactcenterinsightsV1ExactMatchConfig = z.object({caseSensitive: z.boolean().optional()}); export const googleCloudContactcenterinsightsV1RegexMatchConfig = z.object({}); export const googleCloudContactcenterinsightsV1PhraseMatchRuleConfig = z.object({exactMatchConfig: googleCloudContactcenterinsightsV1ExactMatchConfig.optional(), regexMatchConfig: googleCloudContactcenterinsightsV1RegexMatchConfig.optional()}); export const googleCloudContactcenterinsightsV1PhraseMatchRule = z.object({config: googleCloudContactcenterinsightsV1PhraseMatchRuleConfig.optional(), negated: z.boolean().optional(), query: z.string().optional()}); export const googleCloudContactcenterinsightsV1PhraseMatchRuleGroup = z.object({phraseMatchRules: z.array(googleCloudContactcenterinsightsV1PhraseMatchRule).optional(), type: z.enum(["PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED", "ALL_OF", "ANY_OF"]).optional()}); export const googleCloudContactcenterinsightsV1PhraseMatcher = z.object({activationUpdateTime: z.string().optional(), active: z.boolean().optional(), displayName: z.string().optional(), name: z.string().optional(), phraseMatchRuleGroups: z.array(googleCloudContactcenterinsightsV1PhraseMatchRuleGroup).optional(), revisionCreateTime: z.string().optional(), revisionId: z.string().optional(), roleMatch: z.enum(["ROLE_UNSPECIFIED", "HUMAN_AGENT", "AUTOMATED_AGENT", "END_USER", "ANY_AGENT"]).optional(), type: z.enum(["PHRASE_MATCHER_TYPE_UNSPECIFIED", "ALL_OF", "ANY_OF"]).optional(), updateTime: z.string().optional(), versionTag: z.string().optional()}); export const googleCloudContactcenterinsightsV1ListPhraseMatchersResponse = z.object({nextPageToken: z.string().optional(), phraseMatchers: z.array(googleCloudContactcenterinsightsV1PhraseMatcher).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Lists phrase matchers. * * GET /v1/projects/{projectsId}/locations/{locationsId}/phraseMatchers */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdPhraseMatchers = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdPhraseMatchersArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdPhraseMatchersOptions) => { const {baseUrl = "https://contactcenterinsights.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.filter != null) query.append("filter", String(args.filter)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/phraseMatchers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(googleCloudContactcenterinsightsV1ListPhraseMatchersResponse, await res.json()) };