[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eThis document outlines best practices for creating new APIs or integrating existing ones as type providers in Deployment Manager.\u003c/p\u003e\n"],["\u003cp\u003eWhen building a new API, it is best to use standard REST methods like \u003ccode\u003eGET\u003c/code\u003e, \u003ccode\u003ePOST\u003c/code\u003e, \u003ccode\u003ePUT\u003c/code\u003e, and \u003ccode\u003eDELETE\u003c/code\u003e, and to avoid custom methods where possible.\u003c/p\u003e\n"],["\u003cp\u003eFor new APIs, maintain predictable resource paths and use consistent naming conventions across methods for inputs, path names, and parameter values.\u003c/p\u003e\n"],["\u003cp\u003eFor existing APIs, you can create an API wrapper for non-RESTful APIs or update the API if it is almost RESTful, and input mappings are required for server-generated values.\u003c/p\u003e\n"],["\u003cp\u003eThe Beta tag at the top of this page means that this feature is subject to pre-GA offerings terms, which means it is available as-is and with limited support.\u003c/p\u003e\n"]]],[],null,["# Best Practices for Adding a Type Provider\n\n| **Beta**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes best practices for creating a new API to add to Deployment\nManager as a [Type Provider](/deployment-manager/docs/fundamentals#type_providers)\nor adding an existing API as a type provider.\n\nDeployment Manager lets you add APIs as type providers to expose the API\nresources as types that you can call in their configuration. To make the\nprocess easier for you, use these best practices when configuring or creating\nan API.\n\nBuilding a new API\n------------------\n\nIf you are building a new API that you intend to integrate with Deployment\nManager, use these best practices.\n\n### Use standard Create, Read, Update, and Delete (CRUD) methods and avoid custom methods\n\nAvoid creating custom methods if possible. Stick to standard REST methods such\nas `GET`, `POST`, `PUT`, and `DELETE` methods. These methods are recognized\nby Deployment Manager and can be automatically mapped.\n\nFor Discovery APIs, you should name your API methods according to the following\nmapping:\n\nFor OpenAPI specifications, you cannot name your API methods differently than\nthe standard REST methods.\n\n### Use predictable resource paths\n\nFor OpenAPI specifications, Deployment Manager supports two behaviors to\nidentify a RESTful interface. The first is if all REST methods for a resource\nbelong in the same resource path: \n\n /foo/{name}\n post:\n get:\n delete:\n put:\n\nIf you must separate the methods, use the same resource path. For example,\nthe following is valid because it refers to\nthe same `/foo` resource: \n\n /foo/\n post:\n /foo/{id}\n get:\n delete:\n put:\n\nHowever, the following is invalid because it refers to two different resources\nfrom the view of Deployment Manager: \n\n /foo/\n post:\n /foo-bar/{id}:\n get:\n put:\n delete:\n\nFor rare cases, you might tempted to name your resource paths like so: \n\n foo/create\n post:\n\n foo/delete\n delete:\n\nThis is invalid from Deployment Manager's view because it cannot identify the\nRESTful interface.\n\n### Use consistent naming across the interface\n\nKeep input and path names the same between `POST` and `PUT` methods. This also\napplies for the parameter values as well. That is, keep the syntax for parameter\nvalues the same across methods.\n\nFor example, if you have a parameter named `email` for the request body of a\n`POST` request, don't name the same parameter `emailAddress` for the `PUT` request. \n\n POST\n {\n \"email\": \"my-email\"\n }\n\n PUT\n {\n \"email\": \"my-email@gmail.com\"\n }\n\nIf you must add this type of behavior, tell Deployment Manager how to handle\nthis behavior by setting\n[advanced API options](/deployment-manager/docs/configuration/type-providers/advanced-configuration-options).\n\nIn addition, keep the request body for `POST` and `PUT` methods the same.\nFor `GET` and `DELETE` methods, only the path is applicable as there is\nno request body for these methods.\n\nIntegrating an existing API\n---------------------------\n\nIntegrating an existing API can be a widely varied process depending on the\nAPI. As such, there is no concrete set of best practices that can be applied\ngenerically across all APIs. The following is a list of general advice that\nmight help when considering ways to integrate an existing API.\n\n- Use an API wrapper for non-RESTful APIs.\n\n If an existing API is not a RESTful API, you can create an API wrapper to\n expose the REST methods only.\n- If the API is almost RESTful, identify and update the API.\n\n If your API is almost RESTful and only has a few non-REST behaviors, you could\n update the API to resolve these behaviors.\n- Server generated values always requires an input mapping.\n\n If your API has server-generated values that are required by API methods,\n you will need to set up\n [input mappings](/deployment-manager/docs/configuration/type-providers/advanced-configuration-options#specifying_input_mappings)\n to get the server-generated value and map it for each request.\n\nWhat's next\n-----------\n\n- Read about the [API requirements](/deployment-manager/docs/configuration/type-providers/api-requirements) for adding an API to Deployment Manager\n- Follow the instructions to [add an API](/deployment-manager/docs/configuration/type-providers/creating-type-provider).\n- Learn more about [advanced API options](/deployment-manager/docs/configuration/type-providers/advanced-configuration-options).\n- Learn more about [types](/deployment-manager/docs/fundamentals#types).\n- Read about [creating a configuration](/deployment-manager/docs/configuration).\n- [Create a deployment](/deployment-manager/docs/deployments) using your new type provider"]]