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

Add definitions and types for incidents, users #3

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

rliddler
Copy link
Contributor

@rliddler rliddler commented Oct 18, 2023

This is a bit of a slog PR adding a number of types each with a Schema and Serialize method.

We want to control what we add to the schema, and what we then write out. Some fields are deprecated (not a lot) and this gives us control.

This will currently export all incident fields for the incidents v2 API and their nested structures (I believe!).

Mega dump of the catalog.json for these schemas:

{
  "streams": [
    {
      "stream": "incidents",
      "tap_stream_id": "incidents",
      "schema": {
        "type": [
          "object"
        ],
        "additionalProperties": false,
        "properties": {
          "call_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string"
            ],
            "format": "date-time"
          },
          "creator": {
            "type": [
              "object"
            ],
            "properties": {
              "api_key": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string"
                    ]
                  },
                  "name": {
                    "type": [
                      "string"
                    ]
                  }
                }
              },
              "user": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "email": {
                    "type": [
                      "null",
                      "string"
                    ]
                  },
                  "id": {
                    "type": [
                      "string"
                    ]
                  },
                  "name": {
                    "type": [
                      "string"
                    ]
                  },
                  "slack_user_id": {
                    "type": [
                      "null",
                      "string"
                    ]
                  }
                }
              }
            }
          },
          "custom_field_entries": {
            "type": [
              "array"
            ],
            "items": {
              "type": "object",
              "properties": {
                "custom_field": {
                  "type": [
                    "object"
                  ],
                  "properties": {
                    "description": {
                      "type": [
                        "string"
                      ]
                    },
                    "field_type": {
                      "type": [
                        "string"
                      ]
                    },
                    "id": {
                      "type": [
                        "string"
                      ]
                    },
                    "name": {
                      "type": [
                        "string"
                      ]
                    },
                    "options": {
                      "type": [
                        "array"
                      ],
                      "items": {
                        "type": "object",
                        "properties": {
                          "custom_field_id": {
                            "type": [
                              "string"
                            ]
                          },
                          "id": {
                            "type": [
                              "string"
                            ]
                          },
                          "sort_key": {
                            "type": [
                              "integer"
                            ]
                          },
                          "value": {
                            "type": [
                              "string"
                            ]
                          }
                        }
                      }
                    }
                  }
                },
                "values": {
                  "type": [
                    "array"
                  ],
                  "items": {
                    "type": "object",
                    "properties": {
                      "value_catalog_entry": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "aliases": {
                            "type": [
                              "array",
                              "null"
                            ]
                          },
                          "external_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "id": {
                            "type": [
                              "string"
                            ]
                          },
                          "name": {
                            "type": [
                              "string"
                            ]
                          }
                        }
                      },
                      "value_link": {
                        "type": [
                          "null",
                          "string"
                        ]
                      },
                      "value_numeric": {
                        "type": [
                          "null",
                          "number"
                        ]
                      },
                      "value_option": {
                        "type": [
                          "object",
                          "null"
                        ],
                        "properties": {
                          "custom_field_id": {
                            "type": [
                              "string"
                            ]
                          },
                          "id": {
                            "type": [
                              "string"
                            ]
                          },
                          "sort_key": {
                            "type": [
                              "integer"
                            ]
                          },
                          "value": {
                            "type": [
                              "string"
                            ]
                          }
                        }
                      },
                      "value_text": {
                        "type": [
                          "null",
                          "string"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "external_issue_reference": {
            "type": [
              "object",
              "null",
              "null"
            ],
            "properties": {
              "issue_name": {
                "type": [
                  "string"
                ]
              },
              "issue_permalink": {
                "type": [
                  "string"
                ]
              },
              "provider": {
                "type": [
                  "string"
                ]
              }
            }
          },
          "id": {
            "type": [
              "string"
            ]
          },
          "incident_role_assignments": {
            "type": [
              "array"
            ],
            "items": {
              "type": "object",
              "properties": {
                "assignee": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "email": {
                      "type": [
                        "null",
                        "string"
                      ]
                    },
                    "id": {
                      "type": [
                        "string"
                      ]
                    },
                    "name": {
                      "type": [
                        "string"
                      ]
                    },
                    "slack_user_id": {
                      "type": [
                        "null",
                        "string"
                      ]
                    }
                  }
                },
                "role": {
                  "type": [
                    "object"
                  ],
                  "properties": {
                    "created_at": {
                      "type": [
                        "string"
                      ],
                      "format": "date-time"
                    },
                    "description": {
                      "type": [
                        "string"
                      ]
                    },
                    "id": {
                      "type": [
                        "string"
                      ]
                    },
                    "instructions": {
                      "type": [
                        "string"
                      ]
                    },
                    "name": {
                      "type": [
                        "string"
                      ]
                    },
                    "required": {
                      "type": [
                        "boolean"
                      ]
                    },
                    "role_type": {
                      "type": [
                        "string"
                      ]
                    },
                    "short_form": {
                      "type": [
                        "string"
                      ]
                    },
                    "updated_at": {
                      "type": [
                        "string"
                      ],
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "incident_status": {
            "type": [
              "object"
            ],
            "properties": {
              "category": {
                "type": [
                  "string"
                ]
              },
              "created_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              },
              "description": {
                "type": [
                  "string"
                ]
              },
              "id": {
                "type": [
                  "string"
                ]
              },
              "name": {
                "type": [
                  "string"
                ]
              },
              "rank": {
                "type": [
                  "integer"
                ]
              },
              "updated_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              }
            }
          },
          "incident_timestamp_values": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "incident_timestamp": {
                  "type": [
                    "object"
                  ],
                  "properties": {
                    "id": {
                      "type": [
                        "string"
                      ]
                    },
                    "name": {
                      "type": [
                        "string"
                      ]
                    },
                    "rank": {
                      "type": [
                        "integer"
                      ]
                    }
                  }
                },
                "value": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "value": {
                      "type": [
                        "string"
                      ],
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "incident_type": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "create_in_triage": {
                "type": [
                  "string"
                ]
              },
              "created_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              },
              "description": {
                "type": [
                  "string"
                ]
              },
              "id": {
                "type": [
                  "string"
                ]
              },
              "is_default": {
                "type": [
                  "boolean"
                ]
              },
              "name": {
                "type": [
                  "string"
                ]
              },
              "private_incidents_only": {
                "type": [
                  "boolean"
                ]
              },
              "updated_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              }
            }
          },
          "mode": {
            "type": [
              "string"
            ]
          },
          "name": {
            "type": [
              "string"
            ]
          },
          "permalink": {
            "type": [
              "string",
              "null"
            ]
          },
          "postmortem_document_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string"
            ]
          },
          "severity": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "created_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              },
              "description": {
                "type": [
                  "string"
                ]
              },
              "id": {
                "type": [
                  "string"
                ]
              },
              "name": {
                "type": [
                  "string"
                ]
              },
              "rank": {
                "type": [
                  "integer"
                ]
              },
              "updated_at": {
                "type": [
                  "string"
                ],
                "format": "date-time"
              }
            }
          },
          "slack_channel_id": {
            "type": [
              "string"
            ]
          },
          "slack_channel_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "slack_team_id": {
            "type": [
              "string"
            ]
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string"
            ],
            "format": "date-time"
          },
          "visibility": {
            "type": [
              "string"
            ]
          },
          "workload_minutes_late": {
            "type": [
              "number",
              "null"
            ]
          },
          "workload_minutes_sleeping": {
            "type": [
              "number",
              "null"
            ]
          },
          "workload_minutes_total": {
            "type": [
              "number",
              "null"
            ]
          },
          "workload_minutes_working": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      }
    },
    {
      "stream": "users",
      "tap_stream_id": "users",
      "schema": {
        "type": [
          "object"
        ],
        "additionalProperties": false,
        "properties": {
          "email": {
            "type": [
              "null",
              "string"
            ]
          },
          "id": {
            "type": [
              "string"
            ]
          },
          "name": {
            "type": [
              "string"
            ]
          },
          "slack_user_id": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      }
    }
  ]
}

This is a bit of a slog PR adding a number of types each with a Schema
and Serialize method.

We want to control what we add to the schema, and what we then write
out. Some fields are deprecated (not a lot) and this gives us control.

This will currently export all incident fields for the incidents v2 API
and their nested structures.
@rliddler rliddler force-pushed the rob/fillout-rest-of-incidents-api branch from 1ecfcb6 to e6798be Compare October 18, 2023 11:23
@isaacseymour isaacseymour merged commit a39fc89 into master Oct 18, 2023
@isaacseymour isaacseymour deleted the rob/fillout-rest-of-incidents-api branch October 18, 2023 13:16
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