Patch Source App with Python SDK

Hi All,

I am trying to use the Python SDK to add an Access Profile to an existing SourceApp using the patch_source_app method.

When I try:

source_app = AppsApi(api_client).patch_source_app(
                              source_app_id, 
                              [{ "op": "add", 
                                  "path": "/accessProfiles/-", 
                                  "value": {
                                            "type": "ACCESS_PROFILE", 
                                             "id": "eaf17124b594ed786ddd31132334fbe",
                                             "name": "AP-1"}
                                    }])

or

source_app = AppsApi(api_client).patch_source_app(
                            source_app_id, 
                            [{ "op": "add", 
                             "path": "/accessProfiles/-", 
                            "value": {"id": "eaf17124b594ed786ddd31132334fbe"}}])

The error I am getting is error:
“The server did not find a current representation for the target resource”

I have also tried to marshal the dictionary into a JsonPatchOperation and send it that way but same issue.

Also, if I try like this - which is similar to be the way the API docs show:

 source_app = AppsApi(api_client).patch_source_app(
                                 source_app_id, 
                                 [{ "op": "add", 
                                     "path": "/accessProfiles/-", 
                                     "value": "eaf17124b594ed786ddd31132334fbe"
                                  }])

I get the following (Pydantic?) type error:

“Failed to patch source app: 1 validation error for AppsApi.patch_source_app 2.0.value Input should be a valid dictionary or instance of UpdateMultiHostSourcesRequestInnerValue [type=model_type, input_value=‘eaf17124b594ed786ddd31132334fbe’, input_type=str]”

If anyone has an example of what the JSON patch object and path should look like I would appreciate any help.

I can patch the SourceApp successfully with normal Python requests like so:

    with session as s:
        url = f"{base_url}/beta/source-apps/50b16b4225548ceb8cdfb38335d4b69"
        data = '[{ "op": "add", "path": "/accessProfiles/-", "value": "eaf17124b594ed786ddd31132334fbe" }]'

        headers = {
            "Authorization": f"Bearer {access_token}",
            "cache-control": "no-cache",
            "Accept": "application/json",
            "Content-Type": "application/json-patch+json",
        }

        try:
            response = s.patch(url=url, data=data, headers=headers)

I have referenced the following and have read the SDK code base but cannot figure it out:

OK, this example works:

    from sailpoint.v2024.api.apps_api import AppsApi
    from sailpoint.v2024.models.json_patch_operation import JsonPatchOperation

                    patch_list = []
                    patch_list.append(
                        JsonPatchOperation.from_dict(
                            {
                                "op": "add",
                                "path": "/accessProfiles/-",
                                "value": "eaf17124b594ed786ddd31132334fbe",
                            }
                        )
                    )
                    try:
                        source_app: List[SourceApp] = AppsApi(
                            api_client
                        ).patch_source_app(source_app_id, patch_list)