import * as HttpClient from "effect/unstable/http/HttpClient";
import * as S from "effect/Schema";
import * as stream from "effect/Stream";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import * as C from "../category.js";
const svc = T.AwsApiService({
    sdkId: "NetworkMonitor",
    serviceShapeName: "NetworkMonitor",
});
const auth = T.AwsAuthSigv4({ name: "networkmonitor" });
const ver = T.ServiceVersion("2023-08-01");
const proto = T.AwsProtocolsRestJson1();
const rules = T.EndpointResolver((p, _) => {
    const { Region, UseDualStack = false, UseFIPS = false, Endpoint } = p;
    const e = (u, p = {}, h = {}) => ({
        type: "endpoint",
        endpoint: { url: u, properties: p, headers: h },
    });
    const err = (m) => ({
        type: "error",
        message: m,
    });
    if (Endpoint != null) {
        if (UseFIPS === true) {
            return err("Invalid Configuration: FIPS and custom endpoint are not supported");
        }
        if (UseDualStack === true) {
            return err("Invalid Configuration: Dualstack and custom endpoint are not supported");
        }
        return e(Endpoint);
    }
    if (Region != null) {
        {
            const PartitionResult = _.partition(Region);
            if (PartitionResult != null && PartitionResult !== false) {
                if (UseFIPS === true && UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsFIPS") &&
                        true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://networkmonitor-fips.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("FIPS and DualStack are enabled, but this partition does not support one or both");
                }
                if (UseFIPS === true) {
                    if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                        return e(`https://networkmonitor-fips.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
                    }
                    return err("FIPS is enabled but this partition does not support FIPS");
                }
                if (UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://networkmonitor.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://networkmonitor.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const ListTagsForResourceInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ resourceArn: S.String.pipe(T.HttpLabel("resourceArn")) }).pipe(T.all(T.Http({ method: "GET", uri: "/tags/{resourceArn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListTagsForResourceInput",
});
export const TagMap = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const ListTagsForResourceOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ tags: S.optional(TagMap) })).annotate({
    identifier: "ListTagsForResourceOutput",
});
export const TagResourceInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    resourceArn: S.String.pipe(T.HttpLabel("resourceArn")),
    tags: TagMap,
}).pipe(T.all(T.Http({ method: "POST", uri: "/tags/{resourceArn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "TagResourceInput",
});
export const TagResourceOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "TagResourceOutput",
});
export const TagKeyList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const UntagResourceInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    resourceArn: S.String.pipe(T.HttpLabel("resourceArn")),
    tagKeys: TagKeyList.pipe(T.HttpQuery("tagKeys")),
}).pipe(T.all(T.Http({ method: "DELETE", uri: "/tags/{resourceArn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UntagResourceInput",
});
export const UntagResourceOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UntagResourceOutput",
});
export const Protocol = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const CreateMonitorProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    probeTags: S.optional(TagMap),
})).annotate({
    identifier: "CreateMonitorProbeInput",
});
export const CreateMonitorProbeInputList = /*@__PURE__*/ /*#__PURE__*/ S.Array(CreateMonitorProbeInput);
export const CreateMonitorInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String,
    probes: S.optional(CreateMonitorProbeInputList),
    aggregationPeriod: S.optional(S.Number),
    clientToken: S.optional(S.String).pipe(T.IdempotencyToken()),
    tags: S.optional(TagMap),
}).pipe(T.all(T.Http({ method: "POST", uri: "/monitors" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateMonitorInput",
});
export const MonitorState = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const CreateMonitorOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorArn: S.String,
    monitorName: S.String,
    state: MonitorState,
    aggregationPeriod: S.optional(S.Number),
    tags: S.optional(TagMap),
})).annotate({
    identifier: "CreateMonitorOutput",
});
export const GetMonitorInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ monitorName: S.String.pipe(T.HttpLabel("monitorName")) }).pipe(T.all(T.Http({ method: "GET", uri: "/monitors/{monitorName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetMonitorInput",
});
export const AddressFamily = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const ProbeState = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const Probe = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    probeId: S.optional(S.String),
    probeArn: S.optional(S.String),
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    addressFamily: S.optional(AddressFamily),
    vpcId: S.optional(S.String),
    state: S.optional(ProbeState),
    createdAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    modifiedAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    tags: S.optional(TagMap),
})).annotate({ identifier: "Probe" });
export const ProbeList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Probe);
export const GetMonitorOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorArn: S.String,
    monitorName: S.String,
    state: MonitorState,
    aggregationPeriod: S.Number,
    tags: S.optional(TagMap),
    probes: S.optional(ProbeList),
    createdAt: S.Date.pipe(T.TimestampFormat("epoch-seconds")),
    modifiedAt: S.Date.pipe(T.TimestampFormat("epoch-seconds")),
})).annotate({
    identifier: "GetMonitorOutput",
});
export const UpdateMonitorInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String.pipe(T.HttpLabel("monitorName")),
    aggregationPeriod: S.Number,
}).pipe(T.all(T.Http({ method: "PATCH", uri: "/monitors/{monitorName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateMonitorInput",
});
export const UpdateMonitorOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorArn: S.String,
    monitorName: S.String,
    state: MonitorState,
    aggregationPeriod: S.optional(S.Number),
    tags: S.optional(TagMap),
})).annotate({
    identifier: "UpdateMonitorOutput",
});
export const DeleteMonitorInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ monitorName: S.String.pipe(T.HttpLabel("monitorName")) }).pipe(T.all(T.Http({ method: "DELETE", uri: "/monitors/{monitorName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteMonitorInput",
});
export const DeleteMonitorOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteMonitorOutput",
});
export const ListMonitorsInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    nextToken: S.optional(S.String).pipe(T.HttpQuery("nextToken")),
    maxResults: S.optional(S.Number).pipe(T.HttpQuery("maxResults")),
    state: S.optional(S.String).pipe(T.HttpQuery("state")),
}).pipe(T.all(T.Http({ method: "GET", uri: "/monitors" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListMonitorsInput",
});
export const MonitorSummary = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorArn: S.String,
    monitorName: S.String,
    state: MonitorState,
    aggregationPeriod: S.optional(S.Number),
    tags: S.optional(TagMap),
})).annotate({ identifier: "MonitorSummary" });
export const MonitorList = /*@__PURE__*/ /*#__PURE__*/ S.Array(MonitorSummary);
export const ListMonitorsOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ monitors: MonitorList, nextToken: S.optional(S.String) })).annotate({
    identifier: "ListMonitorsOutput",
});
export const ProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    tags: S.optional(TagMap),
})).annotate({ identifier: "ProbeInput" });
export const CreateProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String.pipe(T.HttpLabel("monitorName")),
    probe: ProbeInput,
    clientToken: S.optional(S.String).pipe(T.IdempotencyToken()),
    tags: S.optional(TagMap),
}).pipe(T.all(T.Http({ method: "POST", uri: "/monitors/{monitorName}/probes" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateProbeInput",
});
export const CreateProbeOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    probeId: S.optional(S.String),
    probeArn: S.optional(S.String),
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    addressFamily: S.optional(AddressFamily),
    vpcId: S.optional(S.String),
    state: S.optional(ProbeState),
    createdAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    modifiedAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    tags: S.optional(TagMap),
})).annotate({
    identifier: "CreateProbeOutput",
});
export const GetProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String.pipe(T.HttpLabel("monitorName")),
    probeId: S.String.pipe(T.HttpLabel("probeId")),
}).pipe(T.all(T.Http({
    method: "GET",
    uri: "/monitors/{monitorName}/probes/{probeId}",
}), svc, auth, proto, ver, rules))).annotate({ identifier: "GetProbeInput" });
export const GetProbeOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    probeId: S.optional(S.String),
    probeArn: S.optional(S.String),
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    addressFamily: S.optional(AddressFamily),
    vpcId: S.optional(S.String),
    state: S.optional(ProbeState),
    createdAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    modifiedAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    tags: S.optional(TagMap),
})).annotate({ identifier: "GetProbeOutput" });
export const UpdateProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String.pipe(T.HttpLabel("monitorName")),
    probeId: S.String.pipe(T.HttpLabel("probeId")),
    state: S.optional(ProbeState),
    destination: S.optional(S.String),
    destinationPort: S.optional(S.Number),
    protocol: S.optional(Protocol),
    packetSize: S.optional(S.Number),
}).pipe(T.all(T.Http({
    method: "PATCH",
    uri: "/monitors/{monitorName}/probes/{probeId}",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateProbeInput",
});
export const UpdateProbeOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    probeId: S.optional(S.String),
    probeArn: S.optional(S.String),
    sourceArn: S.String,
    destination: S.String,
    destinationPort: S.optional(S.Number),
    protocol: Protocol,
    packetSize: S.optional(S.Number),
    addressFamily: S.optional(AddressFamily),
    vpcId: S.optional(S.String),
    state: S.optional(ProbeState),
    createdAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    modifiedAt: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    tags: S.optional(TagMap),
})).annotate({
    identifier: "UpdateProbeOutput",
});
export const DeleteProbeInput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    monitorName: S.String.pipe(T.HttpLabel("monitorName")),
    probeId: S.String.pipe(T.HttpLabel("probeId")),
}).pipe(T.all(T.Http({
    method: "DELETE",
    uri: "/monitors/{monitorName}/probes/{probeId}",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteProbeInput",
});
export const DeleteProbeOutput = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteProbeOutput",
});
//# Errors
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { message: S.optional(S.String) }).pipe(C.withAuthError) {
}
export class ConflictException extends S.TaggedErrorClass()("ConflictException", { message: S.optional(S.String) }).pipe(C.withConflictError) {
}
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { message: S.optional(S.String) }, T.Retryable()).pipe(C.withServerError, C.withRetryableError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ThrottlingException extends S.TaggedErrorClass()("ThrottlingException", { message: S.optional(S.String) }, T.Retryable({ throttling: true })).pipe(C.withThrottlingError, C.withRetryableError) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ServiceQuotaExceededException extends S.TaggedErrorClass()("ServiceQuotaExceededException", { message: S.optional(S.String) }).pipe(C.withQuotaError) {
}
/**
 * Lists the tags assigned to this resource.
 */
export const listTagsForResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListTagsForResourceInput,
    output: ListTagsForResourceOutput,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Adds key-value pairs to a monitor or probe.
 */
export const tagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: TagResourceInput,
    output: TagResourceOutput,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Removes a key-value pair from a monitor or probe.
 */
export const untagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UntagResourceInput,
    output: UntagResourceOutput,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Creates a monitor between a source subnet and destination IP address. Within a monitor you'll create one or more probes that monitor network traffic between your source Amazon Web Services VPC subnets and your destination IP addresses. Each probe then aggregates and sends metrics to Amazon CloudWatch.
 *
 * You can also create a monitor with probes using this command. For each probe, you
 * define the following:
 *
 * - `source`—The subnet IDs where the probes will be created.
 *
 * - `destination`— The target destination IP address for the
 * probe.
 *
 * - `destinationPort`—Required only if the protocol is
 * `TCP`.
 *
 * - `protocol`—The communication protocol between the source and
 * destination. This will be either `TCP` or `ICMP`.
 *
 * - `packetSize`—The size of the packets. This must be a number between
 * `56` and `8500`.
 *
 * - (Optional) `tags` —Key-value pairs created and assigned to the
 * probe.
 */
export const createMonitor = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateMonitorInput,
    output: CreateMonitorOutput,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns details about a specific monitor.
 *
 * This action requires the `monitorName` parameter. Run
 * `ListMonitors` to get a list of monitor names.
 */
export const getMonitor = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetMonitorInput,
    output: GetMonitorOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Updates the `aggregationPeriod` for a monitor. Monitors support an
 * `aggregationPeriod` of either `30` or `60` seconds.
 * This action requires the `monitorName` and `probeId` parameter.
 * Run `ListMonitors` to get a list of monitor names.
 */
export const updateMonitor = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateMonitorInput,
    output: UpdateMonitorOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Deletes a specified monitor.
 *
 * This action requires the `monitorName` parameter. Run
 * `ListMonitors` to get a list of monitor names.
 */
export const deleteMonitor = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteMonitorInput,
    output: DeleteMonitorOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns a list of all of your monitors.
 */
export const listMonitors = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListMonitorsInput,
    output: ListMonitorsOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "nextToken",
        outputToken: "nextToken",
        items: "monitors",
        pageSize: "maxResults",
    },
}));
/**
 * Create a probe within a monitor. Once you create a probe, and it begins monitoring your
 * network traffic, you'll incur billing charges for that probe. This action requires the
 * `monitorName` parameter. Run `ListMonitors` to get a list of
 * monitor names. Note the name of the `monitorName` you want to create the
 * probe for.
 */
export const createProbe = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateProbeInput,
    output: CreateProbeOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns the details about a probe. This action requires both the
 * `monitorName` and `probeId` parameters. Run
 * `ListMonitors` to get a list of monitor names. Run
 * `GetMonitor` to get a list of probes and probe IDs.
 */
export const getProbe = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetProbeInput,
    output: GetProbeOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Updates a monitor probe. This action requires both the `monitorName` and `probeId` parameters. Run `ListMonitors` to get a list of monitor names. Run `GetMonitor` to get a list of probes and probe IDs.
 *
 * You can update the following para create a monitor with probes using this command. For
 * each probe, you define the following:
 *
 * - `state`—The state of the probe.
 *
 * - `destination`— The target destination IP address for the
 * probe.
 *
 * - `destinationPort`—Required only if the protocol is
 * `TCP`.
 *
 * - `protocol`—The communication protocol between the source and
 * destination. This will be either `TCP` or `ICMP`.
 *
 * - `packetSize`—The size of the packets. This must be a number between
 * `56` and `8500`.
 *
 * - (Optional) `tags` —Key-value pairs created and assigned to the
 * probe.
 */
export const updateProbe = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateProbeInput,
    output: UpdateProbeOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Deletes the specified probe. Once a probe is deleted you'll no longer incur any billing
 * fees for that probe.
 *
 * This action requires both the `monitorName` and `probeId`
 * parameters. Run `ListMonitors` to get a list of monitor names. Run
 * `GetMonitor` to get a list of probes and probe IDs. You can only delete a
 * single probe at a time using this action.
 */
export const deleteProbe = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteProbeInput,
    output: DeleteProbeOutput,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
//# sourceMappingURL=networkmonitor.js.map