diff --git a/src/posit/connect/jobs.py b/src/posit/connect/jobs.py index 69fb38af..e060e4f1 100644 --- a/src/posit/connect/jobs.py +++ b/src/posit/connect/jobs.py @@ -95,6 +95,7 @@ def find_by( key: str = ..., remote_id: str | None = ..., app_id: str = ..., + content_id: str = ..., variant_id: str = ..., bundle_id: str = ..., # Timestamps @@ -129,6 +130,9 @@ def find_by( Identifier for off-host execution configurations. app_id : str, not required Identifier of the parent content associated with the job. + This field is deprecated and has been renamed to content_id. + content_id : str, not required + Identifier of the parent content associated with the job. variant_id : str, not required Identifier of the variant responsible for the job. bundle_id : str, not required diff --git a/src/posit/connect/packages.py b/src/posit/connect/packages.py index af108e84..56efb623 100644 --- a/src/posit/connect/packages.py +++ b/src/posit/connect/packages.py @@ -92,6 +92,8 @@ def fetch( bundle_id: str = ..., app_id: str = ..., app_guid: str = ..., + content_id: str = ..., + content_guid: str = ..., ) -> Iterable[Package]: """ Fetch all records matching the specified conditions. @@ -110,8 +112,14 @@ def fetch( The unique identifier of the bundle this package is associated with. app_id: str, not required The numerical identifier of the application this package is associated with. + This field is deprecated and has been renamed to content_id. app_guid: str, not required The unique identifier of the application this package is associated with. + This field is deprecated and has been renamed to content_guid. + content_id: str, not required + The numerical identifier of the content item this package is associated with. + content_guid: str, not required + The unique identifier of the content item this package is associated with. Returns ------- @@ -130,6 +138,8 @@ def find_by( bundle_id: str = ..., app_id: str = ..., app_guid: str = ..., + content_id: str = ..., + content_guid: str = ..., ) -> Package | None: """ Find the first record matching the specified conditions. @@ -150,8 +160,14 @@ def find_by( The unique identifier of the bundle this package is associated with. app_id: str, not required The numerical identifier of the application this package is associated with. + This field is deprecated and has been renamed to content_id. app_guid: str, not required The unique identifier of the application this package is associated with. + This field is deprecated and has been renamed to content_guid. + content_id: str, not required + The numerical identifier of the content item this package is associated with. + content_guid: str, not required + The unique identifier of the content item this package is associated with. Returns ------- diff --git a/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json b/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json index b497e465..a4c34f4b 100644 --- a/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json +++ b/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json @@ -6,6 +6,7 @@ "key": "tHawGvHZTosJA2Dx", "remote_id": "S3ViZXJuZXRlczpyZW5kZXItci1tYXJrZG93bi1zaXRlLWtnODJo", "app_id": "54", + "content_id": "54", "variant_id": "54", "bundle_id": "54", "start_time": "2006-01-02T15:04:05-07:00", diff --git a/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs/tHawGvHZTosJA2Dx.json b/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs/tHawGvHZTosJA2Dx.json index c1ca8446..5ea1d580 100644 --- a/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs/tHawGvHZTosJA2Dx.json +++ b/tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs/tHawGvHZTosJA2Dx.json @@ -5,6 +5,7 @@ "key": "tHawGvHZTosJA2Dx", "remote_id": "S3ViZXJuZXRlczpyZW5kZXItci1tYXJrZG93bi1zaXRlLWtnODJo", "app_id": "54", + "content_id": "54", "variant_id": "54", "bundle_id": "54", "start_time": "2006-01-02T15:04:05-07:00", diff --git a/tests/posit/connect/__api__/v1/packages.json b/tests/posit/connect/__api__/v1/packages.json index a259eef1..4e630de3 100644 --- a/tests/posit/connect/__api__/v1/packages.json +++ b/tests/posit/connect/__api__/v1/packages.json @@ -3,7 +3,11 @@ { "language": "python", "name": "posit", - "version": "0.6.0" + "version": "0.6.0", + "app_id": "123", + "app_guid": "abcd-1234", + "content_id": "123", + "content_guid": "abcd-1234" } ], "current_page": 1, diff --git a/tests/posit/connect/test_jobs.py b/tests/posit/connect/test_jobs.py index 802dd850..aabde207 100644 --- a/tests/posit/connect/test_jobs.py +++ b/tests/posit/connect/test_jobs.py @@ -90,6 +90,33 @@ def test(self): assert job assert job["key"] == "tHawGvHZTosJA2Dx" + @responses.activate + def test_with_content_id(self): + responses.get( + "https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066", + json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066.json"), + ) + + responses.get( + "https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs", + json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json"), + ) + + c = Client("https://connect.example", "12345") + content = c.content.get("f2f37341-e21d-3d80-c698-a935ad614066") + + # Test with content_id (new field) + job = content.jobs.find_by(content_id="54") + assert job + assert job["content_id"] == "54" + assert job["app_id"] == "54" # Should have both fields + + # Test with app_id (deprecated field) + job = content.jobs.find_by(app_id="54") + assert job + assert job["app_id"] == "54" + assert job["content_id"] == "54" # Should have both fields + class TestJobDestory: @responses.activate diff --git a/tests/posit/connect/test_packages.py b/tests/posit/connect/test_packages.py index 2f1917a5..8b68f4f4 100644 --- a/tests/posit/connect/test_packages.py +++ b/tests/posit/connect/test_packages.py @@ -20,3 +20,25 @@ def test(self): assert package assert package["name"] == "posit" assert mock_get.call_count == 1 + + @responses.activate + def test_with_content_fields(self): + mock_get = responses.get( + "https://connect.example/__api__/v1/packages", + json=load_mock("v1/packages.json"), + ) + + c = Client("https://connect.example", "12345") + c._ctx.version = None + + # Test with content_id and content_guid (new fields) + package = c.packages.find_by(name="posit", content_id="123", content_guid="abcd-1234") + assert package + assert package["name"] == "posit" + assert mock_get.call_count == 1 + + # Test with app_id and app_guid (deprecated fields) + package = c.packages.find_by(name="posit", app_id="123", app_guid="abcd-1234") + assert package + assert package["name"] == "posit" + assert mock_get.call_count == 2