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 une adresse publique dans Cloud Shell, vous avez uniquement besoin de l'URL de déploiement. Vous pouvez trouver l'URL de déploiement (URL de console) sur la page de détails du déploiement.
Connexion à un déploiement privé
Si le déploiement dispose d'une adresse privée, vous pouvez connecter Cloud Shell à un réseau avec accès au déploiement à l'aide de la mise en réseau Cloud Shell, ou créer un bastion, une session de bastion et un tunnel SSH.
Par défaut, Cloud Shell limite l'accès réseau aux ressources internes OCI dans la région d'origine de votre location, sauf si vous avez activé le réseau public géré par Cloud Shell. L'administrateur doit configurer une stratégie d'identité pour activer le réseau public Cloud Shell. Pour plus d'informations, reportez-vous à Mise en réseau de Cloud Shell.
Exemples d'appels d'API REST
Vous pouvez éventuellement stocker le nom utilisateur et le 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 trace
curl -n -H "Content-Type: application/json" -H "Accept: application/json" -X GET https://<deployment URL>/services/v2/exttrails
Liste des extractions ou des 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 d'extraction ou de 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éation d'une 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éation d'une 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 d'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 d'une réplication donnée
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"}'