Database Migration Service는 연결 프로필과 마이그레이션 작업을 프로그래매틱 방식으로 관리하기 위한 REST API를 제공합니다. REST API는 연결 프로필과 마이그레이션 작업을 만들고 관리하는 작업과 관련된 리소스로 정의됩니다. 모든 리소스와 메서드에 관한 자세한 내용은 Database Migration Service API 참조를 참고하세요.
Database Migration Service REST API로 직접 요청을 보낼 때는 올바른 요청 양식을 만들고, 인증된 사용자로 요청을 승인하고, 반환된 응답을 처리해야 합니다. 이 문서의 여러 태스크는 cURL을 사용하는 API 예시를 제공합니다.
API 사용에 관한 자세한 예시는 Database Migration Service API 참고의 요청 페이지를 참고하세요. 각 페이지에는 여러 프로그래밍 언어로 API를 호출하는 예시와 올바른 형식의 요청에 포함되는 요소 및 예상 응답을 파악하는 데 도움이 되는 요청별 탐색기가 있습니다.
또한 다음과 같은 방법으로 인스턴스를 관리할 때 Database Migration Service API를 간접적으로 사용하게 됩니다.
이러한 방법, 특히Google Cloud 콘솔을 사용할 때의 이점은 사용 사례에 따라 연결 프로필과 마이그레이션 작업의 관리를 크게 간소화할 수 있다는 것입니다. Database Migration Service를 처음 시작하는 경우 REST API로 직접 작업하기 전에 먼저 이러한 도구 중 하나로 시작하는 것이 좋습니다.
API 사용 설정
Database Migration Service API를 사용하려면 사용 설정해야 합니다.
Database Migration Service API를 사용하려면 필요한 권한이 있어야 합니다. 이러한 권한에는 다음이 포함됩니다.
데이터베이스 마이그레이션 관리자: 이 권한이 있으면 사용자가 연결 프로필과 마이그레이션 작업을 관리하는 데 사용되는 Database Migration Service의 모든 리소스에 액세스할 수 있습니다.
Database Migration 뷰어: 이 권한이 있는 사용자는 Database Migration Service의 연결 프로필 및 마이그레이션 작업에 대한 읽기 전용 액세스 권한을 갖습니다.
Cloud SQL 관리자: 이 권한이 있는 사용자는 Database Migration Service에서 Cloud SQL의 연결 프로필과 마이그레이션 작업을 만들고 관리할 수 있습니다.
Google Cloud에서는 Identity and Access Management(IAM)를 제공하므로 특정 Google Cloud 리소스에 더욱 세분화된 액세스 권한을 부여하고 다른 리소스에 대한 무단 액세스를 방지할 수 있습니다. Google Cloud console, API의 IAM 메서드 또는 Google Cloud CLI를 사용하여 Database Migration Service에 대한 권한을 가져오고 설정할 수 있습니다. 자세한 내용은 리소스에 대한 액세스 권한 부여, 변경, 취소를 참고하세요.
cURL로 API를 사용하는 경우 명령줄을 사용하여 속성 값을 제공합니다. 비밀번호나 보안 키 같은 민감한 값으로 작업하는 경우 명령줄에 입력하면 보안 위험이 발생합니다. 보안을 강화하기 위해 API 호출을 위해 JSON 데이터가 포함된 파일을 만들고 명령줄에서 파일 경로를 제공할 수 있습니다.
cURL API 호출에 대하여 파일에서 JSON 데이터를 제공하려면 다음 안내를 따르세요.
모든 항목이 작은 따옴표로 묶인 파일을 --data 필드용으로 만듭니다.
중괄호는 포함하되 작은따옴표는 포함하지 마세요.
명령줄에서 @ 문자 앞에 --data 매개 변수로서 파일 경로 제공합니다.
--data@<path-to-file>/<filename>
예를 들어 Cloud SQL 소스 데이터베이스의 연결 프로필을 만들려면 다음 콘텐츠로 request.json이라는 파일을 만들 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-18(UTC)"],[[["\u003cp\u003eDatabase Migration Service offers a REST API for programmatically managing connection profiles and migration jobs, detailed in the Database Migration Service API Reference.\u003c/p\u003e\n"],["\u003cp\u003eWhile the REST API can be used directly with tools like cURL, users can also indirectly utilize it through the Google Cloud CLI and Google Cloud console, which simplify administration.\u003c/p\u003e\n"],["\u003cp\u003eThe API can be enabled in the Google Cloud console or via gcloud CLI commands, with various permission levels available, such as Database Migration Admin, Viewer, and Cloud SQL Admin.\u003c/p\u003e\n"],["\u003cp\u003eFor secure handling of sensitive data, the API can accept JSON data from a file, rather than directly from the command line, when using cURL.\u003c/p\u003e\n"],["\u003cp\u003eLong-running API operations are handled asynchronously, requiring users to manage them with the Database Migration Service API, allowing for checking status and deleting operations if needed.\u003c/p\u003e\n"]]],[],null,["# Use the Database Migration Service API\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n[MySQL](/database-migration/docs/mysql/use-the-database-migration-service-api \"View this page for the MySQL version of Database Migration Service.\") \\| PostgreSQL \\| [PostgreSQL to AlloyDB](/database-migration/docs/postgresql-to-alloydb/use-the-database-migration-service-api \"View this page for the PostgreSQL to AlloyDB version of Database Migration Service.\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOverview\n--------\n\nDatabase Migration Service provides a REST API for administering your connection profiles and migration jobs programmatically. The REST API is defined by resources associated with creating and managing connection profiles and migration jobs. For details about all resources\nand their methods, see the\n[Database Migration Service API Reference](/database-migration/docs/reference/rest).\n\nWhen you send requests directly to the Database Migration Service REST API, you must create the\ncorrect form of the request, authorize the request as an authenticated user, and\nprocess any responses returned. Many of the tasks in this documentation provide\nAPI examples using [cURL](http://curl.haxx.se).\n\nFor more examples of using the APIs, see the page for the request in the\n[Database Migration Service API Reference](/database-migration/docs/reference/rest). Each page has\nexamples calling the API in several programming languages, as well as a\nrequest-specific Explorer to help you see what goes into a well-formed request\nand what to expect in the response.\n\nYou're also using the Database Migration Service API, indirectly, when you use any of the\nfollowing ways of administering instances:\n\n- [Google Cloud CLI](/sdk): A command-line interface (CLI) that you can use to work with your instances.\n\n- [Google Cloud console](https://console.cloud.google.com/): A graphical web interface.\n\nThe advantage of using these methods, especially the\nGoogle Cloud console, is that they can greatly simplify administering your\nconnection profiles and migration jobs (depending on your use case). If you're just starting out with\nDatabase Migration Service, then we recommend that you start with one of these tools first\nbefore working with the REST API directly.\n\nEnable the API\n--------------\n\nTo use the Database Migration Service API, you need to enable it: \n\n### Console\n\n1. [Enable the Database Migration Service API](https://console.cloud.google.com/apis/library/datamigration.googleapis.com).\n2. Select your project.\n3. Select **Continue**.\n\n### gcloud\n\n1. Enter the following to display the project IDs for your Google Cloud projects: \n\n ```bash\n gcloud projects list\n ```\n2. Set your default project: \n\n ```bash\n gcloud config set project YOUR_PROJECT_ID\n ```\n3. Enable the Cloud SQL Admin API: \n\n ```bash\n gcloud services enable datamigration.googleapis.com\n ```\n\nPermissions\n-----------\n\nYou must have the required permissions to use the Database Migration Service API. These permissions include:\n\n- Database Migration Admin: With this permission, a user gains access to all resources of Database Migration Service used to manage connection profiles and migration jobs.\n- Database Migration Viewer: With this permission, a user has read-only access to connection profiles and migration jobs in Database Migration Service.\n- Cloud SQL Admin: With this permission, a user can create and manage connection profiles and migration jobs for Cloud SQL in Database Migration Service.\n\nGoogle Cloud offers Identity and Access Management (IAM), which lets you give more granular access to specific Google Cloud resources and prevents unwanted access to other resources. You can get and set permissions for Database Migration Service using the Google Cloud console, the IAM methods of the API, or the Google Cloud CLI. For more information, see [Granting, changing, and revoking access to resources](/iam/docs/granting-changing-revoking-access).\n\nAPI examples\n------------\n\nFor examples of using the Database Migration Service API with cURL, see [Manage connection profiles using the API](/database-migration/docs/postgres/api-connection-profiles) and [Manage migration jobs using the API](/database-migration/docs/postgres/api-migration-jobs).\n\nProvide JSON data from a file\n-----------------------------\n\nWhen you use the API with cURL, you provide property values using the command\nline. If you're working with sensitive values such as passwords or security\nkeys, providing them on the command line poses a security risk. For increased\nsecurity, you can create a file containing the JSON data for the API call, and\nprovide the path to the file on the command line.\n\nTo provide JSON data to your cURL API call from a file:\n\n1. Create a file containing everything enclosed in single quotes for the\n `--data` field.\n\n Include the curly brackets, but don't include the single quotes.\n2. At the command line, provide the path to the file, preceded by the\n `@` character, as the `--data` parameter:\n\n ```bash\n --data @\u003cpath-to-file\u003e/\u003cfilename\u003e\n ```\n\n \u003cbr /\u003e\n\n For example, to create a connection profile for a Cloud SQL source database, you could create a file named `request.json` with the following content: \n\n ```\n {\n \"displayName\": \"my Cloud SQL connection profile\",\n \"mysql\": {\n \"host\": \"10.11.12.13\",\n \"port\": 5432,\n \"username\": \"myusername\",\n \"password\": \"mypassword\"\n }\n }\n ```\n\n Then, you would use the following cURL command at the command line: \n\n ```bash\n curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n --header 'Content-Type: application/json' \\\n --data @./request.json \\\n -X POST \\\n https://datamigration.googleapis.com/v1/projects/myProject/locations/myLocation/connectionProfiles?connectionProfileId=myCloudSQLconnectionprofile\n ```\n\nWork with long-running API calls\n--------------------------------\n\nSome API calls, such as object creation, can take some time to complete. Because\nthe API is asynchronous, the call returns immediately, even if the operation is\nstill in progress. If a subsequent API call uses the newly created object, then you\nmust wait for the first operation to complete before proceeding.\n\nYou can use the Database Migration Service API to [manage operations](/sdk/gcloud/reference/database-migration/operations). This includes:\n\n- [Showing details about an operation](/sdk/gcloud/reference/database-migration/operations/describe)\n- [Listing operations for a region](/sdk/gcloud/reference/database-migration/operations/list)\n- [Deleting an operation](/sdk/gcloud/reference/database-migration/operations/delete)\n\nDatabase Migration Service and Google APIs Discovery Service\n------------------------------------------------------------\n\n[Google APIs Discovery Service](/discovery) is a service that you can use to\ndiscover Google APIs. For example, when you use the [Google APIs Explorer](/apis-explorer) tool, you're using the Discovery Service.\n\nIn the Discovery Service, Database Migration Service is represented as \"datamigration\" (for example:\nhttps://**datamigration**.googleapis.com/$discovery/rest?version=v1)."]]