Skip to content

Commit

Permalink
Adds HTTP integration schema
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Jul 13, 2020
1 parent 932d26a commit 0cacd57
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/language-service/src/schemas/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export interface InternalIntegrations {
*/
group?: integrations.Group.Schema | IncludeNamed;

/**
* The http integration serves all files and data required for the Home Assistant frontend. You only need to add this to your configuration file if you want to change any of the default settings.
* https://www.home-assistant.io/integrations/http
*/
http?: integrations.HTTP.Schema | IncludeNamed | null;

/**
* The input_boolean integration allows the user to define boolean values that can be controlled via the frontend and can be used within conditions of automation. This can for example be used to disable or enable certain automations.
* https://www.home-assistant.io/integrations/input_boolean
Expand Down
95 changes: 95 additions & 0 deletions src/language-service/src/schemas/integrations/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* HTTP ntegration
* Source: https://github.com/home-assistant/core/blob/dev/homeassistant/components/http/__init__.py
*/
import {
Deprecated,
IncludeList,
Port,
PositiveInteger,
Secret,
} from "../types";

export type Domain = "http";
export interface Schema {
/**
* DEPRECATED.
* The base URL has been deprecated, please use internal_url and external_url instead.
*/
base_url?: Deprecated;

/**
* A list of origin domain names to allow CORS requests from. Enabling this will set the Access-Control-Allow-Origin header to the Origin header if it is found in the list, and the Access-Control-Allow-Headers header to Origin, Accept, X-Requested-With, Content-type, Authorization.
* https://www.home-assistant.io/integrations/http#cors_allowed_origins
*/
cors_allowed_origins?: string | string[] | Secret | Secret[] | IncludeList;

/**
* Flag indicating whether additional IP filtering is enabled.
* https://www.home-assistant.io/integrations/http#ip_ban_enabled
*/
ip_ban_enabled?: boolean;

/**
* Number of failed login attempt from single IP after which it will be automatically banned if ip_ban_enabled is true.
* https://www.home-assistant.io/integrations/http#login_attempts_threshold
*/
login_attempts_threshold?: PositiveInteger;

/**
* Only listen to incoming requests on specific IP/host. By default it will accept all IPv4 connections. Use server_host: ::0 if you want to listen to (and only) IPv6.
* Warning! Only use this option when you run Home Assistant Core directly in Python!
* https://www.home-assistant.io/integrations/http#server_host
*/
server_host?: string | Secret;

/**
* Let you set a port for Home Assistant to run on.
* https://www.home-assistant.io/integrations/http#server_port
*/
server_port?: Port;

/**
* Path to your TLS/SSL certificate to serve Home Assistant over a secure connection.
* https://www.home-assistant.io/integrations/http#ssl_certificate
*/
ssl_certificate?: string | Secret;

/**
* Path to your TLS/SSL key to serve Home Assistant over a secure connection.
* https://www.home-assistant.io/integrations/http#ssl_key
*/
ssl_key?: string | Secret;

/**
* Path to the client/peer TLS/SSL certificate to accept secure connections from.
* https://www.home-assistant.io/integrations/http#ssl_peer_certificate
*/
ssl_peer_certificate?: string | Secret;

/**
* The Mozilla SSL profile to use. Only lower if you are experiencing integrations causing SSL handshake errors.
* Can be either "modern" or "intermediate". Modern is the default.
* https://www.home-assistant.io/integrations/http#ssl_profile
*/
ssl_profile?: "modern" | "intermediate";

/**
* DEPRECATED.
* This option has no effect. Please remove this from your configuration.
*/
trusted_networks?: Deprecated;

/**
* List of trusted proxies, consisting of IP addresses or networks, that are allowed to set the X-Forwarded-For header. This is required when using use_x_forwarded_for because all requests to Home Assistant, regardless of source, will arrive from the reverse proxy IP address.
* This option should be handled and set with extreme care!
* https://www.home-assistant.io/integrations/http#trusted_proxies
*/
trusted_proxies?: string | string[] | Secret | Secret[] | IncludeList;

/**
* Enable parsing of the X-Forwarded-For header, passing on the client’s correct IP address in proxied setups. You must also whitelist trusted proxies using the trusted_proxies setting for this to work. Non-whitelisted requests with this header will be considered IP spoofing attacks, and the header will, therefore, be ignored.
* https://www.home-assistant.io/integrations/http#use_x_forwarded_for
*/
use_x_forwarded_for?: boolean;
}
1 change: 1 addition & 0 deletions src/language-service/src/schemas/integrations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * as Automation from "./automation";
export * as Group from "./group";
export * as HACS from "./hacs";
export * as HTTP from "./http";
export * as Hue from "./hue";
export * as InputBoolean from "./input_boolean";
export * as PanelIframe from "./panel_iframe";
Expand Down
7 changes: 7 additions & 0 deletions src/language-service/src/schemas/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
"tsFile": "integrations/scene.ts",
"fromType": "Schema"
},
{
"key": "homeassistant-http",
"path": "configuration.yaml/http",
"file": "homeassistant-http.json",
"tsFile": "integrations/http.ts",
"fromType": "Schema"
},
{
"key": "homeassistant-input-boolean",
"path": "configuration.yaml/input_boolean",
Expand Down
13 changes: 13 additions & 0 deletions src/language-service/src/schemas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ export type IncludeNamed = string;
*/
export type Integer = number;

/**
* @JTS-type integer
* @minimum 0
*/
export type PositiveInteger = number;

/**
* @JTS-type integer
* @minimum 1
* @maximum 65535
*/
export type Port = number;

/**
* @TJS-pattern ^!secret\s([a-zA-Z0-9_-]+)$
*/
Expand Down

0 comments on commit 0cacd57

Please sign in to comment.