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";
const svc = T.AwsApiService({
    sdkId: "License Manager Linux Subscriptions",
    serviceShapeName: "LicenseManagerLinuxSubscriptions",
});
const auth = T.AwsAuthSigv4({ name: "license-manager-linux-subscriptions" });
const ver = T.ServiceVersion("2018-05-10");
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://license-manager-linux-subscriptions-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://license-manager-linux-subscriptions-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://license-manager-linux-subscriptions.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://license-manager-linux-subscriptions.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const DeregisterSubscriptionProviderRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ SubscriptionProviderArn: S.String }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/subscription/DeregisterSubscriptionProvider",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeregisterSubscriptionProviderRequest",
});
export const DeregisterSubscriptionProviderResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeregisterSubscriptionProviderResponse",
});
export const GetRegisteredSubscriptionProviderRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ SubscriptionProviderArn: S.String }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/subscription/GetRegisteredSubscriptionProvider",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetRegisteredSubscriptionProviderRequest",
});
export const GetRegisteredSubscriptionProviderResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SubscriptionProviderArn: S.optional(S.String),
    SubscriptionProviderSource: S.optional(S.String),
    SecretArn: S.optional(S.String),
    SubscriptionProviderStatus: S.optional(S.String),
    SubscriptionProviderStatusMessage: S.optional(S.String),
    LastSuccessfulDataRetrievalTime: S.optional(S.String),
})).annotate({
    identifier: "GetRegisteredSubscriptionProviderResponse",
});
export const GetServiceSettingsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.all(T.Http({ method: "POST", uri: "/subscription/GetServiceSettings" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetServiceSettingsRequest",
});
export const StringList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const LinuxSubscriptionsDiscoverySettings = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ SourceRegions: StringList, OrganizationIntegration: S.String })).annotate({
    identifier: "LinuxSubscriptionsDiscoverySettings",
});
export const StringMap = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const GetServiceSettingsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    LinuxSubscriptionsDiscovery: S.optional(S.String),
    LinuxSubscriptionsDiscoverySettings: S.optional(LinuxSubscriptionsDiscoverySettings),
    Status: S.optional(S.String),
    StatusMessage: S.optional(StringMap),
    HomeRegions: S.optional(StringList),
})).annotate({
    identifier: "GetServiceSettingsResponse",
});
export const Filter = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Name: S.optional(S.String),
    Values: S.optional(StringList),
    Operator: S.optional(S.String),
})).annotate({ identifier: "Filter" });
export const FilterList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Filter);
export const ListLinuxSubscriptionInstancesRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Filters: S.optional(FilterList),
    MaxResults: S.optional(S.Number),
    NextToken: S.optional(S.String),
}).pipe(T.all(T.Http({
    method: "POST",
    uri: "/subscription/ListLinuxSubscriptionInstances",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListLinuxSubscriptionInstancesRequest",
});
export const ProductCodeList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const Instance = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    AmiId: S.optional(S.String),
    InstanceID: S.optional(S.String),
    InstanceType: S.optional(S.String),
    AccountID: S.optional(S.String),
    Status: S.optional(S.String),
    Region: S.optional(S.String),
    UsageOperation: S.optional(S.String),
    ProductCode: S.optional(ProductCodeList),
    LastUpdatedTime: S.optional(S.String),
    SubscriptionName: S.optional(S.String),
    OsVersion: S.optional(S.String),
    SubscriptionProviderCreateTime: S.optional(S.String),
    SubscriptionProviderUpdateTime: S.optional(S.String),
    DualSubscription: S.optional(S.String),
    RegisteredWithSubscriptionProvider: S.optional(S.String),
})).annotate({ identifier: "Instance" });
export const InstanceList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Instance);
export const ListLinuxSubscriptionInstancesResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Instances: S.optional(InstanceList),
    NextToken: S.optional(S.String),
})).annotate({
    identifier: "ListLinuxSubscriptionInstancesResponse",
});
export const ListLinuxSubscriptionsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Filters: S.optional(FilterList),
    MaxResults: S.optional(S.Number),
    NextToken: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/subscription/ListLinuxSubscriptions" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListLinuxSubscriptionsRequest",
});
export const Subscription = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Name: S.optional(S.String),
    Type: S.optional(S.String),
    InstanceCount: S.optional(S.Number),
})).annotate({ identifier: "Subscription" });
export const SubscriptionList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(Subscription);
export const ListLinuxSubscriptionsResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Subscriptions: S.optional(SubscriptionList),
    NextToken: S.optional(S.String),
})).annotate({
    identifier: "ListLinuxSubscriptionsResponse",
});
export const SubscriptionProviderSourceList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const ListRegisteredSubscriptionProvidersRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SubscriptionProviderSources: S.optional(SubscriptionProviderSourceList),
    MaxResults: S.optional(S.Number),
    NextToken: S.optional(S.String),
}).pipe(T.all(T.Http({
    method: "POST",
    uri: "/subscription/ListRegisteredSubscriptionProviders",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListRegisteredSubscriptionProvidersRequest",
});
export const RegisteredSubscriptionProvider = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SubscriptionProviderArn: S.optional(S.String),
    SubscriptionProviderSource: S.optional(S.String),
    SecretArn: S.optional(S.String),
    SubscriptionProviderStatus: S.optional(S.String),
    SubscriptionProviderStatusMessage: S.optional(S.String),
    LastSuccessfulDataRetrievalTime: S.optional(S.String),
})).annotate({
    identifier: "RegisteredSubscriptionProvider",
});
export const RegisteredSubscriptionProviderList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(RegisteredSubscriptionProvider);
export const ListRegisteredSubscriptionProvidersResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RegisteredSubscriptionProviders: S.optional(RegisteredSubscriptionProviderList),
    NextToken: S.optional(S.String),
})).annotate({
    identifier: "ListRegisteredSubscriptionProvidersResponse",
});
export const ListTagsForResourceRequest = /*@__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: "ListTagsForResourceRequest",
});
export const Tags = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const ListTagsForResourceResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ tags: S.optional(Tags) })).annotate({
    identifier: "ListTagsForResourceResponse",
});
export const RegisterSubscriptionProviderRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SubscriptionProviderSource: S.String,
    SecretArn: S.String,
    Tags: S.optional(Tags),
}).pipe(T.all(T.Http({
    method: "POST",
    uri: "/subscription/RegisterSubscriptionProvider",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "RegisterSubscriptionProviderRequest",
});
export const RegisterSubscriptionProviderResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SubscriptionProviderSource: S.optional(S.String),
    SubscriptionProviderArn: S.optional(S.String),
    SubscriptionProviderStatus: S.optional(S.String),
})).annotate({
    identifier: "RegisterSubscriptionProviderResponse",
});
export const TagResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    resourceArn: S.String.pipe(T.HttpLabel("resourceArn")),
    tags: Tags,
}).pipe(T.all(T.Http({ method: "PUT", uri: "/tags/{resourceArn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "TagResourceRequest",
});
export const TagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "TagResourceResponse",
});
export const TagKeyList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const UntagResourceRequest = /*@__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: "UntagResourceRequest",
});
export const UntagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UntagResourceResponse",
});
export const UpdateServiceSettingsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    LinuxSubscriptionsDiscovery: S.String,
    LinuxSubscriptionsDiscoverySettings: LinuxSubscriptionsDiscoverySettings,
    AllowUpdate: S.optional(S.Boolean),
}).pipe(T.all(T.Http({ method: "POST", uri: "/subscription/UpdateServiceSettings" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateServiceSettingsRequest",
});
export const UpdateServiceSettingsResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    LinuxSubscriptionsDiscovery: S.optional(S.String),
    LinuxSubscriptionsDiscoverySettings: S.optional(LinuxSubscriptionsDiscoverySettings),
    Status: S.optional(S.String),
    StatusMessage: S.optional(StringMap),
    HomeRegions: S.optional(StringList),
})).annotate({
    identifier: "UpdateServiceSettingsResponse",
});
//# Errors
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { message: S.optional(S.String) }) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.optional(S.String) }) {
}
export class ThrottlingException extends S.TaggedErrorClass()("ThrottlingException", { message: S.optional(S.String) }) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", { message: S.optional(S.String) }) {
}
/**
 * Remove a third-party subscription provider from the Bring Your Own License (BYOL) subscriptions
 * registered to your account.
 */
export const deregisterSubscriptionProvider = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeregisterSubscriptionProviderRequest,
    output: DeregisterSubscriptionProviderResponse,
    errors: [
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Get details for a Bring Your Own License (BYOL) subscription that's registered to your account.
 */
export const getRegisteredSubscriptionProvider = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRegisteredSubscriptionProviderRequest,
    output: GetRegisteredSubscriptionProviderResponse,
    errors: [
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Lists the Linux subscriptions service settings for your account.
 */
export const getServiceSettings = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetServiceSettingsRequest,
    output: GetServiceSettingsResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
}));
/**
 * Lists the running Amazon EC2 instances that were discovered with commercial Linux
 * subscriptions.
 */
export const listLinuxSubscriptionInstances = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListLinuxSubscriptionInstancesRequest,
    output: ListLinuxSubscriptionInstancesResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        items: "Instances",
        pageSize: "MaxResults",
    },
}));
/**
 * Lists the Linux subscriptions that have been discovered. If you have linked your
 * organization, the returned results will include data aggregated across your accounts in
 * Organizations.
 */
export const listLinuxSubscriptions = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListLinuxSubscriptionsRequest,
    output: ListLinuxSubscriptionsResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        items: "Subscriptions",
        pageSize: "MaxResults",
    },
}));
/**
 * List Bring Your Own License (BYOL) subscription registration resources for your account.
 */
export const listRegisteredSubscriptionProviders = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListRegisteredSubscriptionProvidersRequest,
    output: ListRegisteredSubscriptionProvidersResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        items: "RegisteredSubscriptionProviders",
        pageSize: "MaxResults",
    },
}));
/**
 * List the metadata tags that are assigned to the
 * specified Amazon Web Services resource.
 */
export const listTagsForResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListTagsForResourceRequest,
    output: ListTagsForResourceResponse,
    errors: [
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
/**
 * Register the supported third-party subscription provider for your Bring Your Own License (BYOL) subscription.
 */
export const registerSubscriptionProvider = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: RegisterSubscriptionProviderRequest,
    output: RegisterSubscriptionProviderResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
}));
/**
 * Add metadata tags to the specified Amazon Web Services resource.
 */
export const tagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: TagResourceRequest,
    output: TagResourceResponse,
    errors: [
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
/**
 * Remove one or more metadata tag from the specified Amazon Web Services resource.
 */
export const untagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UntagResourceRequest,
    output: UntagResourceResponse,
    errors: [InternalServerException, ResourceNotFoundException],
}));
/**
 * Updates the service settings for Linux subscriptions.
 */
export const updateServiceSettings = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateServiceSettingsRequest,
    output: UpdateServiceSettingsResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
}));
//# sourceMappingURL=license-manager-linux-subscriptions.js.map