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

Fetch asset property info if assetId and propertyId are available #192

Merged
merged 1 commit into from
May 24, 2023

Conversation

kevinwcyu
Copy link
Contributor

@kevinwcyu kevinwcyu commented May 23, 2023

Extracted from this PR https://github.com/grafana/iot-sitewise-datasource/pull/190/files#r1197884481

Update Property method in pkg/resource/sitewise.go so it will call DescribeAssetPropertyWithContext as long as an asset id and property id is available. Previously, it would not call DescribeAssetPropertyWithContext if propertyAlias was not an empty string, but now that we get the asset id and property id from the alias, we can call DescribeAssetPropertyWithContext. You can see the test output files now have the asset name and property names in them e.g. "Demo Turbine Asset 1" and "Average Wind Speed".

@kevinwcyu kevinwcyu requested a review from a team as a code owner May 23, 2023 17:53
@kevinwcyu kevinwcyu requested review from fridgepoet and sarahzinger and removed request for a team May 23, 2023 17:53
@github-actions
Copy link

github-actions bot commented May 23, 2023

Levitate is-compatible report:

🔍 Resolving @grafana/data@latest...
🔍 Resolving @grafana/ui@latest...
🔍 Resolving @grafana/runtime@latest...
🔍 Resolving @grafana/e2e-selectors@latest...

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/data version 9.2.5 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/ui version 9.2.5 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/runtime version 9.2.5 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/[email protected]...
✔ Found @grafana/e2e-selectors version 9.2.5 locally

✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/e2e-selectors

Copy link
Contributor

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

LGTM, assuming the answer to my question is yes

@@ -28,7 +28,7 @@ func (rp *SitewiseResources) Asset(ctx context.Context, assetId string) (*iotsit
}

func (rp *SitewiseResources) Property(ctx context.Context, assetId string, propertyId string, propertyAlias string) (*iotsitewise.DescribeAssetPropertyOutput, error) {
if propertyAlias != "" {
if propertyAlias != "" && (assetId == "" && propertyId == "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Silly question maybe, but is it a given that if assetId != "" that propertyId != "" and visa-versa?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, an asset property is identified by either an alias or (asset id and property id).

@kevinwcyu kevinwcyu merged commit 821ff5c into main May 24, 2023
@kevinwcyu kevinwcyu deleted the kevinwcyu/call-describe-asset-property branch May 24, 2023 21:17
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