create-essential-subscription
Set up a new essential subscription for Redis Cloud by specifying a name, payment method, and plan ID. Returns a TASK ID to monitor subscription creation progress.
Instructions
Create a new essential subscription. Returns a TASK ID that can be used to track the status of the subscription creation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Subscription name | |
| paymentMethod | No | Payment method | credit-card |
| paymentMethodId | No | Payment method ID | |
| planId | Yes | Plan ID. The plan ID can be taken from /fixed/plans |
Implementation Reference
- Handler function that extracts and validates input parameters (name, planId, paymentMethod, paymentMethodId), constructs the request body, calls SubscriptionsEssentialsService.createSubscription1 via executeApiCall, and returns the response."create-essential-subscription": async (request) => { const { name, planId, paymentMethod, paymentMethodId } = extractArguments<{ name: string; planId: number; paymentMethod?: FixedSubscriptionCreateRequest["paymentMethod"]; paymentMethodId?: number; }>(request); // Validate input validateToolInput( createSubscriptionSchema, { name, planId, paymentMethod, paymentMethodId }, "Create essential subscription", ); // If paymentMethod is credit-card, paymentMethodId is required if (paymentMethod === "credit-card" && !paymentMethodId) { throw new Error( "paymentMethodId is required when paymentMethod is credit-card", ); } const reqBody: FixedSubscriptionCreateRequest = { name, planId, ...(paymentMethod && { paymentMethod }), ...(paymentMethodId && { paymentMethodId }), }; const result = await executeApiCall( () => SubscriptionsEssentialsService.createSubscription1(reqBody), "Create essential subscription", ); return createToolResponse(result); },
- Tool schema definition for create-essential-subscription, including input schema with properties for name, planId, paymentMethod, paymentMethodId, and required fields.const CREATE_ESSENTIAL_SUBSCRIPTION_TOOL: Tool = { name: "create-essential-subscription", description: "Create a new essential subscription. Returns a TASK ID that can be used to track the status of the subscription creation", inputSchema: { type: "object", properties: { name: { type: "string", description: "Subscription name", }, planId: { type: "number", description: "Plan ID. The plan ID can be taken from /fixed/plans", }, paymentMethod: { type: "string", description: "Payment method", enum: ["credit-card", "marketplace"], default: "credit-card", }, paymentMethodId: { type: "number", description: "Payment method ID", }, }, required: ["name", "planId"], }, };
- src/tools/subscriptions/essentials/index.ts:163-169 (registration)Registration of the create-essential-subscription tool in the SUBSCRIPTIONS_ESSENTIALS_TOOLS array export.export const SUBSCRIPTIONS_ESSENTIALS_TOOLS = [ GET_ESSENTIAL_SUBSCRIPTIONS_TOOL, GET_ESSENTIAL_SUBSCRIPTION_BY_ID_TOOL, CREATE_ESSENTIAL_SUBSCRIPTION_TOOL, DELETE_ESSENTIAL_SUBSCRIPTION_TOOL, GET_ESSENTIALS_PLANS_TOOL, ];
- src/tools/subscriptions/essentials/index.ts:171-336 (registration)The handlers object export that includes the create-essential-subscription handler key.export const SUBSCRIPTIONS_ESSENTIALS_HANDLERS: ToolHandlers = { "get-essential-subscriptions": async (request) => { const { page = 0, size = DEFAULT_PAGE_SIZE } = extractArguments<{ page?: number; size?: number; }>(request); // Validate input validateToolInput( getSubscriptionsSchema, { page, size }, "Essential subscriptions request", ); const response = await executeApiCall( () => SubscriptionsEssentialsService.getAllSubscriptions1(), "Get essential subscriptions", ); const allSubscriptions = response.subscriptions || []; // Calculate pagination const startIndex = page * size; const endIndex = startIndex + size; const paginatedSubscriptions = allSubscriptions.slice(startIndex, endIndex); const pageable: Pageable = { page, size, }; return createToolResponse( createPage(paginatedSubscriptions, pageable, allSubscriptions.length), ); }, "get-essential-subscription-by-id": async (request) => { const { subscriptionId } = extractArguments<{ subscriptionId: number }>( request, ); // Validate input validateToolInput( subscriptionIdSchema, { subscriptionId }, "Essential subscription ID", ); const subscription = await executeApiCall( () => SubscriptionsEssentialsService.getSubscriptionById1(subscriptionId), `Get essential subscription ${subscriptionId}`, ); return createToolResponse(subscription); }, "delete-essential-subscription": async (request) => { const { subscriptionId } = extractArguments<{ subscriptionId: number }>( request, ); // Validate input validateToolInput( subscriptionIdSchema, { subscriptionId }, "Essential subscription ID", ); const result = await executeApiCall( () => SubscriptionsEssentialsService.deleteSubscriptionById1(subscriptionId), `Delete essential subscription ${subscriptionId}`, ); return createToolResponse(result); }, "get-essentials-plans": async (request) => { const { provider, redisFlex, page = 0, size = DEFAULT_PAGE_SIZE, } = extractArguments<{ provider: "AWS" | "GCP" | "AZURE"; redisFlex: boolean; page?: number; size?: number; }>(request); // Validate input validateToolInput( getPlansSchema, { provider, redisFlex, page, size }, "Essential plans request", ); const response = await executeApiCall( () => SubscriptionsEssentialsService.getAllFixedSubscriptionsPlans( provider, redisFlex, ), `Get essential plans for ${provider}`, ); const allPlans = response.plans.map((plan) => ({ id: plan.id, name: plan.name, size: plan.size, sizeMeasurementUnit: plan.sizeMeasurementUnit, regionId: plan.regionId, price: plan.price, priceCurrency: plan.priceCurrency, pricePeriod: plan.pricePeriod, })); // Calculate pagination const startIndex = page * size; const endIndex = startIndex + size; const paginatedPlans = allPlans.slice(startIndex, endIndex); const pageable: Pageable = { page, size, }; return createToolResponse( createPage(paginatedPlans, pageable, allPlans.length), ); }, "create-essential-subscription": async (request) => { const { name, planId, paymentMethod, paymentMethodId } = extractArguments<{ name: string; planId: number; paymentMethod?: FixedSubscriptionCreateRequest["paymentMethod"]; paymentMethodId?: number; }>(request); // Validate input validateToolInput( createSubscriptionSchema, { name, planId, paymentMethod, paymentMethodId }, "Create essential subscription", ); // If paymentMethod is credit-card, paymentMethodId is required if (paymentMethod === "credit-card" && !paymentMethodId) { throw new Error( "paymentMethodId is required when paymentMethod is credit-card", ); } const reqBody: FixedSubscriptionCreateRequest = { name, planId, ...(paymentMethod && { paymentMethod }), ...(paymentMethodId && { paymentMethodId }), }; const result = await executeApiCall( () => SubscriptionsEssentialsService.createSubscription1(reqBody), "Create essential subscription", ); return createToolResponse(result); }, };