Skip to main content
Glama
yjiace

AlibabaCloud DevOps MCP Server

by yjiace
organization.ts3.58 kB
import { z } from "zod"; import {buildUrl, yunxiaoRequest} from "../../common/utils.js"; import { CurrentOrganizationInfoSchema, UserOrganizationsInfoSchema, CurrentUserSchema, OrganizationDepartmentsSchema, DepartmentInfoSchema, OrganizationRoleSchema, ListOrganizationRolesSchema, OrganizationRole, } from "./types.js"; export async function getCurrentOrganizationInfoFunc( ): Promise<z.infer<typeof CurrentOrganizationInfoSchema>> { const url = "/oapi/v1/platform/user"; const response = await yunxiaoRequest(url, { method: "GET", }); const responseData = response as { lastOrganization?: string; id?: string; name?: string; }; const mappedResponse = { lastOrganization: responseData.lastOrganization, // Organization ID userId: responseData.id, // Map API's "id" to userId userName: responseData.name // Map API's "name" to userName }; return CurrentOrganizationInfoSchema.parse(mappedResponse); } export async function getUserOrganizationsFunc( ): Promise<z.infer<typeof UserOrganizationsInfoSchema>> { const url = "/oapi/v1/platform/organizations"; const response = await yunxiaoRequest(url, { method: "GET", }); if (!Array.isArray(response)) { return []; } return UserOrganizationsInfoSchema.parse(response); } export async function getOrganizationDepartmentsFunc( organizationId: string, parentId?: string ): Promise<z.infer<typeof OrganizationDepartmentsSchema>> { const baseUrl = `/oapi/v1/platform/organizations/${organizationId}/departments`; const params: Record<string, string | undefined> = {}; if (parentId) { params.parentId = parentId; } const url = buildUrl(baseUrl, params); const response = await yunxiaoRequest(url, { method: "GET" }); return OrganizationDepartmentsSchema.parse(response); } export async function getOrganizationDepartmentInfoFunc( organizationId: string, id: string ): Promise<z.infer<typeof DepartmentInfoSchema>> { const url = `/oapi/v1/platform/organizations/${organizationId}/departments/${id}`; const response = await yunxiaoRequest(url, { method: "GET", }); return DepartmentInfoSchema.parse(response); } export async function getOrganizationDepartmentAncestorsFunc( organizationId: string, id: string): Promise<z.infer<typeof OrganizationDepartmentsSchema>> { const url = `/oapi/v1/platform/organizations/${organizationId}/departments/${id}/ancestors`; const response = await yunxiaoRequest(url, { method: "GET", }) return OrganizationDepartmentsSchema.parse(response); }; export async function listOrganizationRolesFunc( organizationId: string ): Promise<z.infer<typeof OrganizationRole>> { const url = `/oapi/v1/platform/organizations/${organizationId}/roles`; const response = await yunxiaoRequest(url, { method: "GET" }); return OrganizationRole.parse(response); } export async function getOrganizationRoleFunc( organizationId: string, roleId: string ): Promise<z.infer<typeof OrganizationRoleSchema>> { const url = `/oapi/v1/platform/organizations/${organizationId}/roles/${roleId}`; const response = await yunxiaoRequest(url, { method: "GET" }); return OrganizationRoleSchema.parse(response); } export async function getCurrentUserFunc(): Promise<z.infer<typeof CurrentUserSchema>> { const url = "/oapi/v1/platform/user"; const response = await yunxiaoRequest(url, { method: "GET", }); return CurrentUserSchema.parse(response); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yjiace/alibabacloud-devops-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server