Commit Graph

47 Commits

Author SHA1 Message Date
Paul Tyng
49ed8b85a7 fix compile error 2022-10-31 15:53:30 -04:00
Paul Tyng
6de33139b5 change stp_priority to numberOrString 2022-10-31 15:48:42 -04:00
Paul Tyng
e7f16ff6c4 lint issues 2022-10-22 21:02:27 -04:00
Paul Tyng
0552712b3b Always send schedule 2022-10-22 21:00:33 -04:00
Paul Tyng
887fae8168 handle omitted is true bools 2022-10-19 20:35:58 -04:00
jeanluc
1ac863de1f Fix type of lte_ext_ant/lte_poe fields (#89) 2022-08-10 11:34:05 +10:00
Joshua Spence
621d0e78f7 Don't set omitempty on mdns_enabled (#74) 2022-05-16 14:43:17 +10:00
Joshua Spence
09e0556344 Add back mdns_enabled (#73) 2022-05-16 13:56:45 +10:00
Joshua Spence
d2a3d064ac Fix SettingGlobalAp (#71)
Variable names (or struct fields) cannot start with a number.
2022-05-12 13:48:20 +10:00
Oskar
3e7bd072ea Omit empty NetworkID in account resource (#59)
* Omit empty NetworkID in account

* Run `go generate`

* Fix tests

Co-authored-by: Joshua Spence <josh@joshuaspence.com>
2022-01-31 15:58:42 +11:00
Joshua Spence
124f349da4 Format generated golang with go/format (#48) 2021-09-24 13:17:25 +10:00
Joshua Spence
8d4ca5f389 Revert "Add controller version to generated files" (#47)
This reverts commit 13d5677bf3.
2021-09-24 07:21:34 +10:00
Joshua Spence
0cb7d3e514 Add AdoptDevice and ForgetDevice methods (#45)
* Add `AdoptDevice` and `ForgetDevice` methods

* Address comments
2021-09-17 11:16:56 +10:00
Paul Tyng
13d5677bf3 Add controller version to generated files 2021-08-31 09:02:23 -04:00
Johannes Heck
4e9d935af2 fix Ht fieldType for device import 2021-08-18 16:10:47 -04:00
Joshua Spence
e27afc6e32 Add --latest flag
Allow using the latest version of the Unifi controller with `--latest`.
2021-08-11 11:40:15 +10:00
Joshua Spence
8f8e19eb2a Don't commit intermediate files
Don't commit the extracted JSON files as well only need the generated `*.generated.go` files.
2021-08-11 11:40:15 +10:00
Kurt McAlpine
7081791f4f Export fields on SettingMgmtXSshKeys (#41) 2021-07-05 14:51:44 +10:00
Joshua Spence
693795b5f0 Fix failing test 2021-06-29 17:43:00 -04:00
Joshua Spence
64a73cdd4b Fix linter issues 2021-06-29 17:43:00 -04:00
Joshua Spence
2f7eee3a6a Add dev_id_override to user 2021-06-18 15:39:41 -04:00
Joshua Spence
dd685c0447 Fix type of x_ssh_keys
The `unifi_settings_mgmt` resource fails for me with the following error:

```
Error: unable to decode body: GET s/default/get/setting/mgmt unable to unmarshal alias: json: cannot unmarshal object into Go struct field .x_ssh_keys of type string
```

My `x_ssh_keys` looks like this:

```
[
  {
    "name": "Laptop",
    "type": "ssh-rsa",
    "key": "REDACTED",
    "comment": "REDACTED",
    "date": "2021-02-25T08:26:04Z",
    "fingerprint": "REDACTED"
  }
]
```
2021-06-16 09:28:49 -04:00
James Stephenson
fbed685c37 Fixing unmarshalling of numberOrString
New unmarshalling rules for fields which could be numeric or string
values were not properly typecasted upon being deserialized.

Cleaned up the api template file and moved custom unmarshalling type
logic into go code out of the template.
2021-04-16 13:41:01 -04:00
Paul Tyng
4ab4036985 Bump to 6.0.43, use go generate
Also moved fetching of JSON information to Go for cross-OS usage.
2021-04-09 09:51:50 -04:00
Paul Tyng
5219e06753 Remove old field JSON 2021-04-09 09:51:50 -04:00
Kurt McAlpine
bd8898db77 Set d.Key for all settings updates 2021-04-09 09:51:50 -04:00
Paul Tyng
4702e34c81 Fix unmarshalling of tx_power 2021-03-21 21:34:29 -04:00
Paul Tyng
82a3baaf00 Handle marshaling of numbers and strings for channels 2021-03-21 21:13:58 -04:00
Paul Tyng
9c60a9de6f Change to string for auto support 2021-03-20 11:30:10 -04:00
Hendrik "T4cC0re" Meyer
4aed7d703d Generate UnmarshalJSON to handle emptyStringInt types
This commit changes the code generator to generate a `UnmarshalJSON` for each
struct, so that if unmarshalled it properly handles UniFis varying integer values
via the `emptyStringInt` type.

Structs not including a field of `int` type will still have the function generated,
but it will effectively do nothing.

Fixes #18
2021-01-03 13:21:53 -05:00
Paul Tyng
abc676f62b Add support for 6.0.23 2020-10-20 10:10:32 -04:00
Ben Davies
df937016b0 Moved handling of string response to int using the existing emptyStringInt method as part of UnmarshalJSON as per Pauls suggestion 2020-10-09 13:42:28 -04:00
Ben Davies
e7f9c5eb97 Added WAN egress qos fix 2020-10-09 13:42:28 -04:00
James Stephenson
6203ee9620 Renaming PortConf to PortProfile; cleanup Device API func names 2020-10-09 08:56:24 -04:00
James Stephenson
e93f92a066 Expose Device API 2020-10-09 08:56:24 -04:00
Paul Tyng
8f15aa6dff gofmt -s 2020-09-24 16:57:25 -04:00
James Stephenson
16c246525b Refactored field processing in generator.
* Allows for specifying more customizations per field in each type.
  Previously, the switch clause didn't allow sub-types to be modified, but
  that became a problem with some of the more complex types.

* Fixed several problematic fields in the Device resource

* Removed the underscore separator from generated type names
2020-09-10 08:50:21 -04:00
James Stephenson
35eda4f67b Refactor type generator
* Allows for generating top-level types for any embedded struct so
  that sub-types can be properly instantiated from calling code
  * Specifying `-no-embedded-types` will generate top-level types
    rather than embedding the struct

* Refactored "Device" API
  * All fields set to `omitempty` because it describes all possible
    device types, so effectively any field could be omitted any time
  * Fixed `get` call for "Device" API; replacing `rest` with `stat`

* Generated `get` and `update` calls for `Setting*` APIs

* Added `5.14.23` JSON files
2020-09-10 08:50:21 -04:00
Paul Tyng
5726e0ab76 sort ascending 2020-08-27 21:52:32 -04:00
James Stephenson
47fa522aba Expose the Account API (RADIUS users)
* Adds Account CRUD API
* Enahnces `emptyStringInt` with a predicate for dynamically setting
  which value should be interpreted as a blank JSON payload
2020-08-27 21:48:13 -04:00
Paul Tyng
8e63bffebb Generate from 5.12.72 fields 2020-05-20 22:01:47 -04:00
Paul Tyng
3d21ebbab0 Add 5.12.72 fields JSON 2020-05-20 22:01:47 -04:00
Paul Tyng
f0da875a46 Improve fields fetching 2020-05-20 22:01:47 -04:00
Paul Tyng
d076e78005 Add context support 2020-03-26 16:12:52 -04:00
Paul Tyng
19709dff50 Add support for IP on User 2020-02-19 10:32:44 -05:00
Paul Tyng
1f8ef07e63 Cleanup firewall rule names 2020-01-12 10:30:42 -05:00
Paul Tyng
435ecf9d6f Initial version
Extracted from paultyng/terraform-provider-unifi@ef25893f14
2020-01-10 14:31:12 -05:00