Skip to content

feat: Add filterType property to work item and work item template APIs models - #228

Draft
gokulprasanth-ni wants to merge 1 commit into
masterfrom
users/gokulprasanthRavi/add-filter-type-support-to-workitems-client
Draft

feat: Add filterType property to work item and work item template APIs models#228
gokulprasanth-ni wants to merge 1 commit into
masterfrom
users/gokulprasanthRavi/add-filter-type-support-to-workitems-client

Conversation

@gokulprasanth-ni

Copy link
Copy Markdown

What does this Pull Request accomplish?

Add filterType property to resource models in work item and template APIs

Why should this Pull Request be merged?

This support makes it easier for the users to create work items with either Linq or Lucene resource filters

What testing has been done?

Automated integration tests are included.

Signed-off-by: gokulprasanth-ni <gokulprasanth.ravi@emerson.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is additive, follows existing JsonModel camelCase serialization conventions, and includes integration test coverage plus updated examples for the new field.

Pull request overview

Adds a filterType/filter_type field to Work Item and Work Item Template resource models so callers can explicitly indicate whether resource filters are interpreted as LINQ or LUCENE, and updates integration tests/examples to exercise and document the new behavior.

Changes:

  • Introduces FilterType enum and adds filter_type to ResourcesDefinition and TemplateResourcesDefinition (serialized as filterType).
  • Extends query projection enums with RESOURCES_FILTER_TYPE for both work items and templates.
  • Updates integration tests and examples to set and validate filter_type (and adjusts sample filter strings accordingly).
File summaries
File Description
tests/integration/work_item/test_work_item_client.py Adds integration coverage for create/update/query behaviors involving resources.filter_type and updates sample filters.
nisystemlink/clients/work_item/models/_resources_definition.py Adds FilterType enum plus filter_type fields to resource definition models.
nisystemlink/clients/work_item/models/_query_work_items_request.py Adds WorkItemField.RESOURCES_FILTER_TYPE projection field.
nisystemlink/clients/work_item/models/_query_work_item_templates_request.py Adds WorkItemTemplateField.RESOURCES_FILTER_TYPE projection field.
nisystemlink/clients/work_item/models/init.py Exports FilterType from the public models package.
examples/work_item/work_items.py Demonstrates setting filter_type for work item create/update resource filters.
examples/work_item/work_item_templates.py Demonstrates setting filter_type for template resource filters and updates.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.



class FilterType(str, Enum):
"""The type of filter used to select the resources for the work item."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""The type of filter used to select the resources for the work item."""
"""Query language used to interpret resource filters in the reservation."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly update in other places.

Comment on lines +10 to +11
LINQ = "LINQ"
LUCENE = "LUCENE"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LINQ = "LINQ"
LUCENE = "LUCENE"
LUCENE = "LUCENE"
LINQ = "LINQ"

Since Lucene is the default FilterType, we could place it first.

],
filter='modelName = "cRIO-9045" && serialNumber = "01E82ED0"',
),
filter_type=FilterType.LINQ,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filter_type=FilterType.LINQ,
filter_type="LINQ",

This is more readable and reflect the usage, can we update it in all 4 places in examples?

Image Image

name="Updated work item",
resources=ResourcesDefinition(
systems=SystemResourceDefinition(
filter='properties.data["Lab"] = "Battery Pack Lab"',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filter='properties.data["Lab"] = "Battery Pack Lab"',
filter='properties.data["Location"] = "Lab 1"',

This filter is already set in the create request model. Are we using the update API to set it again here?

same applies for templates example as well.

filter="os:linux AND arch:x64",
filter='os = "linux" && arch = "x64"',
),
filter_type=FilterType.LINQ,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filter_type=FilterType.LINQ,
filter_type="LINQ",

)
assert delete_work_item_template_response is None

def test__create_work_item__returns_resources_with_filter_type(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, field-level validations (like asserting the response contains expected filter_type) are already covered by the service that the client calls. Our integration tests should only verify that the client correctly wires the request/response and deserializes the fields and don't throw error.

Other integration clients typically use focused assertions rather than validating every field in every response, so having a separate filter-type-specific test for each API feels inconsistent.

We could add the filter_type assertion to the existing update work items and templates tests alone, since the LINQ → LUCENE transition verifies the mutation behavior, and remove all the dedicated tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants