/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type ApprovalSettings = {
/**
* If approvals are required for this environment
*/
required: boolean;
/**
* Whether to skip approvals for pending changes
*/
bypassApprovalsForPendingChanges: boolean;
/**
* Sets the amount of approvals required before a member can apply a change. The minimum is one and the maximum is five.
*/
minNumApprovals: number;
/**
* Allow someone who makes an approval request to apply their own change
*/
canReviewOwnRequest: boolean;
/**
* Allow applying the change as long as at least one person has approved
*/
canApplyDeclinedChanges: boolean;
/**
* Automatically apply changes that have been approved by all reviewers. This field is only applicable for approval services other than LaunchDarkly.
*/
autoApplyApprovedChanges?: boolean | undefined;
/**
* Which service to use for managing approvals
*/
serviceKind: string;
serviceConfig: { [k: string]: any };
/**
* Require approval only on flags with the provided tags. Otherwise all flags will require approval.
*/
requiredApprovalTags: Array<string>;
/**
* Optional field for integration configuration ID of a custom approval integration. This is an Enterprise-only feature.
*/
serviceKindConfigurationId?: string | undefined;
/**
* The kind of resource for which the approval settings apply, for example, flag or segment
*/
resourceKind?: string | undefined;
};
/** @internal */
export const ApprovalSettings$inboundSchema: z.ZodType<
ApprovalSettings,
z.ZodTypeDef,
unknown
> = z.object({
required: z.boolean(),
bypassApprovalsForPendingChanges: z.boolean(),
minNumApprovals: z.number().int(),
canReviewOwnRequest: z.boolean(),
canApplyDeclinedChanges: z.boolean(),
autoApplyApprovedChanges: z.boolean().optional(),
serviceKind: z.string(),
serviceConfig: z.record(z.any()),
requiredApprovalTags: z.array(z.string()),
serviceKindConfigurationId: z.string().optional(),
resourceKind: z.string().optional(),
});
/** @internal */
export type ApprovalSettings$Outbound = {
required: boolean;
bypassApprovalsForPendingChanges: boolean;
minNumApprovals: number;
canReviewOwnRequest: boolean;
canApplyDeclinedChanges: boolean;
autoApplyApprovedChanges?: boolean | undefined;
serviceKind: string;
serviceConfig: { [k: string]: any };
requiredApprovalTags: Array<string>;
serviceKindConfigurationId?: string | undefined;
resourceKind?: string | undefined;
};
/** @internal */
export const ApprovalSettings$outboundSchema: z.ZodType<
ApprovalSettings$Outbound,
z.ZodTypeDef,
ApprovalSettings
> = z.object({
required: z.boolean(),
bypassApprovalsForPendingChanges: z.boolean(),
minNumApprovals: z.number().int(),
canReviewOwnRequest: z.boolean(),
canApplyDeclinedChanges: z.boolean(),
autoApplyApprovedChanges: z.boolean().optional(),
serviceKind: z.string(),
serviceConfig: z.record(z.any()),
requiredApprovalTags: z.array(z.string()),
serviceKindConfigurationId: z.string().optional(),
resourceKind: z.string().optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ApprovalSettings$ {
/** @deprecated use `ApprovalSettings$inboundSchema` instead. */
export const inboundSchema = ApprovalSettings$inboundSchema;
/** @deprecated use `ApprovalSettings$outboundSchema` instead. */
export const outboundSchema = ApprovalSettings$outboundSchema;
/** @deprecated use `ApprovalSettings$Outbound` instead. */
export type Outbound = ApprovalSettings$Outbound;
}
export function approvalSettingsToJSON(
approvalSettings: ApprovalSettings,
): string {
return JSON.stringify(
ApprovalSettings$outboundSchema.parse(approvalSettings),
);
}
export function approvalSettingsFromJSON(
jsonString: string,
): SafeParseResult<ApprovalSettings, SDKValidationError> {
return safeParse(
jsonString,
(x) => ApprovalSettings$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ApprovalSettings' from JSON`,
);
}