Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev docs on how to use new object model #1054

Merged
merged 4 commits into from
Dec 22, 2022
Merged

Conversation

achantavy
Copy link
Contributor

Update the how-to-write-an-intel-module docs using the new cartography object model introduced in #1038.

r.lastupdated = $UpdateTag
```

#### Connecting different node types with the `_attach` pattern
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like their may be cases where we want to attach after loading. But in the cases I can think of, it's still best to transform the data and use a NodeSchema that properly defines those extra relationships.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, and yes that's the approach I would encourage.

It's also possible to first generate a query using selected_relationships and then load to that with additional data, but I don't have an example ready for that and that sounds complicated and I'm not ready to encourage that pattern in the doc yet.

As another example, `region: PropertyRef = PropertyRef('Region', set_in_kwargs=True)` tells the querybuilder to set a field called `region` on the `EMRCluster` node using a keyword argument called `Region` supplied to `cartography.client.core.tx.load_graph_data()`. `set_in_kwargs=True` is useful in cases where we want every object loaded by a single call to `load_graph_data()` to have the same value for a given attribute.


#### Defining relationships
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth adding an example here on the other_relationships, even if it's only pointing to the test cases we have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added below

@achantavy achantavy merged commit 585fc06 into master Dec 22, 2022
@achantavy achantavy deleted the updatemoduledoc branch December 22, 2022 23:07
@achantavy achantavy mentioned this pull request Jan 30, 2023
chandanchowdhury pushed a commit to juju4/cartography that referenced this pull request Jun 26, 2024
* Update dev docs on how to use new object model

* linter

* example of other_relationships
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.

2 participants