From 1f0285783a7bdf631fa86ba1ca96d46378797211 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 8 Sep 2023 20:06:35 +0000 Subject: [PATCH 1/2] feat: Update OpenAPI file replicated from Notehub --- openapi.yaml | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index cb7b886b..a97439d3 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3051,7 +3051,7 @@ components: description: Type of route. enum: ["http", "proxy", "google-function", "mqtt", "aws-lambda", "aws-lambda-with-access-key", "aws-sqs", "aws-sqs-with-access-key", "aws-sqs-fifo", "aws-sqs-fifo-with-access-key", "aws-iot-analytics", "radnote-radresp-fixed-survey", "radnote-radresp-mobile-survey", "azure-function", - "azure-function-with-key", "azure-service-bus-with-sas-token", "thingworx", "snowflake"] + "azure-function-with-key", "azure-service-bus-with-sas-token", "thingworx", "snowflake", "slack-bearer", "slack-webhook"] modified: type: string description: Last Modified @@ -3070,6 +3070,7 @@ components: - $ref: '#/components/schemas/azure' - $ref: '#/components/schemas/thingworx' - $ref: '#/components/schemas/snowflake' + - $ref: '#/components/schemas/slack' UserDbRoute: type: object @@ -3589,6 +3590,74 @@ components: description: Message to send, leave blank to use notefile. throttle_ms: type: integer + + slack: + description: Route settings specific to Slack routes. Only used for Slack route types + type: object + properties: + fleets: + type: array + items: + type: string + minItems: 0 + description: list of Fleet UIDs to apply route to, if any. If empty, applies to all Fleets + filter: + type: object + properties: + type: + type: string + description: What notefiles this route applies to. + enum: ["all", "include", "exclude"] + system_notefiles: + type: boolean + description: Whether system notefiles should be affected by this route + files: + type: array + items: + type: string + description: list of notefiles to filter. For instance, if 'type' is set to "include", will only affect files listed here + minItems: 0 + description: Route filtering settings + transform: + type: object + properties: + format: + type: string + description: Data transformation to apply. Only "jsonata" is valid for Snowflake routes + default: "jsonata" + jsonata: + type: string + description: JSONata transformation + throttle_ms: + type: integer + description: Minimum time between requests in Miliseconds + timeout: + type: integer + default: 15 + description: Timeout in seconds for each request + + slack_type: + type: string + description: The type of Slack message. Must be one of "slack-bearer" for Bearer Token or "slack-webhook" for Webhook messages + bearer: + type: string + description: The Bearer Token for Slack messaging, if the "slack-bearer" type is selected + example: xoxb-1234-56789abcdefghijklmnop + channel: + type : string + description: The Channel ID for Bearer Token method, if the "slack-bearer" type is selected + example: C8675309 + webhook_url: + type: string + description: The Webhook URL for Slack Messaging if the "slack-webhook" type is selected + example: https://hooks.slack.com/services/FOO4BAR/THIS4THAT/123xYzaBC456 + text: + type: string + description: The simple text message to be sent, if the blocks message field is not in use. Placeholders are available for this field. + example: "[.device] reported temp(s) of [.body.temp] at [.body.location]" + blocks: + type: string + description: The Blocks message to be sent. If populated, this field overrides the text field within the Slack Messaging API. Placeholders are available for this field. EnvironmentVariables: type: object From 339a6e16a7cf904321d02e802fbfb9ae759bdde7 Mon Sep 17 00:00:00 2001 From: Paige Niedringhaus Date: Mon, 11 Sep 2023 11:57:19 -0400 Subject: [PATCH 2/2] feat: generate new library from updated openapi file --- src/.openapi-generator/FILES | 3 + src/README.md | 1 + src/docs/Route.md | 4 + src/docs/RouteSchema.md | 83 +++++------ src/docs/Slack.md | 17 +++ src/src/index.js | 7 + src/src/model/Route.js | 12 ++ src/src/model/RouteSchema.js | 64 ++++++++- src/src/model/Slack.js | 262 +++++++++++++++++++++++++++++++++++ src/test/model/Slack.spec.js | 119 ++++++++++++++++ 10 files changed, 526 insertions(+), 46 deletions(-) create mode 100644 src/docs/Slack.md create mode 100644 src/src/model/Slack.js create mode 100644 src/test/model/Slack.spec.js diff --git a/src/.openapi-generator/FILES b/src/.openapi-generator/FILES index 5aa8a1ab..cf703304 100644 --- a/src/.openapi-generator/FILES +++ b/src/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/Route.md docs/RouteApi.md docs/RouteLogsApi.md docs/RouteSchema.md +docs/Slack.md docs/Snowflake.md docs/SnowflakeTransform.md docs/Thingworx.md @@ -164,6 +165,7 @@ src/model/Radresponder.js src/model/Role.js src/model/Route.js src/model/RouteSchema.js +src/model/Slack.js src/model/Snowflake.js src/model/SnowflakeTransform.js src/model/Thingworx.js @@ -171,3 +173,4 @@ src/model/TowerLocation.js src/model/Twilio.js src/model/UpdateFleetRequest.js src/model/UserDbRoute.js +test/model/Slack.spec.js diff --git a/src/README.md b/src/README.md index eb895a44..925addda 100644 --- a/src/README.md +++ b/src/README.md @@ -277,6 +277,7 @@ All URIs are relative to *https://api.notefile.net* - [NotehubJs.Role](docs/Role.md) - [NotehubJs.Route](docs/Route.md) - [NotehubJs.RouteSchema](docs/RouteSchema.md) +- [NotehubJs.Slack](docs/Slack.md) - [NotehubJs.Snowflake](docs/Snowflake.md) - [NotehubJs.SnowflakeTransform](docs/SnowflakeTransform.md) - [NotehubJs.Thingworx](docs/Thingworx.md) diff --git a/src/docs/Route.md b/src/docs/Route.md index a5d95bf0..d1de34ce 100644 --- a/src/docs/Route.md +++ b/src/docs/Route.md @@ -48,3 +48,7 @@ - `thingworx` (value: `"thingworx"`) - `snowflake` (value: `"snowflake"`) + +- `slack-bearer` (value: `"slack-bearer"`) + +- `slack-webhook` (value: `"slack-webhook"`) diff --git a/src/docs/RouteSchema.md b/src/docs/RouteSchema.md index 122a1ce9..8c597a87 100644 --- a/src/docs/RouteSchema.md +++ b/src/docs/RouteSchema.md @@ -2,42 +2,47 @@ ## Properties -| Name | Type | Description | Notes | -| -------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | -| **fleets** | **[String]** | list of Fleet UIDs to apply route to, if any. If empty, applies to all Fleets | [optional] | -| **filter** | [**HttpFilter**](HttpFilter.md) | | [optional] | -| **transform** | [**SnowflakeTransform**](SnowflakeTransform.md) | | [optional] | -| **throttleMs** | **Number** | | [optional] | -| **url** | **String** | | [optional] | -| **httpHeaders** | **{String: String}** | | [optional] | -| **disableHttpHeaders** | **Boolean** | | [optional] [default to false] | -| **timeout** | **Number** | Timeout in seconds for each request | [optional] [default to 15] | -| **token** | **String** | Optional authentication token | [optional] | -| **alias** | **String** | | [optional] | -| **broker** | **String** | | [optional] | -| **port** | **Number** | | [optional] | -| **username** | **String** | | [optional] | -| **password** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **topic** | **String** | | [optional] | -| **certificate** | **String** | Certificate with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **certificateName** | **String** | Name of certificate. | [optional] | -| **key** | **String** | Key with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **privateKeyName** | **String** | Name of PEM key. If omitted, defaults to \"present\" | [optional] [default to 'present'] | -| **region** | **String** | | [optional] | -| **accessKeyId** | **String** | | [optional] | -| **accessKeySecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **messageGroupId** | **String** | | [optional] | -| **messageDeduplicationId** | **String** | | [optional] | -| **channel** | **String** | | [optional] | -| **testApi** | **Boolean** | | [optional] [default to false] | -| **dataFeedKey** | **String** | | [optional] | -| **clientId** | **String** | | [optional] | -| **clientSecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **functionsKeySecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **sasPolicyName** | **String** | | [optional] | -| **sasPolicyKey** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **appKey** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | -| **organizationName** | **String** | | [optional] | -| **accountName** | **String** | | [optional] | -| **userName** | **String** | | [optional] | -| **pem** | **String** | PEM key with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| Name | Type | Description | Notes | +| -------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | +| **fleets** | **[String]** | list of Fleet UIDs to apply route to, if any. If empty, applies to all Fleets | [optional] | +| **filter** | [**HttpFilter**](HttpFilter.md) | | [optional] | +| **transform** | [**SnowflakeTransform**](SnowflakeTransform.md) | | [optional] | +| **throttleMs** | **Number** | Minimum time between requests in Miliseconds | [optional] | +| **url** | **String** | | [optional] | +| **httpHeaders** | **{String: String}** | | [optional] | +| **disableHttpHeaders** | **Boolean** | | [optional] [default to false] | +| **timeout** | **Number** | Timeout in seconds for each request | [optional] [default to 15] | +| **token** | **String** | Optional authentication token | [optional] | +| **alias** | **String** | | [optional] | +| **broker** | **String** | | [optional] | +| **port** | **Number** | | [optional] | +| **username** | **String** | | [optional] | +| **password** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **topic** | **String** | | [optional] | +| **certificate** | **String** | Certificate with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **certificateName** | **String** | Name of certificate. | [optional] | +| **key** | **String** | Key with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **privateKeyName** | **String** | Name of PEM key. If omitted, defaults to \"present\" | [optional] [default to 'present'] | +| **region** | **String** | | [optional] | +| **accessKeyId** | **String** | | [optional] | +| **accessKeySecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **messageGroupId** | **String** | | [optional] | +| **messageDeduplicationId** | **String** | | [optional] | +| **channel** | **String** | The Channel ID for Bearer Token method, if the \"slack-bearer\" type is selected | [optional] | +| **testApi** | **Boolean** | | [optional] [default to false] | +| **dataFeedKey** | **String** | | [optional] | +| **clientId** | **String** | | [optional] | +| **clientSecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **functionsKeySecret** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **sasPolicyName** | **String** | | [optional] | +| **sasPolicyKey** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **appKey** | **String** | This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **organizationName** | **String** | | [optional] | +| **accountName** | **String** | | [optional] | +| **userName** | **String** | | [optional] | +| **pem** | **String** | PEM key with \\n newlines. This value is input-only and will be omitted from the response and replaced with a placeholder | [optional] | +| **slackType** | **String** | The type of Slack message. Must be one of \"slack-bearer\" for Bearer Token or \"slack-webhook\" for Webhook messages | [optional] | +| **bearer** | **String** | The Bearer Token for Slack messaging, if the \"slack-bearer\" type is selected | [optional] | +| **webhookUrl** | **String** | The Webhook URL for Slack Messaging if the \"slack-webhook\" type is selected | [optional] | +| **text** | **String** | The simple text message to be sent, if the blocks message field is not in use. Placeholders are available for this field. | [optional] | +| **blocks** | **String** | The Blocks message to be sent. If populated, this field overrides the text field within the Slack Messaging API. Placeholders are available for this field. | [optional] | diff --git a/src/docs/Slack.md b/src/docs/Slack.md new file mode 100644 index 00000000..df6b187c --- /dev/null +++ b/src/docs/Slack.md @@ -0,0 +1,17 @@ +# NotehubJs.Slack + +## Properties + +| Name | Type | Description | Notes | +| -------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | +| **fleets** | **[String]** | list of Fleet UIDs to apply route to, if any. If empty, applies to all Fleets | [optional] | +| **filter** | [**HttpFilter**](HttpFilter.md) | | [optional] | +| **transform** | [**SnowflakeTransform**](SnowflakeTransform.md) | | [optional] | +| **throttleMs** | **Number** | Minimum time between requests in Miliseconds | [optional] | +| **timeout** | **Number** | Timeout in seconds for each request | [optional] [default to 15] | +| **slackType** | **String** | The type of Slack message. Must be one of \"slack-bearer\" for Bearer Token or \"slack-webhook\" for Webhook messages | [optional] | +| **bearer** | **String** | The Bearer Token for Slack messaging, if the \"slack-bearer\" type is selected | [optional] | +| **channel** | **String** | The Channel ID for Bearer Token method, if the \"slack-bearer\" type is selected | [optional] | +| **webhookUrl** | **String** | The Webhook URL for Slack Messaging if the \"slack-webhook\" type is selected | [optional] | +| **text** | **String** | The simple text message to be sent, if the blocks message field is not in use. Placeholders are available for this field. | [optional] | +| **blocks** | **String** | The Blocks message to be sent. If populated, this field overrides the text field within the Slack Messaging API. Placeholders are available for this field. | [optional] | diff --git a/src/src/index.js b/src/src/index.js index 9c71cc11..1d25485d 100644 --- a/src/src/index.js +++ b/src/src/index.js @@ -74,6 +74,7 @@ import Radresponder from "./model/Radresponder"; import Role from "./model/Role"; import Route from "./model/Route"; import RouteSchema from "./model/RouteSchema"; +import Slack from "./model/Slack"; import Snowflake from "./model/Snowflake"; import SnowflakeTransform from "./model/SnowflakeTransform"; import Thingworx from "./model/Thingworx"; @@ -505,6 +506,12 @@ export { */ RouteSchema, + /** + * The Slack model constructor. + * @property {module:model/Slack} + */ + Slack, + /** * The Snowflake model constructor. * @property {module:model/Snowflake} diff --git a/src/src/model/Route.js b/src/src/model/Route.js index fc7f788d..858fe8ce 100644 --- a/src/src/model/Route.js +++ b/src/src/model/Route.js @@ -285,6 +285,18 @@ Route["RouteTypeEnum"] = { * @const */ snowflake: "snowflake", + + /** + * value: "slack-bearer" + * @const + */ + "slack-bearer": "slack-bearer", + + /** + * value: "slack-webhook" + * @const + */ + "slack-webhook": "slack-webhook", }; export default Route; diff --git a/src/src/model/RouteSchema.js b/src/src/model/RouteSchema.js index bcb3f417..395d5d76 100644 --- a/src/src/model/RouteSchema.js +++ b/src/src/model/RouteSchema.js @@ -20,6 +20,7 @@ import HttpFilter from "./HttpFilter"; import Mqtt from "./Mqtt"; import Proxy from "./Proxy"; import Radresponder from "./Radresponder"; +import Slack from "./Slack"; import Snowflake from "./Snowflake"; import SnowflakeTransform from "./SnowflakeTransform"; import Thingworx from "./Thingworx"; @@ -33,7 +34,7 @@ class RouteSchema { /** * Constructs a new RouteSchema. * @alias module:model/RouteSchema - * @param {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Snowflake|module:model/Thingworx)} instance The actual instance to initialize RouteSchema. + * @param {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Slack|module:model/Snowflake|module:model/Thingworx)} instance The actual instance to initialize RouteSchema. */ constructor(instance = null) { if (instance === null) { @@ -186,15 +187,31 @@ class RouteSchema { errorMessages.push("Failed to construct Snowflake: " + err); } + try { + if (typeof instance === "Slack") { + this.actualInstance = instance; + } else { + // plain JS object + // validate the object + Slack.validateJSON(instance); // throw an exception if no match + // create Slack from JS object + this.actualInstance = Slack.constructFromObject(instance); + } + match++; + } catch (err) { + // json data failed to deserialize into Slack + errorMessages.push("Failed to construct Slack: " + err); + } + if (match > 1) { throw new Error( - "Multiple matches found constructing `RouteSchema` with oneOf schemas Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Snowflake, Thingworx. Input: " + + "Multiple matches found constructing `RouteSchema` with oneOf schemas Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Slack, Snowflake, Thingworx. Input: " + JSON.stringify(instance) ); } else if (match === 0) { this.actualInstance = null; // clear the actual instance in case there are multiple matches throw new Error( - "No match found constructing `RouteSchema` with oneOf schemas Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Snowflake, Thingworx. Details: " + + "No match found constructing `RouteSchema` with oneOf schemas Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Slack, Snowflake, Thingworx. Details: " + errorMessages.join(", ") ); } else { @@ -215,16 +232,16 @@ class RouteSchema { } /** - * Gets the actaul instance, which can be Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Snowflake, Thingworx. - * @return {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Snowflake|module:model/Thingworx)} The actual instance. + * Gets the actaul instance, which can be Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Slack, Snowflake, Thingworx. + * @return {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Slack|module:model/Snowflake|module:model/Thingworx)} The actual instance. */ getActualInstance() { return this.actualInstance; } /** - * Sets the actaul instance, which can be Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Snowflake, Thingworx. - * @param {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Snowflake|module:model/Thingworx)} obj The actual instance. + * Sets the actaul instance, which can be Aws, Azure, Google, Http, Mqtt, Proxy, Radresponder, Slack, Snowflake, Thingworx. + * @param {(module:model/Aws|module:model/Azure|module:model/Google|module:model/Http|module:model/Mqtt|module:model/Proxy|module:model/Radresponder|module:model/Slack|module:model/Snowflake|module:model/Thingworx)} obj The actual instance. */ setActualInstance(obj) { this.actualInstance = @@ -266,6 +283,7 @@ RouteSchema.prototype["filter"] = undefined; RouteSchema.prototype["transform"] = undefined; /** + * Minimum time between requests in Miliseconds * @member {Number} throttle_ms */ RouteSchema.prototype["throttle_ms"] = undefined; @@ -382,6 +400,7 @@ RouteSchema.prototype["message_group_id"] = undefined; RouteSchema.prototype["message_deduplication_id"] = undefined; /** + * The Channel ID for Bearer Token method, if the \"slack-bearer\" type is selected * @member {String} channel */ RouteSchema.prototype["channel"] = undefined; @@ -452,6 +471,36 @@ RouteSchema.prototype["user_name"] = undefined; */ RouteSchema.prototype["pem"] = undefined; +/** + * The type of Slack message. Must be one of \"slack-bearer\" for Bearer Token or \"slack-webhook\" for Webhook messages + * @member {String} slack_type + */ +RouteSchema.prototype["slack_type"] = undefined; + +/** + * The Bearer Token for Slack messaging, if the \"slack-bearer\" type is selected + * @member {String} bearer + */ +RouteSchema.prototype["bearer"] = undefined; + +/** + * The Webhook URL for Slack Messaging if the \"slack-webhook\" type is selected + * @member {String} webhook_url + */ +RouteSchema.prototype["webhook_url"] = undefined; + +/** + * The simple text message to be sent, if the blocks message field is not in use. Placeholders are available for this field. + * @member {String} text + */ +RouteSchema.prototype["text"] = undefined; + +/** + * The Blocks message to be sent. If populated, this field overrides the text field within the Slack Messaging API. Placeholders are available for this field. + * @member {String} blocks + */ +RouteSchema.prototype["blocks"] = undefined; + RouteSchema.OneOf = [ "Aws", "Azure", @@ -460,6 +509,7 @@ RouteSchema.OneOf = [ "Mqtt", "Proxy", "Radresponder", + "Slack", "Snowflake", "Thingworx", ]; diff --git a/src/src/model/Slack.js b/src/src/model/Slack.js new file mode 100644 index 00000000..4280b1b4 --- /dev/null +++ b/src/src/model/Slack.js @@ -0,0 +1,262 @@ +/** + * Notehub API + * The OpenAPI definition for the Notehub.io API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: engineering@blues.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +import ApiClient from "../ApiClient"; +import HttpFilter from "./HttpFilter"; +import SnowflakeTransform from "./SnowflakeTransform"; + +/** + * The Slack model module. + * @module model/Slack + * @version 1.0.16 + */ +class Slack { + /** + * Constructs a new Slack. + * Route settings specific to Slack routes. Only used for Slack route types + * @alias module:model/Slack + */ + constructor() { + Slack.initialize(this); + } + + /** + * Initializes the fields of this object. + * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). + * Only for internal use. + */ + static initialize(obj) {} + + /** + * Constructs a Slack from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Slack} obj Optional instance to populate. + * @return {module:model/Slack} The populated Slack instance. + */ + static constructFromObject(data, obj) { + if (data) { + obj = obj || new Slack(); + + if (data.hasOwnProperty("fleets")) { + obj["fleets"] = ApiClient.convertToType(data["fleets"], ["String"]); + } + if (data.hasOwnProperty("filter")) { + obj["filter"] = HttpFilter.constructFromObject(data["filter"]); + } + if (data.hasOwnProperty("transform")) { + obj["transform"] = SnowflakeTransform.constructFromObject( + data["transform"] + ); + } + if (data.hasOwnProperty("throttle_ms")) { + obj["throttle_ms"] = ApiClient.convertToType( + data["throttle_ms"], + "Number" + ); + } + if (data.hasOwnProperty("timeout")) { + obj["timeout"] = ApiClient.convertToType(data["timeout"], "Number"); + } + if (data.hasOwnProperty("slack_type")) { + obj["slack_type"] = ApiClient.convertToType( + data["slack_type"], + "String" + ); + } + if (data.hasOwnProperty("bearer")) { + obj["bearer"] = ApiClient.convertToType(data["bearer"], "String"); + } + if (data.hasOwnProperty("channel")) { + obj["channel"] = ApiClient.convertToType(data["channel"], "String"); + } + if (data.hasOwnProperty("webhook_url")) { + obj["webhook_url"] = ApiClient.convertToType( + data["webhook_url"], + "String" + ); + } + if (data.hasOwnProperty("text")) { + obj["text"] = ApiClient.convertToType(data["text"], "String"); + } + if (data.hasOwnProperty("blocks")) { + obj["blocks"] = ApiClient.convertToType(data["blocks"], "String"); + } + } else if (data === null) { + return null; + } + return obj; + } + + /** + * Validates the JSON data with respect to Slack. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @return {boolean} to indicate whether the JSON data is valid with respect to Slack. + */ + static validateJSON(data) { + // ensure the json data is an array + if (!Array.isArray(data["fleets"])) { + throw new Error( + "Expected the field `fleets` to be an array in the JSON data but got " + + data["fleets"] + ); + } + // validate the optional field `filter` + if (data["filter"]) { + // data not null + HttpFilter.validateJSON(data["filter"]); + } + // validate the optional field `transform` + if (data["transform"]) { + // data not null + SnowflakeTransform.validateJSON(data["transform"]); + } + // ensure the json data is a string + if ( + data["slack_type"] && + !( + typeof data["slack_type"] === "string" || + data["slack_type"] instanceof String + ) + ) { + throw new Error( + "Expected the field `slack_type` to be a primitive type in the JSON string but got " + + data["slack_type"] + ); + } + // ensure the json data is a string + if ( + data["bearer"] && + !(typeof data["bearer"] === "string" || data["bearer"] instanceof String) + ) { + throw new Error( + "Expected the field `bearer` to be a primitive type in the JSON string but got " + + data["bearer"] + ); + } + // ensure the json data is a string + if ( + data["channel"] && + !( + typeof data["channel"] === "string" || data["channel"] instanceof String + ) + ) { + throw new Error( + "Expected the field `channel` to be a primitive type in the JSON string but got " + + data["channel"] + ); + } + // ensure the json data is a string + if ( + data["webhook_url"] && + !( + typeof data["webhook_url"] === "string" || + data["webhook_url"] instanceof String + ) + ) { + throw new Error( + "Expected the field `webhook_url` to be a primitive type in the JSON string but got " + + data["webhook_url"] + ); + } + // ensure the json data is a string + if ( + data["text"] && + !(typeof data["text"] === "string" || data["text"] instanceof String) + ) { + throw new Error( + "Expected the field `text` to be a primitive type in the JSON string but got " + + data["text"] + ); + } + // ensure the json data is a string + if ( + data["blocks"] && + !(typeof data["blocks"] === "string" || data["blocks"] instanceof String) + ) { + throw new Error( + "Expected the field `blocks` to be a primitive type in the JSON string but got " + + data["blocks"] + ); + } + + return true; + } +} + +/** + * list of Fleet UIDs to apply route to, if any. If empty, applies to all Fleets + * @member {Array.} fleets + */ +Slack.prototype["fleets"] = undefined; + +/** + * @member {module:model/HttpFilter} filter + */ +Slack.prototype["filter"] = undefined; + +/** + * @member {module:model/SnowflakeTransform} transform + */ +Slack.prototype["transform"] = undefined; + +/** + * Minimum time between requests in Miliseconds + * @member {Number} throttle_ms + */ +Slack.prototype["throttle_ms"] = undefined; + +/** + * Timeout in seconds for each request + * @member {Number} timeout + * @default 15 + */ +Slack.prototype["timeout"] = 15; + +/** + * The type of Slack message. Must be one of \"slack-bearer\" for Bearer Token or \"slack-webhook\" for Webhook messages + * @member {String} slack_type + */ +Slack.prototype["slack_type"] = undefined; + +/** + * The Bearer Token for Slack messaging, if the \"slack-bearer\" type is selected + * @member {String} bearer + */ +Slack.prototype["bearer"] = undefined; + +/** + * The Channel ID for Bearer Token method, if the \"slack-bearer\" type is selected + * @member {String} channel + */ +Slack.prototype["channel"] = undefined; + +/** + * The Webhook URL for Slack Messaging if the \"slack-webhook\" type is selected + * @member {String} webhook_url + */ +Slack.prototype["webhook_url"] = undefined; + +/** + * The simple text message to be sent, if the blocks message field is not in use. Placeholders are available for this field. + * @member {String} text + */ +Slack.prototype["text"] = undefined; + +/** + * The Blocks message to be sent. If populated, this field overrides the text field within the Slack Messaging API. Placeholders are available for this field. + * @member {String} blocks + */ +Slack.prototype["blocks"] = undefined; + +export default Slack; diff --git a/src/test/model/Slack.spec.js b/src/test/model/Slack.spec.js new file mode 100644 index 00000000..0f4f0e65 --- /dev/null +++ b/src/test/model/Slack.spec.js @@ -0,0 +1,119 @@ +/** + * Notehub API + * The OpenAPI definition for the Notehub.io API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: engineering@blues.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +(function (root, factory) { + if (typeof define === "function" && define.amd) { + // AMD. + define(["expect.js", process.cwd() + "/src/index"], factory); + } else if (typeof module === "object" && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require("expect.js"), require(process.cwd() + "/src/index")); + } else { + // Browser globals (root is window) + factory(root.expect, root.NotehubJs); + } +})(this, function (expect, NotehubJs) { + "use strict"; + + var instance; + + beforeEach(function () { + instance = new NotehubJs.Slack(); + }); + + var getProperty = function (object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === "function") return object[getter](); + else return object[property]; + }; + + var setProperty = function (object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === "function") object[setter](value); + else object[property] = value; + }; + + describe("Slack", function () { + it("should create an instance of Slack", function () { + // uncomment below and update the code to test Slack + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be.a(NotehubJs.Slack); + }); + + it('should have the property fleets (base name: "fleets")', function () { + // uncomment below and update the code to test the property fleets + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property filter (base name: "filter")', function () { + // uncomment below and update the code to test the property filter + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property transform (base name: "transform")', function () { + // uncomment below and update the code to test the property transform + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property throttleMs (base name: "throttle_ms")', function () { + // uncomment below and update the code to test the property throttleMs + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property timeout (base name: "timeout")', function () { + // uncomment below and update the code to test the property timeout + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property slackType (base name: "slack_type")', function () { + // uncomment below and update the code to test the property slackType + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property bearer (base name: "bearer")', function () { + // uncomment below and update the code to test the property bearer + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property channel (base name: "channel")', function () { + // uncomment below and update the code to test the property channel + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property webhookUrl (base name: "webhook_url")', function () { + // uncomment below and update the code to test the property webhookUrl + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property text (base name: "text")', function () { + // uncomment below and update the code to test the property text + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + + it('should have the property blocks (base name: "blocks")', function () { + // uncomment below and update the code to test the property blocks + //var instance = new NotehubJs.Slack(); + //expect(instance).to.be(); + }); + }); +});