GoldenGate Add Extract – (Part 3 Rest API Series)

Let’s add and start an Extract with REST API, note that I am not starting at creation:

— Add Extract
curl -s -u oggadmin:”xxxxx” \
-H “Accept: application/json” \
-X POST http://localhost:9011/services/v2/extracts/EDEMO \
-d ‘{
“description”:”Create Extract Demo”,
“config”:[
“EXTRACT EDEMO”,
“EXTTRAIL ed”,
“USERIDALIAS OGG_SRC_CDB”,
“– Integrated extract parameters”,
“TRANLOGOPTIONS INTEGRATEDPARAMS (max_sga_size 2048, parallelism 4)”,
“LOGALLSUPCOLS”,
“UPDATERECORDFORMAT COMPACT”,
“GETTRUNCATES”,
“DDL INCLUDE MAPPED”,
“DDLOPTIONS GETREPLICATES, GETAPPLOPS”,
“TABLE SRCPDB.HR.*;”
],
“source”:{
“tranlogs”:”integrated”
},
“credentials”:{
“alias”:”OGG_SRC_CDB”
},
“registration”:{
“containers”: [ “SRCPDB” ],
“optimized”:false
},
“begin”:”now”,
“targets”:[
{
“name”:”ed”,
“sizeMB”:50
}
],
“status”:”stopped”
}’ \
| json_reformat

-bash-4.2$ curl -s -u oggadmin:"xxxxx" \
> -H "Accept: application/json" \
> -X POST http://localhost:9011/services/v2/extracts/EDEMO \
> -d '{
> "description":"Create Extract Demo",
> "config":[
> "EXTRACT EDEMO",
> "EXTTRAIL ed",
> "USERIDALIAS OGG_SRC_CDB",
> "-- Integrated extract parameters",
> "TRANLOGOPTIONS INTEGRATEDPARAMS (max_sga_size 2048, parallelism 4)",
> "LOGALLSUPCOLS",
> "UPDATERECORDFORMAT COMPACT",
> "GETTRUNCATES",
> "DDL INCLUDE MAPPED",
> "DDLOPTIONS GETREPLICATES, GETAPPLOPS",
> "TABLE SRCPDB.HR.*;"
> ],
> "source":{
> "tranlogs":"integrated"
> },
> "credentials":{
> "alias":"OGG_SRC_CDB"
> },
> "registration":{
> "containers": [ "SRCPDB" ],
> "optimized":false
> },
> "begin":"now",
> "targets":[
> {
> "name":"ed",
> "sizeMB":50
> }
> ],
> "status":"stopped"
> }' \
> | json_reformat
{
    "$schema": "api:standardResponse",
    "links": [
        {
            "rel": "canonical",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        },
        {
            "rel": "self",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        }
    ],
    "messages": [
        {
            "$schema": "ogg:message",
            "title": "The json property '/source/tranlogs' has been deprecated. Expected value is: '/source'.",
            "code": "OGG-12142",
            "severity": "WARNING",
            "issued": "2021-10-11T04:21:29Z",
            "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"
        },
        {
            "$schema": "ogg:message",
            "title": "Integrated Extract added.",
            "code": "OGG-08100",
            "severity": "INFO",
            "issued": "2021-10-11T04:21:29Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-08100"
        },
        {
            "$schema": "ogg:message",
            "title": "Extract group EDEMO successfully registered with database at SCN 5520852.",
            "code": "OGG-02003",
            "severity": "INFO",
            "issued": "2021-10-11T04:21:36Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-02003"
        },
        {
            "$schema": "ogg:message",
            "title": "Parameter file EDEMO.prm passed validity check.",
            "code": "OGG-10183",
            "severity": "INFO",
            "issued": "2021-10-11T04:21:37Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-10183"
        }
    ]
}
-bash-4.2$

Now, let’s start the Extract:

— Start Extract
curl -s -u oggadmin:”xxxxx” \
-H “Content-Type: application/json” \
-H “Accept: application/json” \
-X PATCH http://localhost:9011/services/v2/extracts/EDEMO \
-d ‘{“status”: “running”}’ | json_reformat

-bash-4.2$ curl -s -u oggadmin:"xxxxx" \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -X PATCH http://localhost:9011/services/v2/extracts/EDEMO \
> -d '{"status": "running"}' | json_reformat
{
    "$schema": "api:standardResponse",
    "links": [
        {
            "rel": "canonical",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        },
        {
            "rel": "self",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        }
    ],
    "messages": [
        {
            "$schema": "ogg:message",
            "title": "Extract group EDEMO starting.",
            "code": "OGG-00975",
            "severity": "INFO",
            "issued": "2021-10-11T04:24:30Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-00975"
        },
        {
            "$schema": "ogg:message",
            "title": "Extract group EDEMO started.",
            "code": "OGG-15426",
            "severity": "INFO",
            "issued": "2021-10-11T04:24:30Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-15426"
        }
    ]
}

We can also check with REST API:

-bash-4.2$ curl -s -u oggadmin:"xxxx" \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -X GET http://localhost:9011/services/v2/extracts/EDEMO/info/status | json_reformat
{
    "$schema": "api:standardResponse",
    "links": [
        {
            "rel": "canonical",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO/info/status",
            "mediaType": "application/json"
        },
        {
            "rel": "self",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO/info/status",
            "mediaType": "application/json"
        },
        {
            "rel": "describedby",
            "href": "http://localhost:9011/services/v2/metadata-catalog/extractStatus",
            "mediaType": "application/schema+json"
        }
    ],
    "messages": [

    ],
    "response": {
        "$schema": "ogg:extractStatus",
        "status": "running",
        "processId": 27065,
        "lastStarted": "2021-10-11T04:24:39.006Z",
        "lag": 3,
        "sinceLagReported": 3,
        "position": "0.5560442"
    }
}

Now let’s stop and DELETE the Extract:

-bash-4.2$ curl -s -u oggadmin:"xxxxx" \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -X PATCH http://localhost:9011/services/v2/extracts/EDEMO \
> -d '{"status": "stopped"}' | json_reformat
{
    "$schema": "api:standardResponse",
    "links": [
        {
            "rel": "canonical",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        },
        {
            "rel": "self",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        }
    ],
    "messages": [

    ]
}

Delete the Extract:

-bash-4.2$ curl -s -u oggadmin:"xxxxx" \
> -H "Content-Type: application/json" \
> -H "Accept: application/json" \
> -X DELETE http://localhost:9011/services/v2/extracts/EDEMO | json_reformat
{
    "$schema": "api:standardResponse",
    "links": [
        {
            "rel": "canonical",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        },
        {
            "rel": "self",
            "href": "http://localhost:9011/services/v2/extracts/EDEMO",
            "mediaType": "application/json"
        }
    ],
    "messages": [
        {
            "$schema": "ogg:message",
            "title": "Successfully unregistered Extract group EDEMO from database.",
            "code": "OGG-01750",
            "severity": "INFO",
            "issued": "2021-10-11T04:29:01Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-01750"
        },
        {
            "$schema": "ogg:message",
            "title": "No Heartbeat entries with [EDEMO], none deleted.",
            "code": "OGG-14052",
            "severity": "INFO",
            "issued": "2021-10-11T04:29:01Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-14052"
        },
        {
            "$schema": "ogg:message",
            "title": "Extract group EDEMO deleted.",
            "code": "OGG-08100",
            "severity": "INFO",
            "issued": "2021-10-11T04:29:01Z",
            "type": "http://docs.oracle.com/goldengate/c2130/gg-winux/GMESG/oggus.htm#OGG-08100"
        }
    ]
}
-bash-4.2$

Next up PART 4: Add Replicat

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.