Utilisation de l'API REST
Utilisez l'API REST OCI GoldenGate pour communiquer avec vos déploiements de réplication de données. Découvrez comment utiliser l'API REST dans diverses configurations, en appelant des commandes à l'aide de curl et de Cloud Shell.
Rubriques connexes
Se connecter à un déploiement public
Pour vous connecter à un déploiement OCI GoldenGate avec un point d'extrémité public dans Cloud Shell, vous avez seulement besoin de l'URL de déploiement. Vous pouvez trouver l'URL de déploiement (URL de la console) dans la page des détails du déploiement.
Se connecter à un déploiement privé
Si le déploiement comporte un point d'extrémité privé, vous pouvez connecter Cloud Shell à un réseau ayant accès au déploiement à l'aide du service de réseau Cloud Shell ou créer un hôte bastion, une session d'hôte bastion et un tunnel SSH.
Par défaut, Cloud Shell limite l'accès réseau aux ressources internes OCI dans la région principale de votre location, sauf si vous avez activé le réseau public géré par Cloud Shell. Votre administrateur doit configurer une politique d'identité pour activer le réseau public Cloud Shell. Pour plus d'informations, voir Réseau Cloud Shell.
Exemples d'appels d'API REST
Facultativement, vous pouvez stocker votre nom d'utilisateur et votre mot de passe de déploiement dans un fichier .netrc. Les exemples suivants supposent que vous utilisez un fichier .netrc.
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/services/v2/config/healthLister les fichiers de piste
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/services/v2/exttrails
Lister les extractions ou les répliques
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/v2/extractscurl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/v2/replicatsExtraire les détails de l'extraction ou de la réplication
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/v2/extracts/<extract name>curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/v2/replicats/<replicat name>Créer un processus d'extraction
{
"config":[
"Extract EATP",
"ExtTrail E1",
"UseridAlias BLOGSRCATP",
"Table SRC_OCIGGLL.*;"
],
"source":{"tranlogs":"integrated"},
"credentials":{"alias":"BLOGSRCATP"},
"registration":{"optimized":false},
"begin":"now",
"targets":[{"name":"E1"}]
}
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>/services/v2/extracts/<Extract name> -d @<JSON file>.jsonCréer un processus de réplication
{
"config":[
"REPLICAT RADW",
"UseridAlias BLOGTRGADW",
"MAP SRC_OCIGGLL.*, TARGET SRCMIRROR_OCIGGLL.*;"
],
"source":{"name": "E1"},
"credentials":{"alias":"BLOGTRGADW"},
"checkpoint":{"table":"SRCMIRROR_OCIGGLL.CHECKTABLE"},
"mode":{
"type":"nonintegrated",
"parallel": false
},
"registration":"none",
"begin":"now",
"status":"stopped"
}
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>/services/v2/replicats/<Replicat name> -d @<JSON file>.jsonDémarrer une extraction ou une réplication
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>/services/v2/commands/execute -d '{ "name":"start", "processName":"<Extract or Replicat name>"}'
Obtenir le statut et les statistiques pour une extraction donnée
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>:<port>/services/v2/extracts/<extract name>/command -d '{"command":"STATUS"}'curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>:<port>/services/v2/extracts/<extract name>/command -d '{"command":"STATUS"}'Obtenir le statut et les statistiques pour un processus de réplication donné
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>:<port>/services/v2/replicats/<replicat name>/command -d '{"command":"STATUS"}'curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X POST https://<deployment URL>:<port>/services/v2/replicats/<replicat name>/command -d '{"command":"STATS"}'