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

Adds business services, services dependencies, custom fields and service id filters #50

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sam-io
Copy link

@sam-io sam-io commented May 7, 2024

Overview

Tables and columns

This PR introduces the following changes:

  • New table pagerduty_business_service that returns data from the pagerduty business services api.
  • New column dependencies on the pagerduty_service table that contains service dependencies of a service.
  • New column service_id on the 'pagerduty_incident' table that maps to the service_ids[] query parameter in the list incidents API.
  • New column custom_fields on the 'pagerduty_incident' table that contains custom field values for an incident.
  • New column impacted_business_services on the 'pagerduty_incident' table that contains business services that are impacted by an incident.

Additional Changes

In addition to these changes the pagerduty api client is updated to the latest version.

Notes

There are some APIs that are supported by pagerduty but are not implemented by the pagerduty API client. These include:

Support for these has been included by introducing an ExtendedPagerDutyClient type that implements functions to call these APIs and return the results as a basic map[string]interface{} that is sufficient for mapping to a table.

Example query results

pagerduty_business_service

Listing all business services

select * from pagerduty_business_service
Results
+--------------------+---------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+------------------+-------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+---------------------------------------------------------------------+
| name               | id      | self                                                | description                                                                                                                                                                                                | html_url | point_of_contact | team                                                                                      | dependencies                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | title              | _ctx                                                                |
+--------------------+---------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+------------------+-------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+---------------------------------------------------------------------+
| Vostok             | PTS3FM5 | https://api.pagerduty.com/business_services/PTS3FM5 | The Vostok program was a project that succeeded in putting a person into orbit for the first time. Sergei Korolev and Konstantin Feoktistov began, in June 1956, crewed spacecraft research.               | <null>   | <null>           | <null>                                                                                    | [{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDEQZ","supporting_service":{"id":"P703E9Q","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFN4","supporting_service":{"id":"PR6MHNF","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFN7","supporting_service":{"id":"PQVUB8D","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFSW","supporting_service":{"id":"PG6HW8H","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","r | Vostok             | {"connection_name":"pagerduty","steampipe":{"sdk_version":"5.8.0"}} |
|                    |         |                                                     |                                                                                                                                                                                                            |          |                  |                                                                                           | elationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDIVU","supporting_service":{"id":"P8SWW3O","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDIW5","supporting_service":{"id":"POQPQDZ","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9B","supporting_service":{"id":"PJCSLRA","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9I","supporting_service":{"id":"P0KV854","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_serv |                    |                                                                     |
|                    |         |                                                     |                                                                                                                                                                                                            |          |                  |                                                                                           | ice_reference"},"id":"DDLF5T6Y5IHT2SDQ9K","supporting_service":{"id":"PYLH6O8","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9L","supporting_service":{"id":"PBSK1OX","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9O","supporting_service":{"id":"PNDPEF1","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PTS3FM5","relationships":null,"type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9X","supporting_service":{"id":"PBW2BWS","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"}]                                                                                                                        |                    |                                                                     |
| Crew Dragon Demo-2 | PVCX4Q7 | https://api.pagerduty.com/business_services/PVCX4Q7 | SpaceX Demo-2 (also referred to as SpaceX Demonstration Mission 2, or Demo-2) is the first crewed test flight of the Crew Dragon spacecraft. It launched on 30 May 2020 at 19:22:45 UTC (3:22:45 PM EDT).  | <null>   | <null>           | {"id":"PQZPQGI","self":"https://api.pagerduty.com/teams/PQZPQGI","type":"team_reference"} | []                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Crew Dragon Demo-2 | {"connection_name":"pagerduty","steampipe":{"sdk_version":"5.8.0"}} |
| Voskhod            | PO306GC | https://api.pagerduty.com/business_services/PO306GC | The Voskhod programme (Russian: Восхо́д, IPA: [vɐsˈxot], Ascent or Dawn) was the second Soviet human spaceflight project.                                                                                   | <null>   | <null>           | {"id":"PGVXG6U","self":"https://api.pagerduty.com/teams/PGVXG6U","type":"team_reference"} | []                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Voskhod            | {"connection_name":"pagerduty","steampipe":{"sdk_version":"5.8.0"}} |
| Mercury Project    | PF28J75 | https://api.pagerduty.com/business_services/PF28J75 | Project Mercury was the first human spaceflight program of the United States, running from 1958 through 1963.                                                                                              | <null>   | <null>           | {"id":"PQZPQGI","self":"https://api.pagerduty.com/teams/PQZPQGI","type":"team_reference"} | [{"dependent_service":{"id":"PF28J75","relationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIX","supporting_service":{"id":"PLK9E0W","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PF28J75","relationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIY","supporting_service":{"id":"PINLDO6","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PF28J75","relationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIZ","supporting_service":{"id":"PEBACYG","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PF28J75","relationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ1","supporting_service":{"id":"PXT1B73","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PF28J75","r | Mercury Project    | {"connection_name":"pagerduty","steampipe":{"sdk_version":"5.8.0"}} |
|                    |         |                                                     |                                                                                                                                                                                                            |          |                  |                                                                                           | elationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ2","supporting_service":{"id":"PQ7SZFQ","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"},{"dependent_service":{"id":"PF28J75","relationships":null,"type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ4","supporting_service":{"id":"P310DDP","relationships":null,"type":"technical_service_reference"},"type":"service_dependency"}]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                    |                                                                     |
+--------------------+---------+-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+------------------+-------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+---------------------------------------------------------------------+

pagerduty_service

Getting technical services along with their immediate dependencies

select id, dependencies from pagerduty_service
Results
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id      | dependencies                                                                                                                                                                                                  |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| P0KV854 | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9I","supporting_service":{"id":"P0KV854","type":"technical_service_reference"},"type":"service_dependency"}] |
| POQPQDZ | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDIW5","supporting_service":{"id":"POQPQDZ","type":"technical_service_reference"},"type":"service_dependency"}] |
| PYLH6O8 | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9K","supporting_service":{"id":"PYLH6O8","type":"technical_service_reference"},"type":"service_dependency"}] |
| P8SWW3O | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDIVU","supporting_service":{"id":"P8SWW3O","type":"technical_service_reference"},"type":"service_dependency"}] |
| PEBACYG | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIZ","supporting_service":{"id":"PEBACYG","type":"technical_service_reference"},"type":"service_dependency"}] |
| P310DDP | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ4","supporting_service":{"id":"P310DDP","type":"technical_service_reference"},"type":"service_dependency"}] |
| P18JCJH | []                                                                                                                                                                                                            |
| PR6MHNF | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFN4","supporting_service":{"id":"PR6MHNF","type":"technical_service_reference"},"type":"service_dependency"}] |
| PXT1B73 | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ1","supporting_service":{"id":"PXT1B73","type":"technical_service_reference"},"type":"service_dependency"}] |
| PBSK1OX | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9L","supporting_service":{"id":"PBSK1OX","type":"technical_service_reference"},"type":"service_dependency"}] |
| PG6HW8H | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFSW","supporting_service":{"id":"PG6HW8H","type":"technical_service_reference"},"type":"service_dependency"}] |
| PG9JLO3 | []                                                                                                                                                                                                            |
| PQVUB8D | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDFN7","supporting_service":{"id":"PQVUB8D","type":"technical_service_reference"},"type":"service_dependency"}] |
| P703E9Q | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDEQZ","supporting_service":{"id":"P703E9Q","type":"technical_service_reference"},"type":"service_dependency"}] |
| PINLDO6 | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIY","supporting_service":{"id":"PINLDO6","type":"technical_service_reference"},"type":"service_dependency"}] |
| PNDPEF1 | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9O","supporting_service":{"id":"PNDPEF1","type":"technical_service_reference"},"type":"service_dependency"}] |
| PQ7SZFQ | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYJ2","supporting_service":{"id":"PQ7SZFQ","type":"technical_service_reference"},"type":"service_dependency"}] |
| PJCSLRA | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9B","supporting_service":{"id":"PJCSLRA","type":"technical_service_reference"},"type":"service_dependency"}] |
| PBW2BWS | [{"dependent_service":{"id":"PTS3FM5","type":"business_service_reference"},"id":"DDLF5T6Y5IHT2SDQ9X","supporting_service":{"id":"PBW2BWS","type":"technical_service_reference"},"type":"service_dependency"}] |
| PLK9E0W | [{"dependent_service":{"id":"PF28J75","type":"business_service_reference"},"id":"DDMO3L6NTB3PPLQYIX","supporting_service":{"id":"PLK9E0W","type":"technical_service_reference"},"type":"service_dependency"}] |
| PU1BXAX | []                                                                                                                                                                                                            |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

pagerduty_incident

Listing incidents including custom field values and business services impacted by the incident

select id, service_id, custom_fields, impacted_business_services from pagerduty_incident 
Results
+----------------+------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id             | service_id | custom_fields                                                                                                                                                                                                                                    | impacted_business_services[]                                                                                                                                                             |
+----------------+------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| P1SBQWX        | PQ7SZFQ    | []                                                                                                                                                                                                                                               | []                                                                                                                                                                                       |
| Q18FXZURFJ46U1 | PU1BXAX    | []                                                                                                                                                                                                                                               | [{"id": "PD1234", "name": "Web API", "type": "business_service", "status": "impacted"},{"id": "PF9KMXH", "name": "Analytics Backend", "type": "business_service", "status": "impacted"}] |
| P1OGMH6        | PG6HW8H    | [{"id": "PT4KHEE", "type": "field_value", "name": "environment", "display_name": "Runtime Environment", "description": "environment where incident occurred", "data_type": "string", "field_type": "single_value_fixed", "value": "production"}] | []                                                                                                                                                                                       |
| PMN3VMG        | P703E9Q    | []                                                                                                                                                                                                                                               | []                                                                                                                                                                                       |
| P9UMCAE        | PQVUB8D    | []                                                                                                                                                                                                                                               | []                                                                                                                                                                                       |
+----------------+------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Getting incidents for a specific technical service
select id, service_id, custom_fields, impacted_business_services from pagerduty_incident where service_id = 'P703E9Q'"
Results
+---------+------------+---------------+----------------------------+
| id      | service_id | custom_fields | impacted_business_services |
+---------+------------+---------------+----------------------------+
| PMN3VMG | P703E9Q    | [{"id": "PT4KHEE", "type": "field_value", "name": "environment", "display_name": "Runtime Environment", "description": "environment where incident occurred", "data_type": "string", "field_type": "single_value_fixed", "value": "production"}] | []                         |
+---------+------------+---------------+----------------------------+

@misraved misraved self-requested a review May 8, 2024 06:08
@sam-io sam-io marked this pull request as ready for review May 11, 2024 09:36
@misraved
Copy link
Contributor

Thank you for the contribution @sam-io and welcome to Steampipe 👍 !!

Could you please take a look at the lint failure:

  Running [/home/runner/golangci-lint-1.58.1-linux-amd64/golangci-lint run --out-format=github-actions --timeout=10m] in [] ...
  Error: SA1019: pagerduty.Priorities is deprecated: Use type ListPrioritiesResponse instead; will be removed in V2  (staticcheck)
  Error: SA1019: client.ListMembersPaginated is deprecated: Use ListTeamMembersPaginated instead.  (staticcheck)

Additionally, since we have an SDK update, I believe it is worth checking for breaking changes that might affect the plugin's original functionality. I would recommend verifying that the old tables work consistently with the new SDK without altering the results 👍.

@sam-io
Copy link
Author

sam-io commented May 14, 2024

Thank you @misraved I have fixed the lint issues and checked for possible breaking changes by looking through the change log and comparing the output of the old and new version of the plugin. I did not find any changes that could cause compatibility issues.

Copy link

@ParthaI ParthaI left a comment

Choose a reason for hiding this comment

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

Hello @sam-io,

The changes look good to me overall. However, could you please address the following points?

  • Could you update the hydrate function names to use the prefixes get or list instead of hydrate to maintain consistency?
  • Could you replace our custom function:
  • Could you structure the API response based on the data returned by the API?
    • Currently, all custom API calls return a structure map[string]interface{}.
    • Can we tie up the custom API calls with a Go structure to visualize the API response better?
    • This way, if the response changes from the API end in the future, we can clearly identify the missing fields.

Thank you!

@@ -175,6 +180,26 @@ func tablePagerDutyIncident(_ context.Context) *plugin.Table {
Description: "The teams involved in the incident's lifecycle.",
Type: proto.ColumnType_JSON,
},
{
Name: "service_id",
Copy link

Choose a reason for hiding this comment

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

Could you please arrange the columns by column type, moving the JSON columns towards the bottom and placing the other columns towards the top?

@misraved
Copy link
Contributor

Hi @sam-io, did you get a chance to address the review comments from @ParthaI?

Please feel free to ask questions or reach out if you need any clarification or assistance. Happy to help 👍 !!

Looking forward to your updates.

Thanks!!

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