Resource Type

Last modified 13 Mar 2024 13:32 +01:00

Description

Here we are describing the Resource object type in relation to midPoints REST API. The Resource objects are a part of the REST API web resources.

Endpoint
resources/

Operations And Examples

The Resource endpoint is a part of the Create-Read-Update-Delete (CRUD) web resources present in midPoint. This is apparent in the operations which are available for this type of object.

In our examples we are authenticating with the credentials, name "administrator" and password "y0uR_P455woR*d" on a localhost instance running on port 8080.

For some help regarding the REST examples please see this link:

Create Resource Objects

Create a new Resource object in MidPoint with file data source
curl --user administrator:y0uR_P455woR*d \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/resources \
-v \
--data-binary @./samples/rest/resource-csv.json
Show data source example for "Create a new Resource object in MidPoint" | GitHub
{
  "resource" : {
    "oid" : "ef2bc95b-76e0-59e2-86d6-9999cccccccc",
    "name" : "Test CSV: username",
    "description" : "Simple CSV resource that is using single identifier (username)",
    "connectorRef" : {
      "type" : "c:ConnectorType",
      "filter" : {
        "equal" : {
          "path" : "c:connectorType",
          "value" : "com.evolveum.polygon.connector.csv.CsvConnector"
        }
      }
    },
    "connectorConfiguration" : {
      "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3",
      "configurationProperties" : {
        "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector",
        "filePath" : "target/midpoint.csv",
        "encoding" : "utf-8",
        "fieldDelimiter" : ",",
        "multivalueDelimiter" : ";",
        "uniqueAttribute" : "username",
        "passwordAttribute" : "password"
      }
    },
    "schemaHandling" : {
      "objectType" : {
        "displayName" : "Default Account",
        "default" : true,
        "objectClass" : "ri:AccountObjectClass",
        "attribute" : [ {
          "ref" : "ri:username",
          "outbound" : {
            "source" : {
              "path" : "$user/name"
            }
          }
        }, {
          "ref" : "ri:firstname",
          "outbound" : {
            "source" : {
              "path" : "$user/givenName"
            }
          }
        }, {
          "ref" : "ri:lastname",
          "outbound" : {
            "source" : {
              "path" : "$user/familyName"
            }
          }
        } ],
        "activation" : {
          "administrativeStatus" : {
            "outbound" : { }
          }
        },
        "credentials" : {
          "password" : {
            "outbound" : { }
          }
        }
      }
    },
    "capabilities" : {
      "configured" : {
        "activation" : {
          "status" : {
            "attribute" : "ri:disabled",
            "enableValue" : "false",
            "disableValue" : "true"
          }
        }
      }
    }
  }
}
Show source data for resource for "Create a new Resource object in MidPoint" | GitHub
username,firstname,lastname,disabled,password
user01,Firstname,Lastname,false,secret
user02,Test,Lastname,false,secret

The response is an HTTP 201 code in case of success without a response body. Also, the response contains a Location Header pointing to the location of the created user.

Example location header
Location: http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc

Get Resource Type Objects

Get operation for fetching a single specific object.

Get Resource object
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-X GET http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc?options=raw \
-v

The response is an HTTP 200 code in case of success with a response body containing the queried item.

Example Output of "Get Resource object" example

The example is simplified, some properties were removed to keep the example output "short". This example does not contain all possible properties of this object type.

{
  "resource" : {
    "oid" : "ef2bc95b-76e0-59e2-86d6-9999cccccccc",
    "version" : "1",
    "name" : "Test CSV: username",
    "description" : "Simple CSV resource that is using single identifier (username)",
    "metadata" : {},
    "operationExecution" : {},
    "iteration" : 0,
    "iterationToken" : "",
    "connectorRef" : {
      "oid" : "01aa0a9e-dfe0-47c8-8fca-4446894a348c",
      "relation" : "org:default",
      "type" : "c:ConnectorType",
      "filter" : {
        "equal" : {
          "path" : "c:connectorType",
          "value" : "com.evolveum.polygon.connector.csv.CsvConnector"
        }
      }
    },
    "connectorConfiguration" : {
      "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3",
      "configurationProperties" : {
        "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector",
        "multivalueDelimiter" : ";",
        "fieldDelimiter" : ",",
        "filePath" : "target/midpoint.csv",
        "encoding" : "utf-8",
        "passwordAttribute" : "password",
        "uniqueAttribute" : "username"
      }
    },
    "schemaHandling" : {
      "objectType" : {
        "@id" : 1,
        "displayName" : "Default Account",
        "default" : true,
        "objectClass" : "ri:AccountObjectClass",
        "attribute" : [ {
          "@id" : 2,
          "ref" : "ri:username",
          "outbound" : {
            "source" : {
              "path" : "$user/name"
            }
          }
        }, {
          "@id" : 3,
          "ref" : "ri:firstname",
          "outbound" : {
            "source" : {
              "path" : "$user/givenName"
            }
          }
        }, {
          "@id" : 4,
          "ref" : "ri:lastname",
          "outbound" : {
            "source" : {
              "path" : "$user/familyName"
            }
          }
        } ],
        "activation" : {
          "administrativeStatus" : {
            "outbound" : {
              "@id" : 5
            }
          }
        },
        "credentials" : {
          "password" : {
            "outbound" : {
              "@id" : 6
            }
          }
        }
      }
    },
    "capabilities" : {
      "configured" : {
        "activation" : {
          "status" : {
            "attribute" : "ri:disabled",
            "enableValue" : "false",
            "disableValue" : "true"
          }
        }
      }
    }
  }
}

Search for Resource Type Objects

Search operation usable for fetching the full list of objects or a list based on filter.

Search for All Resources With Name That Starts With 'a'
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/resources/search \
-v \
--data-binary @./samples/rest/query-gen-name.json
Show data source example for "Search for name starting with 'a'" | GitHub
{
  "query": {
    "filter": {
      "text": "name startsWith \"a\""
    }
  }
}

The response is an HTTP 200 code in case of success with a response body containing the queried items.

Example Output is a list of objects.
{
  "@ns" : "http://prism.evolveum.com/xml/ns/public/types-3",
  "object" : {
    "@type" : "http://midpoint.evolveum.com/xml/ns/public/common/api-types-3#ObjectListType",
    "object" : [ {
      "@type" : "",
      "oid" : "",
      "version" : "",
      "name" : "",
      "metadata" : {},
      "operationExecution": {},
      "indestructible": ,
      "iteration" : ,
      "iterationToken" : "",
      "archetypeRef": {},
      "roleMembershipRef": {},
      "activation": {}
    }, {
      "@type" : "",
      "oid" : "",
      "version" : "",
      "name" : "",
      "metadata" : {},
      "operationExecution": {},
      "indestructible": ,
      "iteration" : ,
      "iterationToken" : "",
      "archetypeRef": {},
      "roleMembershipRef": {},
      "activation": {}
    } ]
  }
}

Modify Resource Type Objects

Modify Resource
curl --user administrator:y0uR_P455woR*d \
-H "Content-Type: application/json" \
-X PATCH http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc \
-v \
--data-binary @./samples/rest/modify-attribute-resource.json -v
Show data source example for "Modify resource capability" | GitHub
{
  "objectModification": {
    "itemDelta": {
      "modificationType": "replace",
      "path": "capabilities/configured/delete/enabled/",
      "value": false
    }
  }
}

The response is an HTTP 204 code in case of success without a response body.

Delete Resource Type Objects

Delete a Resource type object
curl --user administrator:y0uR_P455woR*d \
-v \
-X DELETE http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc

The response is an HTTP 204 code in case of success without a response body.

Generate and Validate Operations for Resource Type Objects

Operations to generate or validate values.

Operations specific for Resources

Execute the Test Operation for a Resource Object in MidPoint
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc/test \
-v

The response is an HTTP 200 code in case of success with a response body containing the operation result.

Example Output of "Test Resource object" example

The example is simplified, some properties were removed to keep the example output "short". This example does not contain all possible properties of this object type.

{
  "@ns" : "http://prism.evolveum.com/xml/ns/public/types-3",
  "object" : {
    "@type" : "c:OperationResultType",
    "operation" : "com.evolveum.midpoint.schema.constants.TestResourceOpNames.test",
    "status" : "success",
    "importance" : "normal",
    "start" : "",
    "end" : "",
    "microseconds" :,
    "invocationId" :,
    "params" : {
      "entry" : []
    },
    "token" :,
    "partialResults" : [ {}, {} ]
  }
}
Execute the import operation for a Resource object in MidPoint
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc/import/AccountObjectClass \
-v

The response is an HTTP 303 code in case of success without a response body. Yet there is a location header which can be used for a redirect. The object which is referred is a task used for asynchronous execution of the import operation. Please see this link for more information on the tasks endpoint.

Example Location Header of "Import Operation from Resource object" example
Location: http://localhost:8080/midpoint/ws/rest/tasks/31e60ee4-8bb9-4a8d-a001-88ef6191d4ee

Common Use-case Examples

JSON Example

Example output of information regarding a specific object. Some data vas omitted to simplify the example.

Show JSON Example
{
  "resource" : {
    "oid" : "ef2bc95b-76e0-59e2-86d6-9999cccccccc",
    "version" : "1",
    "name" : "Test CSV: username",
    "description" : "Simple CSV resource that is using single identifier (username)",
    "metadata" : {},
    "operationExecution" : {},
    "iteration" : 0,
    "iterationToken" : "",
    "connectorRef" : {
      "oid" : "01aa0a9e-dfe0-47c8-8fca-4446894a348c",
      "relation" : "org:default",
      "type" : "c:ConnectorType",
      "filter" : {
        "equal" : {
          "path" : "c:connectorType",
          "value" : "com.evolveum.polygon.connector.csv.CsvConnector"
        }
      }
    },
    "connectorConfiguration" : {
      "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3",
      "configurationProperties" : {
        "@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector",
        "multivalueDelimiter" : ";",
        "fieldDelimiter" : ",",
        "filePath" : "target/midpoint.csv",
        "encoding" : "utf-8",
        "passwordAttribute" : "password",
        "uniqueAttribute" : "username"
      }
    },
    "schemaHandling" : {
      "objectType" : {
        "@id" : 1,
        "displayName" : "Default Account",
        "default" : true,
        "objectClass" : "ri:AccountObjectClass",
        "attribute" : [ {
          "@id" : 2,
          "ref" : "ri:username",
          "outbound" : {
            "source" : {
              "path" : "$user/name"
            }
          }
        }, {
          "@id" : 3,
          "ref" : "ri:firstname",
          "outbound" : {
            "source" : {
              "path" : "$user/givenName"
            }
          }
        }, {
          "@id" : 4,
          "ref" : "ri:lastname",
          "outbound" : {
            "source" : {
              "path" : "$user/familyName"
            }
          }
        } ],
        "activation" : {
          "administrativeStatus" : {
            "outbound" : {
              "@id" : 5
            }
          }
        },
        "credentials" : {
          "password" : {
            "outbound" : {
              "@id" : 6
            }
          }
        }
      }
    },
    "capabilities" : {
      "configured" : {
        "activation" : {
          "status" : {
            "attribute" : "ri:disabled",
            "enableValue" : "false",
            "disableValue" : "true"
          }
        }
      }
    }
  }
}
Was this page helpful?
YES NO
Thanks for your feedback