From f2aeccd1174e40ff6454fdb2d144150cef2495f9 Mon Sep 17 00:00:00 2001 From: Thomas Munzer Date: Mon, 9 Sep 2024 14:25:51 +0200 Subject: [PATCH] v0.3.9 --- README.md | 12 +- doc/controllers/admins.md | 2 +- doc/controllers/constants-definitions.md | 2 +- doc/controllers/installer.md | 25 +- doc/controllers/ms-ps-inventory.md | 2 +- doc/controllers/ms-ps-logs.md | 8 +- doc/controllers/ms-ps-marvis.md | 6 +- doc/controllers/ms-ps-orgs.md | 8 +- doc/controllers/ms-ps-sl-es.md | 2 +- doc/controllers/ms-ps-tickets.md | 4 +- doc/controllers/ms-ps.md | 4 +- doc/controllers/orgs-alarm-templates.md | 6 +- doc/controllers/orgs-alarms.md | 10 +- doc/controllers/orgs-antivirus-profiles.md | 4 +- doc/controllers/orgs-ap-templates.md | 4 +- doc/controllers/orgs-asset-filters.md | 4 +- doc/controllers/orgs-assets.md | 4 +- doc/controllers/orgs-clients-nac.md | 24 +- doc/controllers/orgs-clients-wan.md | 24 +- doc/controllers/orgs-clients-wired.md | 12 +- doc/controllers/orgs-clients-wireless.md | 28 +- doc/controllers/orgs-device-profiles.md | 6 +- doc/controllers/orgs-devices-others.md | 22 +- doc/controllers/orgs-devices.md | 38 +- doc/controllers/orgs-evpn-topologies.md | 4 +- doc/controllers/orgs-gateway-templates.md | 4 +- doc/controllers/orgs-guests.md | 18 +- doc/controllers/orgs-idp-profiles.md | 4 +- doc/controllers/orgs-inventory.md | 17 +- doc/controllers/orgs-jsi.md | 10 +- doc/controllers/orgs-logs.md | 14 +- doc/controllers/orgs-mx-clusters.md | 4 +- doc/controllers/orgs-mx-edges.md | 36 +- doc/controllers/orgs-mx-tunnels.md | 4 +- doc/controllers/orgs-nac-portals.md | 10 +- doc/controllers/orgs-nac-rules.md | 4 +- doc/controllers/orgs-nac-tags.md | 4 +- doc/controllers/orgs-network-templates.md | 4 +- doc/controllers/orgs-networks.md | 4 +- doc/controllers/orgs-premium-analytics.md | 4 +- doc/controllers/orgs-psk-portals.md | 24 +- doc/controllers/orgs-psks.md | 6 +- doc/controllers/orgs-rf-templates.md | 4 +- doc/controllers/orgs-sec-policies.md | 4 +- doc/controllers/orgs-service-policies.md | 4 +- doc/controllers/orgs-services.md | 4 +- doc/controllers/orgs-site-templates.md | 4 +- doc/controllers/orgs-sitegroups.md | 4 +- doc/controllers/orgs-sites.md | 16 +- doc/controllers/orgs-sl-es.md | 8 +- doc/controllers/orgs-sso-roles.md | 4 +- doc/controllers/orgs-sso.md | 10 +- doc/controllers/orgs-stats-assets.md | 10 +- doc/controllers/orgs-stats-devices.md | 10 +- doc/controllers/orgs-stats-mx-edges.md | 8 +- doc/controllers/orgs-stats-other-devices.md | 2 +- doc/controllers/orgs-stats-ports.md | 12 +- doc/controllers/orgs-stats-tunnels.md | 10 +- doc/controllers/orgs-stats-vpn-peers.md | 10 +- doc/controllers/orgs-stats.md | 6 +- doc/controllers/orgs-tickets.md | 8 +- doc/controllers/orgs-user-ma-cs.md | 4 +- doc/controllers/orgs-vars.md | 4 +- doc/controllers/orgs-vp-ns.md | 4 +- doc/controllers/orgs-webhooks.md | 12 +- doc/controllers/orgs-wlan-templates.md | 4 +- doc/controllers/orgs-wlans.md | 59 +- doc/controllers/orgs-wx-rules.md | 4 +- doc/controllers/orgs-wx-tags.md | 4 +- doc/controllers/orgs-wx-tunnels.md | 4 +- doc/controllers/orgs.md | 4 +- doc/controllers/self-audit-logs.md | 6 +- doc/controllers/self-mfa.md | 2 +- doc/controllers/sites-alarms.md | 12 +- doc/controllers/sites-anomaly.md | 4 +- doc/controllers/sites-asset-filters.md | 4 +- doc/controllers/sites-assets.md | 6 +- doc/controllers/sites-beacons.md | 4 +- doc/controllers/sites-clients-nac.md | 26 +- doc/controllers/sites-clients-wan.md | 24 +- doc/controllers/sites-clients-wired.md | 12 +- doc/controllers/sites-clients-wireless.md | 40 +- doc/controllers/sites-device-profiles.md | 2 +- doc/controllers/sites-devices-others.md | 14 +- doc/controllers/sites-devices.md | 62 +- doc/controllers/sites-events.md | 14 +- doc/controllers/sites-guests.md | 20 +- doc/controllers/sites-insights.md | 22 +- doc/controllers/sites-location.md | 4 +- doc/controllers/sites-maps.md | 6 +- doc/controllers/sites-mx-edges.md | 14 +- doc/controllers/sites-networks.md | 2 +- doc/controllers/sites-psks.md | 6 +- doc/controllers/sites-rfdiags.md | 6 +- doc/controllers/sites-rogues.md | 20 +- doc/controllers/sites-rrm.md | 10 +- doc/controllers/sites-rssi-zones.md | 4 +- doc/controllers/sites-service-policies.md | 2 +- doc/controllers/sites-services.md | 12 +- doc/controllers/sites-skyatp.md | 10 +- doc/controllers/sites-sl-es.md | 24 +- doc/controllers/sites-stats-assets.md | 26 +- doc/controllers/sites-stats-beacons.md | 6 +- doc/controllers/sites-stats-calls.md | 22 +- .../sites-stats-clients-wireless.md | 16 +- doc/controllers/sites-stats-devices.md | 8 +- .../sites-stats-discovered-switches.md | 18 +- doc/controllers/sites-stats-mx-edges.md | 8 +- doc/controllers/sites-stats-ports.md | 24 +- doc/controllers/sites-vp-ns.md | 2 +- doc/controllers/sites-wan-usages.md | 14 +- doc/controllers/sites-webhooks.md | 12 +- doc/controllers/sites-wlans.md | 8 +- doc/controllers/sites-wx-rules.md | 4 +- doc/controllers/sites-wx-tags.md | 4 +- doc/controllers/sites-wx-tunnels.md | 4 +- doc/controllers/sites-zones.md | 22 +- doc/controllers/sitesv-beacons.md | 4 +- doc/controllers/utilities-common.md | 2 +- doc/controllers/utilities-lan.md | 4 +- doc/controllers/utilities-pca-ps.md | 12 +- doc/controllers/utilities-upgrade.md | 4 +- doc/controllers/utilities-wi-fi.md | 10 +- doc/models/const-nac-event.md | 2 +- doc/models/event-nac-client.md | 2 +- doc/models/fwupdate-stat.md | 2 +- doc/models/image-import.md | 2 +- doc/models/installer-device.md | 2 +- .../response-inventory-error-exception.md | 76 +++ doc/models/response-inventory.md | 1 + doc/models/response-stats-assets.md | 4 +- doc/models/response-zone-search.md | 4 +- doc/models/service-path-event.md | 2 +- doc/models/stats-asset.md | 4 +- doc/models/webhook-delivery.md | 2 +- doc/models/webhook-nac-events-event.md | 2 +- doc/models/wlan-portal-template-setting.md | 4 +- mistapi/admins_login_test.go | 46 ++ mistapi/admins_logout_test.go | 23 + mistapi/admins_lookup_test.go | 30 + mistapi/admins_recover_password_test.go | 24 + mistapi/admins_test.go | 41 ++ mistapi/constants_definitions_test.go | 184 ++++++ mistapi/constants_events_test.go | 119 ++++ mistapi/constants_models_test.go | 39 ++ mistapi/errors/errors.go | 24 + mistapi/installer.go | 2 +- mistapi/installer_test.go | 222 +++++++ mistapi/models/image_import.go | 1 - mistapi/models/response_inventory.go | 8 +- mistapi/ms_ps_admins_test.go | 173 ++++++ mistapi/ms_ps_inventory_test.go | 29 + mistapi/ms_ps_licenses_test.go | 94 +++ mistapi/ms_ps_logo_test.go | 37 ++ mistapi/ms_ps_logs_test.go | 59 ++ mistapi/ms_ps_marvis_test.go | 32 + mistapi/ms_ps_org_groups_test.go | 122 ++++ mistapi/ms_ps_orgs_test.go | 187 ++++++ mistapi/ms_ps_sso_roles_test.go | 90 +++ mistapi/ms_ps_sso_test.go | 192 ++++++ mistapi/ms_ps_test.go | 116 ++++ mistapi/ms_ps_tickets_test.go | 53 ++ mistapi/orgs_admins_test.go | 137 +++++ mistapi/orgs_alarm_templates_test.go | 170 ++++++ mistapi/orgs_alarms_test.go | 159 +++++ mistapi/orgs_antivirus_profiles_test.go | 128 ++++ mistapi/orgs_ap_templates_test.go | 57 ++ mistapi/orgs_api_tokens_test.go | 122 ++++ mistapi/orgs_asset_filters_test.go | 126 ++++ mistapi/orgs_assets_test.go | 149 +++++ mistapi/orgs_cert_test.go | 83 +++ mistapi/orgs_clients_marvis_test.go | 126 ++++ mistapi/orgs_clients_nac_test.go | 161 +++++ mistapi/orgs_clients_sdk_test.go | 33 ++ mistapi/orgs_clients_wan_test.go | 122 ++++ mistapi/orgs_clients_wired_test.go | 68 +++ mistapi/orgs_clients_wireless_test.go | 182 ++++++ mistapi/orgs_cradlepoint_test.go | 72 +++ mistapi/orgs_crl_test.go | 26 + mistapi/orgs_device_profiles_test.go | 187 ++++++ mistapi/orgs_devices_others_test.go | 183 ++++++ mistapi/orgs_devices_ssr_test.go | 28 + mistapi/orgs_devices_test.go | 227 +++++++ mistapi/orgs_evpn_topologies_test.go | 128 ++++ mistapi/orgs_gateway_templates_test.go | 120 ++++ mistapi/orgs_guests_test.go | 145 +++++ mistapi/orgs_idp_profiles_test.go | 128 ++++ mistapi/orgs_inventory.go | 2 +- mistapi/orgs_inventory_test.go | 159 +++++ mistapi/orgs_jse_test.go | 85 +++ mistapi/orgs_jsi_test.go | 96 +++ mistapi/orgs_licenses_test.go | 94 +++ mistapi/orgs_linked_applications_test.go | 50 ++ mistapi/orgs_logs_test.go | 68 +++ mistapi/orgs_maps_test.go | 32 + mistapi/orgs_marvis_test.go | 33 ++ mistapi/orgs_mx_clusters_test.go | 128 ++++ mistapi/orgs_mx_edges_test.go | 426 +++++++++++++ mistapi/orgs_mx_tunnels_test.go | 124 ++++ mistapi/orgs_nac_portals_test.go | 250 ++++++++ mistapi/orgs_nac_rules_test.go | 118 ++++ mistapi/orgs_nac_tags_test.go | 119 ++++ mistapi/orgs_naccrl_test.go | 46 ++ mistapi/orgs_nacidp_test.go | 33 ++ mistapi/orgs_network_templates_test.go | 126 ++++ mistapi/orgs_networks_test.go | 128 ++++ mistapi/orgs_premium_analytics_test.go | 30 + mistapi/orgs_psk_portals_test.go | 260 ++++++++ mistapi/orgs_psks_test.go | 201 +++++++ mistapi/orgs_rf_templates_test.go | 118 ++++ mistapi/orgs_scep_test.go | 117 ++++ mistapi/orgs_sdk_invites_test.go | 190 ++++++ mistapi/orgs_sdk_templates_test.go | 116 ++++ mistapi/orgs_sec_policies_test.go | 124 ++++ mistapi/orgs_service_policies_test.go | 122 ++++ mistapi/orgs_services_test.go | 128 ++++ mistapi/orgs_setting_test.go | 134 +++++ mistapi/orgs_setting_zscaler_test.go | 63 ++ mistapi/orgs_site_templates_test.go | 118 ++++ mistapi/orgs_sitegroups_test.go | 128 ++++ mistapi/orgs_sites_test.go | 123 ++++ mistapi/orgs_sso_roles_test.go | 126 ++++ mistapi/orgs_sso_test.go | 199 +++++++ mistapi/orgs_stats_assets_test.go | 92 +++ mistapi/orgs_stats_bgp_peers_test.go | 48 ++ mistapi/orgs_stats_mx_edges_test.go | 58 ++ mistapi/orgs_stats_other_devices_test.go | 29 + mistapi/orgs_stats_ports_test.go | 111 ++++ mistapi/orgs_stats_test.go | 33 ++ mistapi/orgs_stats_tunnels_test.go | 31 + mistapi/orgs_stats_vpn_peers_test.go | 58 ++ mistapi/orgs_subscriptions_test.go | 36 ++ mistapi/orgs_test.go | 138 +++++ mistapi/orgs_tickets_test.go | 211 +++++++ mistapi/orgs_user_ma_cs_test.go | 120 ++++ mistapi/orgs_vars_test.go | 33 ++ mistapi/orgs_vp_ns_test.go | 128 ++++ mistapi/orgs_webhooks_test.go | 202 +++++++ mistapi/orgs_wlan_templates_test.go | 149 +++++ mistapi/orgs_wlans.go | 41 ++ mistapi/orgs_wlans_test.go | 183 ++++++ mistapi/orgs_wx_rules_test.go | 148 +++++ mistapi/orgs_wx_tags_test.go | 166 ++++++ mistapi/orgs_wx_tunnels_test.go | 118 ++++ mistapi/samples_webhooks_test.go | 354 +++++++++++ mistapi/self_account_test.go | 71 +++ mistapi/self_alarms_test.go | 21 + mistapi/self_api_token_test.go | 106 ++++ mistapi/self_audit_logs_test.go | 28 + mistapi/self_mfa_test.go | 51 ++ mistapi/sites_alarms_test.go | 198 +++++++ mistapi/sites_ap_templates_test.go | 29 + mistapi/sites_applications_test.go | 28 + mistapi/sites_asset_filters_test.go | 116 ++++ mistapi/sites_assets_test.go | 151 +++++ mistapi/sites_beacons_test.go | 128 ++++ mistapi/sites_clients_nac_test.go | 164 +++++ mistapi/sites_clients_wan_test.go | 120 ++++ mistapi/sites_clients_wired_test.go | 71 +++ mistapi/sites_clients_wireless_test.go | 242 ++++++++ mistapi/sites_device_profiles_test.go | 29 + mistapi/sites_devices_others_test.go | 90 +++ mistapi/sites_devices_test.go | 320 ++++++++++ mistapi/sites_devices_wan_cluster_test.go | 81 +++ mistapi/sites_devices_wired_test.go | 51 ++ ...ites_devices_wired_virtual_chassis_test.go | 133 +++++ mistapi/sites_devices_wireless_test.go | 78 +++ mistapi/sites_events_test.go | 85 +++ mistapi/sites_evpn_topologies_test.go | 120 ++++ mistapi/sites_gateway_templates_test.go | 27 + mistapi/sites_guests_test.go | 163 +++++ mistapi/sites_jse_test.go | 28 + mistapi/sites_licenses_test.go | 28 + mistapi/sites_location_test.go | 190 ++++++ mistapi/sites_maps_auto_placement_test.go | 175 ++++++ mistapi/sites_maps_test.go | 212 +++++++ mistapi/sites_mx_edges_test.go | 188 ++++++ mistapi/sites_network_templates_test.go | 29 + mistapi/sites_networks_test.go | 29 + mistapi/sites_psks_test.go | 167 ++++++ mistapi/sites_rf_templates_test.go | 29 + mistapi/sites_rfdiags_test.go | 161 +++++ mistapi/sites_rogues_test.go | 142 +++++ mistapi/sites_rrm_test.go | 54 ++ mistapi/sites_rssi_zones_test.go | 126 ++++ mistapi/sites_service_policies_test.go | 29 + mistapi/sites_services_test.go | 101 ++++ mistapi/sites_setting_test.go | 168 ++++++ mistapi/sites_site_templates_test.go | 29 + mistapi/sites_skyatp_test.go | 68 +++ mistapi/sites_stats_apps_test.go | 32 + mistapi/sites_stats_assets_test.go | 186 ++++++ mistapi/sites_stats_beacons_test.go | 31 + mistapi/sites_stats_bgp_peers_test.go | 50 ++ mistapi/sites_stats_calls_test.go | 87 +++ mistapi/sites_stats_clients_sdk_test.go | 54 ++ mistapi/sites_stats_clients_wireless_test.go | 102 ++++ mistapi/sites_stats_devices_test.go | 73 +++ .../sites_stats_discovered_switches_test.go | 113 ++++ mistapi/sites_stats_mx_edges_test.go | 60 ++ mistapi/sites_stats_ports_test.go | 222 +++++++ mistapi/sites_stats_test.go | 28 + mistapi/sites_stats_wx_rules_test.go | 28 + mistapi/sites_stats_zones_test.go | 29 + mistapi/sites_synthetic_tests_test.go | 145 +++++ mistapi/sites_test.go | 69 +++ mistapi/sites_ui_settings_test.go | 146 +++++ mistapi/sites_v_beacons_test.go | 128 ++++ mistapi/sites_vp_ns_test.go | 29 + mistapi/sites_wan_usages_test.go | 72 +++ mistapi/sites_webhooks_test.go | 211 +++++++ mistapi/sites_wlans_test.go | 175 ++++++ mistapi/sites_wx_rules_test.go | 148 +++++ mistapi/sites_wx_tags_test.go | 172 ++++++ mistapi/sites_wx_tunnels_test.go | 128 ++++ mistapi/sites_zones_test.go | 128 ++++ mistapi/tests_base.go | 561 ++++++++++++++++++ mistapi/utilities_common_test.go | 506 ++++++++++++++++ mistapi/utilities_lan_test.go | 266 +++++++++ mistapi/utilities_location_test.go | 29 + mistapi/utilities_mx_edge_test.go | 30 + mistapi/utilities_pca_ps_test.go | 179 ++++++ mistapi/utilities_upgrade_test.go | 426 +++++++++++++ mistapi/utilities_wan_test.go | 232 ++++++++ mistapi/utilities_wi_fi_test.go | 216 +++++++ 325 files changed, 22435 insertions(+), 639 deletions(-) create mode 100644 doc/models/response-inventory-error-exception.md create mode 100644 mistapi/admins_login_test.go create mode 100644 mistapi/admins_logout_test.go create mode 100644 mistapi/admins_lookup_test.go create mode 100644 mistapi/admins_recover_password_test.go create mode 100644 mistapi/admins_test.go create mode 100644 mistapi/constants_definitions_test.go create mode 100644 mistapi/constants_events_test.go create mode 100644 mistapi/constants_models_test.go create mode 100644 mistapi/installer_test.go create mode 100644 mistapi/ms_ps_admins_test.go create mode 100644 mistapi/ms_ps_inventory_test.go create mode 100644 mistapi/ms_ps_licenses_test.go create mode 100644 mistapi/ms_ps_logo_test.go create mode 100644 mistapi/ms_ps_logs_test.go create mode 100644 mistapi/ms_ps_marvis_test.go create mode 100644 mistapi/ms_ps_org_groups_test.go create mode 100644 mistapi/ms_ps_orgs_test.go create mode 100644 mistapi/ms_ps_sso_roles_test.go create mode 100644 mistapi/ms_ps_sso_test.go create mode 100644 mistapi/ms_ps_test.go create mode 100644 mistapi/ms_ps_tickets_test.go create mode 100644 mistapi/orgs_admins_test.go create mode 100644 mistapi/orgs_alarm_templates_test.go create mode 100644 mistapi/orgs_alarms_test.go create mode 100644 mistapi/orgs_antivirus_profiles_test.go create mode 100644 mistapi/orgs_ap_templates_test.go create mode 100644 mistapi/orgs_api_tokens_test.go create mode 100644 mistapi/orgs_asset_filters_test.go create mode 100644 mistapi/orgs_assets_test.go create mode 100644 mistapi/orgs_cert_test.go create mode 100644 mistapi/orgs_clients_marvis_test.go create mode 100644 mistapi/orgs_clients_nac_test.go create mode 100644 mistapi/orgs_clients_sdk_test.go create mode 100644 mistapi/orgs_clients_wan_test.go create mode 100644 mistapi/orgs_clients_wired_test.go create mode 100644 mistapi/orgs_clients_wireless_test.go create mode 100644 mistapi/orgs_cradlepoint_test.go create mode 100644 mistapi/orgs_crl_test.go create mode 100644 mistapi/orgs_device_profiles_test.go create mode 100644 mistapi/orgs_devices_others_test.go create mode 100644 mistapi/orgs_devices_ssr_test.go create mode 100644 mistapi/orgs_devices_test.go create mode 100644 mistapi/orgs_evpn_topologies_test.go create mode 100644 mistapi/orgs_gateway_templates_test.go create mode 100644 mistapi/orgs_guests_test.go create mode 100644 mistapi/orgs_idp_profiles_test.go create mode 100644 mistapi/orgs_inventory_test.go create mode 100644 mistapi/orgs_jse_test.go create mode 100644 mistapi/orgs_jsi_test.go create mode 100644 mistapi/orgs_licenses_test.go create mode 100644 mistapi/orgs_linked_applications_test.go create mode 100644 mistapi/orgs_logs_test.go create mode 100644 mistapi/orgs_maps_test.go create mode 100644 mistapi/orgs_marvis_test.go create mode 100644 mistapi/orgs_mx_clusters_test.go create mode 100644 mistapi/orgs_mx_edges_test.go create mode 100644 mistapi/orgs_mx_tunnels_test.go create mode 100644 mistapi/orgs_nac_portals_test.go create mode 100644 mistapi/orgs_nac_rules_test.go create mode 100644 mistapi/orgs_nac_tags_test.go create mode 100644 mistapi/orgs_naccrl_test.go create mode 100644 mistapi/orgs_nacidp_test.go create mode 100644 mistapi/orgs_network_templates_test.go create mode 100644 mistapi/orgs_networks_test.go create mode 100644 mistapi/orgs_premium_analytics_test.go create mode 100644 mistapi/orgs_psk_portals_test.go create mode 100644 mistapi/orgs_psks_test.go create mode 100644 mistapi/orgs_rf_templates_test.go create mode 100644 mistapi/orgs_scep_test.go create mode 100644 mistapi/orgs_sdk_invites_test.go create mode 100644 mistapi/orgs_sdk_templates_test.go create mode 100644 mistapi/orgs_sec_policies_test.go create mode 100644 mistapi/orgs_service_policies_test.go create mode 100644 mistapi/orgs_services_test.go create mode 100644 mistapi/orgs_setting_test.go create mode 100644 mistapi/orgs_setting_zscaler_test.go create mode 100644 mistapi/orgs_site_templates_test.go create mode 100644 mistapi/orgs_sitegroups_test.go create mode 100644 mistapi/orgs_sites_test.go create mode 100644 mistapi/orgs_sso_roles_test.go create mode 100644 mistapi/orgs_sso_test.go create mode 100644 mistapi/orgs_stats_assets_test.go create mode 100644 mistapi/orgs_stats_bgp_peers_test.go create mode 100644 mistapi/orgs_stats_mx_edges_test.go create mode 100644 mistapi/orgs_stats_other_devices_test.go create mode 100644 mistapi/orgs_stats_ports_test.go create mode 100644 mistapi/orgs_stats_test.go create mode 100644 mistapi/orgs_stats_tunnels_test.go create mode 100644 mistapi/orgs_stats_vpn_peers_test.go create mode 100644 mistapi/orgs_subscriptions_test.go create mode 100644 mistapi/orgs_test.go create mode 100644 mistapi/orgs_tickets_test.go create mode 100644 mistapi/orgs_user_ma_cs_test.go create mode 100644 mistapi/orgs_vars_test.go create mode 100644 mistapi/orgs_vp_ns_test.go create mode 100644 mistapi/orgs_webhooks_test.go create mode 100644 mistapi/orgs_wlan_templates_test.go create mode 100644 mistapi/orgs_wlans_test.go create mode 100644 mistapi/orgs_wx_rules_test.go create mode 100644 mistapi/orgs_wx_tags_test.go create mode 100644 mistapi/orgs_wx_tunnels_test.go create mode 100644 mistapi/samples_webhooks_test.go create mode 100644 mistapi/self_account_test.go create mode 100644 mistapi/self_alarms_test.go create mode 100644 mistapi/self_api_token_test.go create mode 100644 mistapi/self_audit_logs_test.go create mode 100644 mistapi/self_mfa_test.go create mode 100644 mistapi/sites_alarms_test.go create mode 100644 mistapi/sites_ap_templates_test.go create mode 100644 mistapi/sites_applications_test.go create mode 100644 mistapi/sites_asset_filters_test.go create mode 100644 mistapi/sites_assets_test.go create mode 100644 mistapi/sites_beacons_test.go create mode 100644 mistapi/sites_clients_nac_test.go create mode 100644 mistapi/sites_clients_wan_test.go create mode 100644 mistapi/sites_clients_wired_test.go create mode 100644 mistapi/sites_clients_wireless_test.go create mode 100644 mistapi/sites_device_profiles_test.go create mode 100644 mistapi/sites_devices_others_test.go create mode 100644 mistapi/sites_devices_test.go create mode 100644 mistapi/sites_devices_wan_cluster_test.go create mode 100644 mistapi/sites_devices_wired_test.go create mode 100644 mistapi/sites_devices_wired_virtual_chassis_test.go create mode 100644 mistapi/sites_devices_wireless_test.go create mode 100644 mistapi/sites_events_test.go create mode 100644 mistapi/sites_evpn_topologies_test.go create mode 100644 mistapi/sites_gateway_templates_test.go create mode 100644 mistapi/sites_guests_test.go create mode 100644 mistapi/sites_jse_test.go create mode 100644 mistapi/sites_licenses_test.go create mode 100644 mistapi/sites_location_test.go create mode 100644 mistapi/sites_maps_auto_placement_test.go create mode 100644 mistapi/sites_maps_test.go create mode 100644 mistapi/sites_mx_edges_test.go create mode 100644 mistapi/sites_network_templates_test.go create mode 100644 mistapi/sites_networks_test.go create mode 100644 mistapi/sites_psks_test.go create mode 100644 mistapi/sites_rf_templates_test.go create mode 100644 mistapi/sites_rfdiags_test.go create mode 100644 mistapi/sites_rogues_test.go create mode 100644 mistapi/sites_rrm_test.go create mode 100644 mistapi/sites_rssi_zones_test.go create mode 100644 mistapi/sites_service_policies_test.go create mode 100644 mistapi/sites_services_test.go create mode 100644 mistapi/sites_setting_test.go create mode 100644 mistapi/sites_site_templates_test.go create mode 100644 mistapi/sites_skyatp_test.go create mode 100644 mistapi/sites_stats_apps_test.go create mode 100644 mistapi/sites_stats_assets_test.go create mode 100644 mistapi/sites_stats_beacons_test.go create mode 100644 mistapi/sites_stats_bgp_peers_test.go create mode 100644 mistapi/sites_stats_calls_test.go create mode 100644 mistapi/sites_stats_clients_sdk_test.go create mode 100644 mistapi/sites_stats_clients_wireless_test.go create mode 100644 mistapi/sites_stats_devices_test.go create mode 100644 mistapi/sites_stats_discovered_switches_test.go create mode 100644 mistapi/sites_stats_mx_edges_test.go create mode 100644 mistapi/sites_stats_ports_test.go create mode 100644 mistapi/sites_stats_test.go create mode 100644 mistapi/sites_stats_wx_rules_test.go create mode 100644 mistapi/sites_stats_zones_test.go create mode 100644 mistapi/sites_synthetic_tests_test.go create mode 100644 mistapi/sites_test.go create mode 100644 mistapi/sites_ui_settings_test.go create mode 100644 mistapi/sites_v_beacons_test.go create mode 100644 mistapi/sites_vp_ns_test.go create mode 100644 mistapi/sites_wan_usages_test.go create mode 100644 mistapi/sites_webhooks_test.go create mode 100644 mistapi/sites_wlans_test.go create mode 100644 mistapi/sites_wx_rules_test.go create mode 100644 mistapi/sites_wx_tags_test.go create mode 100644 mistapi/sites_wx_tunnels_test.go create mode 100644 mistapi/sites_zones_test.go create mode 100644 mistapi/tests_base.go create mode 100644 mistapi/utilities_common_test.go create mode 100644 mistapi/utilities_lan_test.go create mode 100644 mistapi/utilities_location_test.go create mode 100644 mistapi/utilities_mx_edge_test.go create mode 100644 mistapi/utilities_pca_ps_test.go create mode 100644 mistapi/utilities_upgrade_test.go create mode 100644 mistapi/utilities_wan_test.go create mode 100644 mistapi/utilities_wi_fi_test.go diff --git a/README.md b/README.md index 1aff2752..3696555d 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ## Introduction -> Version: **2408.1.8** +> Version: **2408.1.9** > -> Date: **September 5, 2024** +> Date: **September 9, 2024** --- @@ -55,6 +55,14 @@ require mistapi v0.0.0 - Resolve the dependencies in the updated `go.mod` file, using the `go get` command. +## Test the SDK + +`Go Testing` is used as the testing framework. To run the unit tests of the SDK, navigate to the root directory of the SDK and run the following command in the terminal: + +```bash +$ go test +``` + ## Initialize the API Client **_Note:_** Documentation for the client can be found [here.](doc/client.md) diff --git a/doc/controllers/admins.md b/doc/controllers/admins.md index 1c0ec2a8..d6448b31 100644 --- a/doc/controllers/admins.md +++ b/doc/controllers/admins.md @@ -36,7 +36,7 @@ GetAdminRegistrationInfo( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `recaptchaFlavor` | [`*models.RecaptchaFlavorEnum`](../../doc/models/recaptcha-flavor-enum.md) | Query, Optional | - | +| `recaptchaFlavor` | [`*models.RecaptchaFlavorEnum`](../../doc/models/recaptcha-flavor-enum.md) | Query, Optional | **Default**: `"google"` | ## Response Type diff --git a/doc/controllers/constants-definitions.md b/doc/controllers/constants-definitions.md index c00f8f7f..4e504038 100644 --- a/doc/controllers/constants-definitions.md +++ b/doc/controllers/constants-definitions.md @@ -96,7 +96,7 @@ ListApChannels( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `countryCode` | `*string` | Query, Optional | country code, in two-character | +| `countryCode` | `*string` | Query, Optional | country code, in two-character
**Constraints**: *Pattern*: `^[a-zA-Z]{2}$` | ## Response Type diff --git a/doc/controllers/installer.md b/doc/controllers/installer.md index 2a91be5f..9e2f3d4a 100644 --- a/doc/controllers/installer.md +++ b/doc/controllers/installer.md @@ -78,7 +78,7 @@ AddInstallerDeviceImage( | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | | `imageName` | `string` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `autoDeviceprofileAssignment` | `*bool` | Form, Optional | whether to auto assign device to deviceprofile by name | | `csv` | `*models.FileWrapper` | Form, Optional | csv file for ap name mapping, optional | | `file` | `*models.FileWrapper` | Form, Optional | ekahau or ibwave file | @@ -149,7 +149,7 @@ ClaimInstallerDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `body` | `[]string` | Body, Optional | Request Body | +| `body` | `[]string` | Body, Optional | Request Body
**Constraints**: *Unique Items Required* | ## Response Type @@ -207,6 +207,9 @@ if err != nil { "serial": "FXLH2015150027", "type": "ap" } + ], + "reason": [ + "belongs to another org ('e2f543f7-d6e1-409f-a565-e77a1f098d3b' (other) != '0de5d6fc-219a-414d-a840-67d6b919ad8f' (you))" ] } ``` @@ -215,7 +218,7 @@ if err != nil { | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | -| 400 | Bad Request if none of the entries are valid | `ApiError` | +| 400 | OK - if any of entries are valid or there’s no errors | [`ResponseInventoryErrorException`](../../doc/models/response-inventory-error-exception.md) | | 401 | Unauthorized | [`ResponseHttp401ErrorException`](../../doc/models/response-http-401-error-exception.md) | | 403 | Permission Denied | [`ResponseHttp403ErrorException`](../../doc/models/response-http-403-error-exception.md) | | 404 | Not found. The API endpoint doesn’t exist or resource doesn’ t exist | [`ResponseHttp404Exception`](../../doc/models/response-http-404-exception.md) | @@ -562,7 +565,7 @@ DeleteInstallerDeviceImage( | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | | `imageName` | `string` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -915,7 +918,7 @@ ListInstallerDeviceProfiles( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | ## Response Type @@ -987,8 +990,8 @@ ListInstallerListOfRenctlyClaimedDevices( | `model` | `*string` | Query, Optional | Device Model | | `siteName` | `*string` | Query, Optional | Site Name | | `siteId` | `*uuid.UUID` | Query, Optional | Site ID | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -1466,7 +1469,7 @@ ProvisionInstallerDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `body` | [`*models.InstallerProvisionDevice`](../../doc/models/installer-provision-device.md) | Body, Optional | Request Body | ## Response Type @@ -1530,7 +1533,7 @@ StartInstallerLocateDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -1582,7 +1585,7 @@ StopInstallerLocateDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -1634,7 +1637,7 @@ UnassignInstallerRecentlyClaimedDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/controllers/ms-ps-inventory.md b/doc/controllers/ms-ps-inventory.md index 2e16accc..46d9a051 100644 --- a/doc/controllers/ms-ps-inventory.md +++ b/doc/controllers/ms-ps-inventory.md @@ -27,7 +27,7 @@ GetMspInventoryByMac( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `mspId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/controllers/ms-ps-logs.md b/doc/controllers/ms-ps-logs.md index f6861d5c..99c83e9d 100644 --- a/doc/controllers/ms-ps-logs.md +++ b/doc/controllers/ms-ps-logs.md @@ -32,7 +32,7 @@ CountMspAuditLogs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `mspId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.MspLogsCountDistinctEnum`](../../doc/models/msp-logs-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.MspLogsCountDistinctEnum`](../../doc/models/msp-logs-count-distinct-enum.md) | Query, Optional | **Default**: `"admin_name"` | ## Response Type @@ -118,9 +118,9 @@ ListMspAuditLogs( | `sort` | [`*models.ListMspLogsSortEnum`](../../doc/models/list-msp-logs-sort-enum.md) | Query, Optional | sort order | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/ms-ps-marvis.md b/doc/controllers/ms-ps-marvis.md index 461ddc44..5a969755 100644 --- a/doc/controllers/ms-ps-marvis.md +++ b/doc/controllers/ms-ps-marvis.md @@ -29,9 +29,9 @@ CountMspsMarvisActions( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `mspId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.MspMarvisSuggestionsCountDistinctEnum`](../../doc/models/msp-marvis-suggestions-count-distinct-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `distinct` | [`*models.MspMarvisSuggestionsCountDistinctEnum`](../../doc/models/msp-marvis-suggestions-count-distinct-enum.md) | Query, Optional | **Default**: `"org_id"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/ms-ps-orgs.md b/doc/controllers/ms-ps-orgs.md index 6c779433..e0a4b576 100644 --- a/doc/controllers/ms-ps-orgs.md +++ b/doc/controllers/ms-ps-orgs.md @@ -243,8 +243,8 @@ ListMspOrgStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `mspId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -436,8 +436,8 @@ SearchMspOrgs( | `orgId` | `*uuid.UUID` | Query, Optional | org id | | `subInsufficient` | `*bool` | Query, Optional | if this org has sufficient subscription | | `trialEnabled` | `*bool` | Query, Optional | if this org is under trial period | -| `usageTypes` | `[]string` | Query, Optional | a list of types that enabled by usage | -| `limit` | `*int` | Query, Optional | - | +| `usageTypes` | `[]string` | Query, Optional | a list of types that enabled by usage
**Constraints**: *Unique Items Required* | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/ms-ps-sl-es.md b/doc/controllers/ms-ps-sl-es.md index af30e60b..eb14b221 100644 --- a/doc/controllers/ms-ps-sl-es.md +++ b/doc/controllers/ms-ps-sl-es.md @@ -34,7 +34,7 @@ GetMspSle( | `mspId` | `uuid.UUID` | Template, Required | - | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | | `sle` | `*string` | Query, Optional | see /api/v1/const/insight_metrics for more details | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | diff --git a/doc/controllers/ms-ps-tickets.md b/doc/controllers/ms-ps-tickets.md index a14e1ea8..7d2933dc 100644 --- a/doc/controllers/ms-ps-tickets.md +++ b/doc/controllers/ms-ps-tickets.md @@ -32,7 +32,7 @@ CountMspTickets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `mspId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.MspTicketsCountDistinctEnum`](../../doc/models/msp-tickets-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.MspTicketsCountDistinctEnum`](../../doc/models/msp-tickets-count-distinct-enum.md) | Query, Optional | **Default**: `"status"` | ## Response Type @@ -108,7 +108,7 @@ ListMspTickets( | `mspId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/ms-ps.md b/doc/controllers/ms-ps.md index bb78cf38..0717ed10 100644 --- a/doc/controllers/ms-ps.md +++ b/doc/controllers/ms-ps.md @@ -216,10 +216,10 @@ SearchMspOrgGroup( | `mspId` | `uuid.UUID` | Template, Required | - | | `mType` | [`models.MspSearchTypeEnum`](../../doc/models/msp-search-type-enum.md) | Query, Required | orgs | | `q` | `*string` | Query, Optional | search string | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-alarm-templates.md b/doc/controllers/orgs-alarm-templates.md index dbd06f92..0747760d 100644 --- a/doc/controllers/orgs-alarm-templates.md +++ b/doc/controllers/orgs-alarm-templates.md @@ -236,8 +236,8 @@ ListOrgAlarmTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -293,7 +293,7 @@ ListOrgSuppressedAlarms( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `scope` | [`*models.SuppressedAlarmScopeEnum`](../../doc/models/suppressed-alarm-scope-enum.md) | Query, Optional | - | +| `scope` | [`*models.SuppressedAlarmScopeEnum`](../../doc/models/suppressed-alarm-scope-enum.md) | Query, Optional | **Default**: `"site"` | ## Response Type diff --git a/doc/controllers/orgs-alarms.md b/doc/controllers/orgs-alarms.md index fb6dd470..2f24825e 100644 --- a/doc/controllers/orgs-alarms.md +++ b/doc/controllers/orgs-alarms.md @@ -217,9 +217,9 @@ CountOrgAlarms( | `distinct` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -310,8 +310,8 @@ SearchOrgAlarms( | `mType` | `*string` | Query, Optional | alarm type | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/orgs-antivirus-profiles.md b/doc/controllers/orgs-antivirus-profiles.md index 66bb3ac3..044b6b55 100644 --- a/doc/controllers/orgs-antivirus-profiles.md +++ b/doc/controllers/orgs-antivirus-profiles.md @@ -231,8 +231,8 @@ ListOrgAntivirusProfiles( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-ap-templates.md b/doc/controllers/orgs-ap-templates.md index 1be5e558..f0488e96 100644 --- a/doc/controllers/orgs-ap-templates.md +++ b/doc/controllers/orgs-ap-templates.md @@ -774,8 +774,8 @@ ListOrgAptemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-asset-filters.md b/doc/controllers/orgs-asset-filters.md index 22d3550e..c2a71d8a 100644 --- a/doc/controllers/orgs-asset-filters.md +++ b/doc/controllers/orgs-asset-filters.md @@ -247,8 +247,8 @@ ListOrgAssetFilters( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-assets.md b/doc/controllers/orgs-assets.md index bd9bf6f8..83bd81b6 100644 --- a/doc/controllers/orgs-assets.md +++ b/doc/controllers/orgs-assets.md @@ -295,8 +295,8 @@ ListOrgAssets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-clients-nac.md b/doc/controllers/orgs-clients-nac.md index bfbe459b..a0bc39dd 100644 --- a/doc/controllers/orgs-clients-nac.md +++ b/doc/controllers/orgs-clients-nac.md @@ -43,8 +43,8 @@ CountOrgNacClientEvents( | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listNacEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -147,7 +147,7 @@ CountOrgNacClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgNacClientsCountDistinctEnum`](../../doc/models/org-nac-clients-count-distinct-enum.md) | Query, Optional | NAC Policy Rule ID, if matched | +| `distinct` | [`*models.OrgNacClientsCountDistinctEnum`](../../doc/models/org-nac-clients-count-distinct-enum.md) | Query, Optional | NAC Policy Rule ID, if matched
**Default**: `"type"` | | `lastNacruleId` | `*string` | Query, Optional | NAC Policy Rule ID, if matched | | `nacruleMatched` | `*bool` | Query, Optional | NAC Policy Rule Matched | | `authType` | `*string` | Query, Optional | authentication type, e.g. "eap-tls", "peap-tls", "eap-ttls", "eap-teap", "mab", "psk", "device-auth" | @@ -166,9 +166,9 @@ CountOrgNacClients( | `mdmProvider` | `*string` | Query, Optional | MDM provider of client’s organisation eg “intune”, “jamf” | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -315,7 +315,7 @@ SearchOrgNacClientEvents( | `bssid` | `*string` | Query, Optional | SSID | | `idpId` | `*uuid.UUID` | Query, Optional | SSO ID, if present and used | | `idpRole` | `*string` | Query, Optional | IDP returned roles/groups for the user | -| `respAttrs` | `[]string` | Query, Optional | Radius attributes returned by NAC to NAS Devive | +| `respAttrs` | `[]string` | Query, Optional | Radius attributes returned by NAC to NAS Devive
**Constraints**: *Unique Items Required* | | `ssid` | `*string` | Query, Optional | SSID | | `username` | `*string` | Query, Optional | Username presented by the client | | `siteId` | `*string` | Query, Optional | site id | @@ -325,8 +325,8 @@ SearchOrgNacClientEvents( | `timestamp` | `*float64` | Query, Optional | start time, in epoch | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -505,9 +505,9 @@ SearchOrgNacClients( | `mdmProvider` | `*string` | Query, Optional | MDM provider of client’s organisation eg “intune”, “jamf” | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-clients-wan.md b/doc/controllers/orgs-clients-wan.md index 4c7918b6..4bf4ea1c 100644 --- a/doc/controllers/orgs-clients-wan.md +++ b/doc/controllers/orgs-clients-wan.md @@ -39,12 +39,12 @@ CountOrgWanClientEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgWanClientsEventsCountDistinctEnum`](../../doc/models/org-wan-clients-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgWanClientsEventsCountDistinctEnum`](../../doc/models/org-wan-clients-events-count-distinct-enum.md) | Query, Optional | **Default**: `"type"` | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -131,12 +131,12 @@ CountOrgWanClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgWanClientsCountDistinctEnum`](../../doc/models/org-wan-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgWanClientsCountDistinctEnum`](../../doc/models/org-wan-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -235,8 +235,8 @@ SearchOrgWanClientEvents( | `nacruleId` | `*string` | Query, Optional | nacrule_id | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -347,9 +347,9 @@ SearchOrgWanClients( | `mfg` | `*string` | Query, Optional | Manufacture | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-clients-wired.md b/doc/controllers/orgs-clients-wired.md index 2ba0aa8c..dfe8a60a 100644 --- a/doc/controllers/orgs-clients-wired.md +++ b/doc/controllers/orgs-clients-wired.md @@ -39,12 +39,12 @@ CountOrgWiredClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgWiredClientsCountDistinctEnum`](../../doc/models/org-wired-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgWiredClientsCountDistinctEnum`](../../doc/models/org-wired-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -149,10 +149,10 @@ SearchOrgWiredClients( | `manufacture` | `*string` | Query, Optional | client manufacturer | | `text` | `*string` | Query, Optional | single entry of hostname/mac | | `nacruleId` | `*string` | Query, Optional | nacrule_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-clients-wireless.md b/doc/controllers/orgs-clients-wireless.md index 31e1d531..c6b362eb 100644 --- a/doc/controllers/orgs-clients-wireless.md +++ b/doc/controllers/orgs-clients-wireless.md @@ -49,7 +49,7 @@ CountOrgWirelessClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgClientsCountDistinctEnum`](../../doc/models/org-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgClientsCountDistinctEnum`](../../doc/models/org-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"device"` | | `mac` | `*string` | Query, Optional | partial / full MAC address | | `hostname` | `*string` | Query, Optional | partial / full hostname | | `device` | `*string` | Query, Optional | device type, e.g. Mac, Nvidia, iPhone | @@ -61,9 +61,9 @@ CountOrgWirelessClients( | `ipAddress` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -176,7 +176,7 @@ CountOrgWirelessClientsSessions( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgClientSessionsCountDistinctEnum`](../../doc/models/org-client-sessions-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgClientSessionsCountDistinctEnum`](../../doc/models/org-client-sessions-count-distinct-enum.md) | Query, Optional | **Default**: `"device"` | | `ap` | `*string` | Query, Optional | AP MAC | | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `clientFamily` | `*string` | Query, Optional | E.g. “Mac”, “iPhone”, “Apple watch” | @@ -187,9 +187,9 @@ CountOrgWirelessClientsSessions( | `wlanId` | `*string` | Query, Optional | wlan_id | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -306,10 +306,10 @@ SearchOrgWirelessClientEvents( | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `wlanId` | `*string` | Query, Optional | wlan_id | | `nacruleId` | `*string` | Query, Optional | nacrule_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -436,10 +436,10 @@ SearchOrgWirelessClientSessions( | `wlanId` | `*string` | Query, Optional | wlan_id | | `pskId` | `*string` | Query, Optional | PSK ID | | `pskName` | `*string` | Query, Optional | PSK Name | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -580,10 +580,10 @@ SearchOrgWirelessClients( | `vlan` | `*string` | Query, Optional | vlan | | `ssid` | `*string` | Query, Optional | SSID | | `text` | `*string` | Query, Optional | partial / full MAC address, hostname, username, psk_name or ip | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-device-profiles.md b/doc/controllers/orgs-device-profiles.md index a9b4c1dd..515bc55c 100644 --- a/doc/controllers/orgs-device-profiles.md +++ b/doc/controllers/orgs-device-profiles.md @@ -631,9 +631,9 @@ ListOrgDeviceProfiles( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-devices-others.md b/doc/controllers/orgs-devices-others.md index a1122503..45bcbd0f 100644 --- a/doc/controllers/orgs-devices-others.md +++ b/doc/controllers/orgs-devices-others.md @@ -43,12 +43,12 @@ CountOrgOtherDeviceEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgOtherdevicesEventsCountDistinctEnum`](../../doc/models/org-otherdevices-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgOtherdevicesEventsCountDistinctEnum`](../../doc/models/org-otherdevices-events-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listOtherDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -130,7 +130,7 @@ DeleteOrgOtherDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -182,7 +182,7 @@ GetOrgOtherDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -265,8 +265,8 @@ ListOrgOtherDevices( | `serial` | `*string` | Query, Optional | - | | `model` | `*string` | Query, Optional | - | | `name` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -352,7 +352,7 @@ RebootOrgOtherDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -421,8 +421,8 @@ SearchOrgOtherDeviceEvents( | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listOtherDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -516,7 +516,7 @@ UpdateOrgOtherDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `body` | [`*models.OtherDeviceUpdate`](../../doc/models/other-device-update.md) | Body, Optional | - | ## Response Type diff --git a/doc/controllers/orgs-devices.md b/doc/controllers/orgs-devices.md index 653f1255..2410a5a2 100644 --- a/doc/controllers/orgs-devices.md +++ b/doc/controllers/orgs-devices.md @@ -50,7 +50,7 @@ CountOrgDeviceEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgDevicesEventsCountDistinctEnum`](../../doc/models/org-devices-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgDevicesEventsCountDistinctEnum`](../../doc/models/org-devices-events-count-distinct-enum.md) | Query, Optional | **Default**: `"model"` | | `siteId` | `*string` | Query, Optional | site id | | `ap` | `*string` | Query, Optional | AP mac | | `apfw` | `*string` | Query, Optional | AP Firmware | @@ -58,10 +58,10 @@ CountOrgDeviceEvents( | `text` | `*string` | Query, Optional | event message | | `timestamp` | `*string` | Query, Optional | event time | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -159,11 +159,11 @@ CountOrgDeviceLastConfigs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `distinct` | [`*models.OrgDevicesLastConfigsCountDistinctEnum`](../../doc/models/org-devices-last-configs-count-distinct-enum.md) | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -261,7 +261,7 @@ CountOrgDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgDevicesCountDistinctEnum`](../../doc/models/org-devices-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgDevicesCountDistinctEnum`](../../doc/models/org-devices-count-distinct-enum.md) | Query, Optional | **Default**: `"model"` | | `hostname` | `*string` | Query, Optional | partial / full hostname | | `siteId` | `*string` | Query, Optional | site id | | `model` | `*string` | Query, Optional | device model | @@ -277,9 +277,9 @@ CountOrgDevices( | `lldpMgmtAddr` | `*string` | Query, Optional | LLDP management ip address | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -455,8 +455,8 @@ ListOrgApsMacs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -610,15 +610,15 @@ SearchOrgDeviceEvents( | `orgId` | `uuid.UUID` | Template, Required | - | | `mac` | `*string` | Query, Optional | device mac | | `model` | `*string` | Query, Optional | device model | -| `deviceType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `deviceType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `text` | `*string` | Query, Optional | event message | | `timestamp` | `*string` | Query, Optional | event time | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `lastBy` | `*string` | Query, Optional | Return last/recent event for passed in field | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -723,14 +723,14 @@ SearchOrgDeviceLastConfigs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `mac` | `*string` | Query, Optional | Device MAC address | | `name` | `*string` | Query, Optional | Devices Name | | `version` | `*string` | Query, Optional | Device Version | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `limit` | `*int` | Query, Optional | - | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -910,10 +910,10 @@ SearchOrgDevices( | `band5Channel` | `*int` | Query, Optional | Channel of band_5 | | `band6Channel` | `*int` | Query, Optional | Channel of band_6 | | `eth0PortSpeed` | `*int` | Query, Optional | Port speed of eth0 | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-evpn-topologies.md b/doc/controllers/orgs-evpn-topologies.md index 5ca6ef2c..c1adbf6b 100644 --- a/doc/controllers/orgs-evpn-topologies.md +++ b/doc/controllers/orgs-evpn-topologies.md @@ -309,8 +309,8 @@ ListOrgEvpnTopologies( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-gateway-templates.md b/doc/controllers/orgs-gateway-templates.md index 91622e11..8890ade3 100644 --- a/doc/controllers/orgs-gateway-templates.md +++ b/doc/controllers/orgs-gateway-templates.md @@ -507,8 +507,8 @@ ListOrgGatewayTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-guests.md b/doc/controllers/orgs-guests.md index 46449c28..9f867133 100644 --- a/doc/controllers/orgs-guests.md +++ b/doc/controllers/orgs-guests.md @@ -41,12 +41,12 @@ CountOrgGuestAuthorizations( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgGuestsCountDistinctEnum`](../../doc/models/org-guests-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgGuestsCountDistinctEnum`](../../doc/models/org-guests-count-distinct-enum.md) | Query, Optional | **Default**: `"auth_method"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -128,7 +128,7 @@ DeleteOrgGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -180,7 +180,7 @@ GetOrgGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -333,10 +333,10 @@ SearchOrgGuestAuthorization( | `wlanId` | `*string` | Query, Optional | WLAN ID | | `authMethod` | `*string` | Query, Optional | Authentication Methdo | | `ssid` | `*string` | Query, Optional | SSID | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -439,7 +439,7 @@ UpdateOrgGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `body` | [`*models.Guest`](../../doc/models/guest.md) | Body, Optional | - | ## Response Type diff --git a/doc/controllers/orgs-idp-profiles.md b/doc/controllers/orgs-idp-profiles.md index 573808ba..ecfb172e 100644 --- a/doc/controllers/orgs-idp-profiles.md +++ b/doc/controllers/orgs-idp-profiles.md @@ -271,8 +271,8 @@ ListOrgIdpProfiles( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-inventory.md b/doc/controllers/orgs-inventory.md index 070ee001..402faac6 100644 --- a/doc/controllers/orgs-inventory.md +++ b/doc/controllers/orgs-inventory.md @@ -37,7 +37,7 @@ AddOrgInventory( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `body` | `[]string` | Body, Optional | Request Body | +| `body` | `[]string` | Body, Optional | Request Body
**Constraints**: *Unique Items Required* | ## Response Type @@ -95,6 +95,9 @@ if err != nil { "serial": "FXLH2015150027", "type": "ap" } + ], + "reason": [ + "belongs to another org ('e2f543f7-d6e1-409f-a565-e77a1f098d3b' (other) != '0de5d6fc-219a-414d-a840-67d6b919ad8f' (you))" ] } ``` @@ -103,7 +106,7 @@ if err != nil { | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | -| 400 | if none of the entries are valid | `ApiError` | +| 400 | OK - if any of entries are valid or there’s no errors | [`ResponseInventoryErrorException`](../../doc/models/response-inventory-error-exception.md) | | 401 | Unauthorized | [`ResponseHttp401ErrorException`](../../doc/models/response-http-401-error-exception.md) | | 403 | Permission Denied | [`ResponseHttp403ErrorException`](../../doc/models/response-http-403-error-exception.md) | | 404 | Not found. The API endpoint doesn’t exist or resource doesn’ t exist | [`ResponseHttp404Exception`](../../doc/models/response-http-404-exception.md) | @@ -273,14 +276,14 @@ GetOrgInventory( | `orgId` | `uuid.UUID` | Template, Required | - | | `serial` | `*string` | Query, Optional | device serial | | `model` | `*string` | Query, Optional | device model | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `mac` | `*string` | Query, Optional | MAC address | | `siteId` | `*string` | Query, Optional | site id if assigned, null if not assigned | | `vcMac` | `*string` | Query, Optional | Virtual Chassis MAC Address | -| `vc` | `*bool` | Query, Optional | To display Virtual Chassis members | -| `unassigned` | `*bool` | Query, Optional | to display Unassigned devices | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `vc` | `*bool` | Query, Optional | To display Virtual Chassis members
**Default**: `false` | +| `unassigned` | `*bool` | Query, Optional | to display Unassigned devices
**Default**: `true` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-jsi.md b/doc/controllers/orgs-jsi.md index 66ec7b6d..2f64346d 100644 --- a/doc/controllers/orgs-jsi.md +++ b/doc/controllers/orgs-jsi.md @@ -92,7 +92,7 @@ CreateOrgJsiDeviceShellSession( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -150,8 +150,8 @@ ListOrgJsiDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | | `model` | `*string` | Query, Optional | Device model | | `serial` | `*string` | Query, Optional | Device serial | | `mac` | `*string` | Query, Optional | Device MAC Address | @@ -233,8 +233,8 @@ ListOrgJsiPastPurchases( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | | `model` | `*string` | Query, Optional | - | | `serial` | `*string` | Query, Optional | - | diff --git a/doc/controllers/orgs-logs.md b/doc/controllers/orgs-logs.md index 7a5d971f..6c0cf76c 100644 --- a/doc/controllers/orgs-logs.md +++ b/doc/controllers/orgs-logs.md @@ -41,16 +41,16 @@ CountOrgAuditLogs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgLogsCountDistinctEnum`](../../doc/models/org-logs-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgLogsCountDistinctEnum`](../../doc/models/org-logs-count-distinct-enum.md) | Query, Optional | **Default**: `"admin_name"` | | `adminId` | `*string` | Query, Optional | - | | `adminName` | `*string` | Query, Optional | - | | `siteId` | `*string` | Query, Optional | - | | `message` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -154,9 +154,9 @@ ListOrgAuditLogs( | `sort` | [`*models.ListOrgLogsSortEnum`](../../doc/models/list-org-logs-sort-enum.md) | Query, Optional | sort order | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-mx-clusters.md b/doc/controllers/orgs-mx-clusters.md index 35fba833..722c4705 100644 --- a/doc/controllers/orgs-mx-clusters.md +++ b/doc/controllers/orgs-mx-clusters.md @@ -347,8 +347,8 @@ ListOrgMxEdgeClusters( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-mx-edges.md b/doc/controllers/orgs-mx-edges.md index e2fa3b25..1fc15771 100644 --- a/doc/controllers/orgs-mx-edges.md +++ b/doc/controllers/orgs-mx-edges.md @@ -53,7 +53,7 @@ AddOrgMxEdgeImage( | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | | `mxedgeId` | `uuid.UUID` | Template, Required | - | -| `imageNumber` | `int` | Template, Required | - | +| `imageNumber` | `int` | Template, Required | **Constraints**: `>= 1`, `<= 3` | | `body` | [`*models.ImageImport`](../../doc/models/image-import.md) | Body, Optional | - | ## Response Type @@ -378,7 +378,7 @@ CountOrgMxEdges( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgMxedgeCountDistinctEnum`](../../doc/models/org-mxedge-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgMxedgeCountDistinctEnum`](../../doc/models/org-mxedge-count-distinct-enum.md) | Query, Optional | **Default**: `"model"` | | `mxedgeId` | `*string` | Query, Optional | mist edge id | | `siteId` | `*string` | Query, Optional | mist edge site id | | `mxclusterId` | `*string` | Query, Optional | mist edge cluster id | @@ -389,9 +389,9 @@ CountOrgMxEdges( | `stats` | `*bool` | Query, Optional | whether to return device stats, default is false | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -497,15 +497,15 @@ CountOrgSiteMxEdgeEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgMxedgeEventsCountDistinctEnum`](../../doc/models/org-mxedge-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgMxedgeEventsCountDistinctEnum`](../../doc/models/org-mxedge-events-count-distinct-enum.md) | Query, Optional | **Default**: `"mxedge_id"` | | `mxedgeId` | `*string` | Query, Optional | mist edge id | | `mxclusterId` | `*string` | Query, Optional | mist edge cluster id | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `service` | `*string` | Query, Optional | service running on mist edge(mxagent, tunterm etc) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -794,7 +794,7 @@ DeleteOrgMxEdgeImage( | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | | `mxedgeId` | `uuid.UUID` | Template, Required | - | -| `imageNumber` | `int` | Template, Required | - | +| `imageNumber` | `int` | Template, Required | **Constraints**: `>= 1`, `<= 3` | ## Response Type @@ -958,7 +958,7 @@ GetOrgMxEdgeUpgradeInfo( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `channel` | [`*models.GetOrgMxedgeUpgradeInfoChannelEnum`](../../doc/models/get-org-mxedge-upgrade-info-channel-enum.md) | Query, Optional | upgrade channel to follow, stable (default) / beta / alpha | +| `channel` | [`*models.GetOrgMxedgeUpgradeInfoChannelEnum`](../../doc/models/get-org-mxedge-upgrade-info-channel-enum.md) | Query, Optional | upgrade channel to follow, stable (default) / beta / alpha
**Default**: `"stable"` | ## Response Type @@ -1030,9 +1030,9 @@ ListOrgMxEdges( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `forSites` | [`*models.MxedgeForSiteEnum`](../../doc/models/mxedge-for-site-enum.md) | Query, Optional | filter for site level mist edges | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `forSites` | [`*models.MxedgeForSiteEnum`](../../doc/models/mxedge-for-site-enum.md) | Query, Optional | filter for site level mist edges
**Default**: `"any"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -1256,8 +1256,8 @@ SearchOrgMistEdgeEvents( | `service` | `*string` | Query, Optional | service running on mist edge(mxagent, tunterm etc) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -1368,9 +1368,9 @@ SearchOrgMxEdges( | `stats` | `*bool` | Query, Optional | whether to return device stats, default is false | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-mx-tunnels.md b/doc/controllers/orgs-mx-tunnels.md index 207ec540..eb17707a 100644 --- a/doc/controllers/orgs-mx-tunnels.md +++ b/doc/controllers/orgs-mx-tunnels.md @@ -286,8 +286,8 @@ ListOrgMxTunnels( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-nac-portals.md b/doc/controllers/orgs-nac-portals.md index 63591575..a0db0c25 100644 --- a/doc/controllers/orgs-nac-portals.md +++ b/doc/controllers/orgs-nac-portals.md @@ -461,9 +461,9 @@ ListOrgNacPortalSsoLatestFailures( | `nacportalId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -542,8 +542,8 @@ ListOrgNacPortals( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-nac-rules.md b/doc/controllers/orgs-nac-rules.md index 6672a38e..8fa9c515 100644 --- a/doc/controllers/orgs-nac-rules.md +++ b/doc/controllers/orgs-nac-rules.md @@ -223,8 +223,8 @@ ListOrgNacRules( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-nac-tags.md b/doc/controllers/orgs-nac-tags.md index 98fe935c..01562d07 100644 --- a/doc/controllers/orgs-nac-tags.md +++ b/doc/controllers/orgs-nac-tags.md @@ -250,8 +250,8 @@ ListOrgNacTags( | `mType` | `*string` | Query, Optional | Type of NAC Tag | | `name` | `*string` | Query, Optional | Name of NAC Tag | | `match` | `*string` | Query, Optional | Type of NAC Tag | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-network-templates.md b/doc/controllers/orgs-network-templates.md index be5f3eb7..b3ad958a 100644 --- a/doc/controllers/orgs-network-templates.md +++ b/doc/controllers/orgs-network-templates.md @@ -580,8 +580,8 @@ ListOrgNetworkTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-networks.md b/doc/controllers/orgs-networks.md index 234b9308..e2fda519 100644 --- a/doc/controllers/orgs-networks.md +++ b/doc/controllers/orgs-networks.md @@ -571,8 +571,8 @@ ListOrgNetworks( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-premium-analytics.md b/doc/controllers/orgs-premium-analytics.md index 73951e2d..bee42bb8 100644 --- a/doc/controllers/orgs-premium-analytics.md +++ b/doc/controllers/orgs-premium-analytics.md @@ -28,8 +28,8 @@ ListOrgPmaDashboards( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-psk-portals.md b/doc/controllers/orgs-psk-portals.md index 44fed26c..05bd2c2c 100644 --- a/doc/controllers/orgs-psk-portals.md +++ b/doc/controllers/orgs-psk-portals.md @@ -46,12 +46,12 @@ CountOrgPskPortalLogs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgPskPortalLogsCountDistinctEnum`](../../doc/models/org-psk-portal-logs-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgPskPortalLogsCountDistinctEnum`](../../doc/models/org-psk-portal-logs-count-distinct-enum.md) | Query, Optional | **Default**: `"pskportal_id"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -372,9 +372,9 @@ ListOrgPskPortalLogs( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -460,8 +460,8 @@ ListOrgPskPortals( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -530,9 +530,9 @@ SearchOrgPskPortalLogs( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | | `pskName` | `*string` | Query, Optional | - | | `pskId` | `*string` | Query, Optional | - | | `pskportalId` | `*string` | Query, Optional | - | diff --git a/doc/controllers/orgs-psks.md b/doc/controllers/orgs-psks.md index daeccacd..aac8a2a3 100644 --- a/doc/controllers/orgs-psks.md +++ b/doc/controllers/orgs-psks.md @@ -425,8 +425,8 @@ ListOrgPsks( | `name` | `*string` | Query, Optional | - | | `ssid` | `*string` | Query, Optional | - | | `role` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -508,7 +508,7 @@ UpdateOrgMultiplePsks( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `body` | [`[]models.Psk`](../../doc/models/psk.md) | Body, Optional | - | +| `body` | [`[]models.Psk`](../../doc/models/psk.md) | Body, Optional | **Constraints**: *Unique Items Required* | ## Response Type diff --git a/doc/controllers/orgs-rf-templates.md b/doc/controllers/orgs-rf-templates.md index 0d264bf4..89036cfa 100644 --- a/doc/controllers/orgs-rf-templates.md +++ b/doc/controllers/orgs-rf-templates.md @@ -311,8 +311,8 @@ ListOrgRfTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-sec-policies.md b/doc/controllers/orgs-sec-policies.md index bc93c3fd..eaa344bc 100644 --- a/doc/controllers/orgs-sec-policies.md +++ b/doc/controllers/orgs-sec-policies.md @@ -644,8 +644,8 @@ ListOrgSecPolicies( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-service-policies.md b/doc/controllers/orgs-service-policies.md index 8bda1c0f..f61401db 100644 --- a/doc/controllers/orgs-service-policies.md +++ b/doc/controllers/orgs-service-policies.md @@ -205,8 +205,8 @@ ListOrgServicePolicies( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-services.md b/doc/controllers/orgs-services.md index d23fcabf..d94592ab 100644 --- a/doc/controllers/orgs-services.md +++ b/doc/controllers/orgs-services.md @@ -284,8 +284,8 @@ ListOrgServices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-site-templates.md b/doc/controllers/orgs-site-templates.md index e636927b..cbe58d58 100644 --- a/doc/controllers/orgs-site-templates.md +++ b/doc/controllers/orgs-site-templates.md @@ -237,8 +237,8 @@ ListOrgSiteTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-sitegroups.md b/doc/controllers/orgs-sitegroups.md index fb2ce786..799def93 100644 --- a/doc/controllers/orgs-sitegroups.md +++ b/doc/controllers/orgs-sitegroups.md @@ -228,8 +228,8 @@ ListOrgSiteGroups( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-sites.md b/doc/controllers/orgs-sites.md index 5beaab76..e9e8f6c0 100644 --- a/doc/controllers/orgs-sites.md +++ b/doc/controllers/orgs-sites.md @@ -39,12 +39,12 @@ CountOrgSites( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgSitesCountDistinctEnum`](../../doc/models/org-sites-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgSitesCountDistinctEnum`](../../doc/models/org-sites-count-distinct-enum.md) | Query, Optional | **Default**: `"id"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -230,8 +230,8 @@ ListOrgSites( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -354,10 +354,10 @@ SearchOrgSites( | `rtsaEnabled` | `*bool` | Query, Optional | if managed mobility feature is enabled | | `vnaEnabled` | `*bool` | Query, Optional | if Virtual Network Assistant is enabled | | `wifiEnabled` | `*bool` | Query, Optional | if WIFI feature is enabled | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-sl-es.md b/doc/controllers/orgs-sl-es.md index 111b7806..04539092 100644 --- a/doc/controllers/orgs-sl-es.md +++ b/doc/controllers/orgs-sl-es.md @@ -41,10 +41,10 @@ GetOrgSitesSle( | `sle` | [`*models.OrgSiteSleTypeEnum`](../../doc/models/org-site-sle-type-enum.md) | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -125,7 +125,7 @@ GetOrgSle( | `orgId` | `uuid.UUID` | Template, Required | - | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | | `sle` | `*string` | Query, Optional | see [listInsightMetrics]($e/Constants%Definitions/listInsightMetrics) for more details | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | diff --git a/doc/controllers/orgs-sso-roles.md b/doc/controllers/orgs-sso-roles.md index b1e53896..d5ab28d7 100644 --- a/doc/controllers/orgs-sso-roles.md +++ b/doc/controllers/orgs-sso-roles.md @@ -247,8 +247,8 @@ ListOrgSsoRoles( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-sso.md b/doc/controllers/orgs-sso.md index 28e75c6c..1441280d 100644 --- a/doc/controllers/orgs-sso.md +++ b/doc/controllers/orgs-sso.md @@ -400,9 +400,9 @@ ListOrgSsoLatestFailures( | `ssoId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -481,8 +481,8 @@ ListOrgSsos( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-stats-assets.md b/doc/controllers/orgs-stats-assets.md index b4eb156b..188a209a 100644 --- a/doc/controllers/orgs-stats-assets.md +++ b/doc/controllers/orgs-stats-assets.md @@ -111,9 +111,9 @@ ListOrgAssetsStats( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -240,10 +240,10 @@ SearchOrgAssets( | `apMac` | `*string` | Query, Optional | - | | `beam` | `*int` | Query, Optional | - | | `rssi` | `*int` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-stats-devices.md b/doc/controllers/orgs-stats-devices.md index fbc11c52..f59764fe 100644 --- a/doc/controllers/orgs-stats-devices.md +++ b/doc/controllers/orgs-stats-devices.md @@ -39,8 +39,8 @@ ListOrgDevicesStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | - | -| `status` | [`*models.DeviceStatusEnum`](../../doc/models/device-status-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | **Default**: `"ap"` | +| `status` | [`*models.DeviceStatusEnum`](../../doc/models/device-status-enum.md) | Query, Optional | **Default**: `"all"` | | `siteId` | `*string` | Query, Optional | - | | `mac` | `*string` | Query, Optional | - | | `evpntopoId` | `*string` | Query, Optional | EVPN Topology ID | @@ -48,9 +48,9 @@ ListOrgDevicesStats( | `fields` | `*string` | Query, Optional | list of additional fields requests, comma separeted, or `fields=*` for all of them | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-stats-mx-edges.md b/doc/controllers/orgs-stats-mx-edges.md index 93fb8239..2998b3c2 100644 --- a/doc/controllers/orgs-stats-mx-edges.md +++ b/doc/controllers/orgs-stats-mx-edges.md @@ -262,12 +262,12 @@ ListOrgMxEdgesStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `forSite` | `*bool` | Query, Optional | filter for site level mist edges | +| `forSite` | `*bool` | Query, Optional | filter for site level mist edges
**Default**: `false` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-stats-other-devices.md b/doc/controllers/orgs-stats-other-devices.md index 511e149e..21d99ab8 100644 --- a/doc/controllers/orgs-stats-other-devices.md +++ b/doc/controllers/orgs-stats-other-devices.md @@ -27,7 +27,7 @@ GetOrgOtherDeviceStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/controllers/orgs-stats-ports.md b/doc/controllers/orgs-stats-ports.md index 5ed907b6..52fd621f 100644 --- a/doc/controllers/orgs-stats-ports.md +++ b/doc/controllers/orgs-stats-ports.md @@ -62,7 +62,7 @@ CountOrgSwitchPorts( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgSwitchPortCountDistinctEnum`](../../doc/models/org-switch-port-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgSwitchPortCountDistinctEnum`](../../doc/models/org-switch-port-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `fullDuplex` | `*bool` | Query, Optional | indicates full or half duplex | | `mac` | `*string` | Query, Optional | device identifier | | `neighborMac` | `*string` | Query, Optional | Chassis identifier of the chassis type listed | @@ -90,9 +90,9 @@ CountOrgSwitchPorts( | `up` | `*bool` | Query, Optional | indicates if interface is up | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -285,10 +285,10 @@ SearchOrgSwOrGwPorts( | `stpState` | [`*models.SearchOrgSwOrGwPortsStpStateEnum`](../../doc/models/search-org-sw-or-gw-ports-stp-state-enum.md) | Query, Optional | if `up`==`true` | | `stpRole` | [`*models.SearchOrgSwOrGwPortsStpRoleEnum`](../../doc/models/search-org-sw-or-gw-ports-stp-role-enum.md) | Query, Optional | if `up`==`true` | | `authState` | [`*models.SearchOrgSwOrGwPortsAuthStateEnum`](../../doc/models/search-org-sw-or-gw-ports-auth-state-enum.md) | Query, Optional | if `up`==`true` && has Authenticator role | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-stats-tunnels.md b/doc/controllers/orgs-stats-tunnels.md index a2580ddc..2023ba0f 100644 --- a/doc/controllers/orgs-stats-tunnels.md +++ b/doc/controllers/orgs-stats-tunnels.md @@ -33,8 +33,8 @@ CountOrgTunnelsStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgTunnelCountDistinctEnum`](../../doc/models/org-tunnel-count-distinct-enum.md) | Query, Optional | - If `type`==`wxtunnel`: wxtunnel_id / ap / remote_ip / remote_port / state / mxedge_id / mxcluster_id / site_id / peer_mxedge_id; default is wxtunnel_id
- If `type`==`wan`: mac / site_id / node / peer_ip / peer_host/ ip / tunnel_name / protocol / auth_algo / encrypt_algo / ike_version / last_event / up | -| `mType` | [`*models.OrgTunnelTypeCountEnum`](../../doc/models/org-tunnel-type-count-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgTunnelCountDistinctEnum`](../../doc/models/org-tunnel-count-distinct-enum.md) | Query, Optional | - If `type`==`wxtunnel`: wxtunnel_id / ap / remote_ip / remote_port / state / mxedge_id / mxcluster_id / site_id / peer_mxedge_id; default is wxtunnel_id
- If `type`==`wan`: mac / site_id / node / peer_ip / peer_host/ ip / tunnel_name / protocol / auth_algo / encrypt_algo / ike_version / last_event / up
**Default**: `"wxtunnel_id"` | +| `mType` | [`*models.OrgTunnelTypeCountEnum`](../../doc/models/org-tunnel-type-count-enum.md) | Query, Optional | **Default**: `"wxtunnel"` | ## Response Type @@ -142,11 +142,11 @@ SearchOrgTunnelsStats( | `encryptAlgo` | `*string` | Query, Optional | if `type`==`wan` | | `ikeVersion` | `*string` | Query, Optional | if `type`==`wan` | | `up` | `*string` | Query, Optional | if `type`==`wan` | -| `mType` | [`*models.TunnelTypeEnum`](../../doc/models/tunnel-type-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `mType` | [`*models.TunnelTypeEnum`](../../doc/models/tunnel-type-enum.md) | Query, Optional | **Default**: `"wxtunnel"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-stats-vpn-peers.md b/doc/controllers/orgs-stats-vpn-peers.md index 0aebc3ab..fe0b0170 100644 --- a/doc/controllers/orgs-stats-vpn-peers.md +++ b/doc/controllers/orgs-stats-vpn-peers.md @@ -40,9 +40,9 @@ CountOrgPeerPathStats( | `distinct` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -129,8 +129,8 @@ SearchOrgPeerPathStats( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/orgs-stats.md b/doc/controllers/orgs-stats.md index b2ee7891..c96d0827 100644 --- a/doc/controllers/orgs-stats.md +++ b/doc/controllers/orgs-stats.md @@ -33,9 +33,9 @@ GetOrgStats( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-tickets.md b/doc/controllers/orgs-tickets.md index d0edd46d..50e425ae 100644 --- a/doc/controllers/orgs-tickets.md +++ b/doc/controllers/orgs-tickets.md @@ -128,7 +128,7 @@ CountOrgTickets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.OrgTicketsCountDistinctEnum`](../../doc/models/org-tickets-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.OrgTicketsCountDistinctEnum`](../../doc/models/org-tickets-count-distinct-enum.md) | Query, Optional | **Default**: `"status"` | ## Response Type @@ -291,7 +291,7 @@ GetOrgTicket( | `ticketId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -387,7 +387,7 @@ GetOrgTicketAttachment( | `attachmentId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -461,7 +461,7 @@ ListOrgTickets( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/orgs-user-ma-cs.md b/doc/controllers/orgs-user-ma-cs.md index 795117eb..af91c5b7 100644 --- a/doc/controllers/orgs-user-ma-cs.md +++ b/doc/controllers/orgs-user-ma-cs.md @@ -316,8 +316,8 @@ SearchOrgUserMacs( | `orgId` | `uuid.UUID` | Template, Required | - | | `mac` | `*string` | Query, Optional | mac address | | `labels` | `[]string` | Query, Optional | optional, array of strings of labels | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-vars.md b/doc/controllers/orgs-vars.md index 5ad442a8..eb19d32f 100644 --- a/doc/controllers/orgs-vars.md +++ b/doc/controllers/orgs-vars.md @@ -36,8 +36,8 @@ SearchOrgVars( | `siteId` | `*string` | Query, Optional | - | | `vars` | `*string` | Query, Optional | - | | `src` | [`*models.VarSourceEnum`](../../doc/models/var-source-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-vp-ns.md b/doc/controllers/orgs-vp-ns.md index d91322d2..74f3ffca 100644 --- a/doc/controllers/orgs-vp-ns.md +++ b/doc/controllers/orgs-vp-ns.md @@ -252,8 +252,8 @@ ListOrgsVpns( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-webhooks.md b/doc/controllers/orgs-webhooks.md index 0d74f906..3ef927c2 100644 --- a/doc/controllers/orgs-webhooks.md +++ b/doc/controllers/orgs-webhooks.md @@ -63,8 +63,8 @@ CountOrgWebhooksDeliveries( | `distinct` | [`*models.WebhookDeliveryDistinctEnum`](../../doc/models/webhook-delivery-distinct-enum.md) | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -373,8 +373,8 @@ ListOrgWebhooks( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -530,8 +530,8 @@ SearchOrgWebhooksDeliveries( | `topic` | [`*models.WebhookDeliveryTopicEnum`](../../doc/models/webhook-delivery-topic-enum.md) | Query, Optional | webhook topic | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/orgs-wlan-templates.md b/doc/controllers/orgs-wlan-templates.md index 4c5f7206..a4b0a6a3 100644 --- a/doc/controllers/orgs-wlan-templates.md +++ b/doc/controllers/orgs-wlan-templates.md @@ -359,8 +359,8 @@ ListOrgTemplates( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-wlans.md b/doc/controllers/orgs-wlans.md index 42cdd572..c6b6a674 100644 --- a/doc/controllers/orgs-wlans.md +++ b/doc/controllers/orgs-wlans.md @@ -15,6 +15,7 @@ orgsWlans := client.OrgsWlans() * [Delete Org Wlan Portal Image](../../doc/controllers/orgs-wlans.md#delete-org-wlan-portal-image) * [Get Org WLAN](../../doc/controllers/orgs-wlans.md#get-org-wlan) * [List Org Wlans](../../doc/controllers/orgs-wlans.md#list-org-wlans) +* [Site Org Wlan Portal Image](../../doc/controllers/orgs-wlans.md#site-org-wlan-portal-image) * [Update Org Wlan](../../doc/controllers/orgs-wlans.md#update-org-wlan) * [Update Org Wlan Portal Template](../../doc/controllers/orgs-wlans.md#update-org-wlan-portal-template) * [Upload Org Wlan Portal Image](../../doc/controllers/orgs-wlans.md#upload-org-wlan-portal-image) @@ -436,8 +437,8 @@ ListOrgWlans( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -475,6 +476,58 @@ if err != nil { | 429 | Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold | [`ResponseHttp429ErrorException`](../../doc/models/response-http-429-error-exception.md) | +# Site Org Wlan Portal Image + +Delete Site WLAN Portal Image + +```go +SiteOrgWlanPortalImage( + ctx context.Context, + siteId uuid.UUID, + wlanId uuid.UUID) ( + http.Response, + error) +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `siteId` | `uuid.UUID` | Template, Required | - | +| `wlanId` | `uuid.UUID` | Template, Required | - | + +## Response Type + +`` + +## Example Usage + +```go +ctx := context.Background() + +siteId := uuid.MustParse("000000ab-00ab-00ab-00ab-0000000000ab") + +wlanId := uuid.MustParse("000000ab-00ab-00ab-00ab-0000000000ab") + +resp, err := orgsWlans.SiteOrgWlanPortalImage(ctx, siteId, wlanId) +if err != nil { + log.Fatalln(err) +} else { + fmt.Println(resp.StatusCode) +} +``` + +## Errors + +| HTTP Status Code | Error Description | Exception Class | +| --- | --- | --- | +| 400 | Bad Syntax | [`ResponseHttp400Exception`](../../doc/models/response-http-400-exception.md) | +| 401 | Unauthorized | [`ResponseHttp401ErrorException`](../../doc/models/response-http-401-error-exception.md) | +| 403 | Permission Denied | [`ResponseHttp403ErrorException`](../../doc/models/response-http-403-error-exception.md) | +| 404 | Not found. The API endpoint doesn’t exist or resource doesn’ t exist | [`ResponseHttp404Exception`](../../doc/models/response-http-404-exception.md) | +| 429 | Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold | [`ResponseHttp429ErrorException`](../../doc/models/response-http-429-error-exception.md) | + + # Update Org Wlan Update Org Wlan @@ -853,7 +906,7 @@ UploadOrgWlanPortalImage( | `orgId` | `uuid.UUID` | Template, Required | - | | `wlanId` | `uuid.UUID` | Template, Required | - | | `file` | `models.FileWrapper` | Form, Required | binary file | -| `json` | `*string` | Form, Optional | JSON string describing your upload | +| `json` | `*string` | Form, Optional | - | ## Response Type diff --git a/doc/controllers/orgs-wx-rules.md b/doc/controllers/orgs-wx-rules.md index 1a3bd385..52fa3e7e 100644 --- a/doc/controllers/orgs-wx-rules.md +++ b/doc/controllers/orgs-wx-rules.md @@ -377,8 +377,8 @@ ListOrgWxRules( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-wx-tags.md b/doc/controllers/orgs-wx-tags.md index 9224d6e5..562b9133 100644 --- a/doc/controllers/orgs-wx-tags.md +++ b/doc/controllers/orgs-wx-tags.md @@ -396,8 +396,8 @@ ListOrgWxTags( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs-wx-tunnels.md b/doc/controllers/orgs-wx-tunnels.md index f2a1a217..22f3f3b6 100644 --- a/doc/controllers/orgs-wx-tunnels.md +++ b/doc/controllers/orgs-wx-tunnels.md @@ -306,8 +306,8 @@ ListOrgWxTunnels( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/orgs.md b/doc/controllers/orgs.md index b3055b3f..4d671efc 100644 --- a/doc/controllers/orgs.md +++ b/doc/controllers/orgs.md @@ -314,8 +314,8 @@ SearchOrgEvents( | `mType` | `*string` | Query, Optional | event type | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/self-audit-logs.md b/doc/controllers/self-audit-logs.md index 3a308fcd..61dcd180 100644 --- a/doc/controllers/self-audit-logs.md +++ b/doc/controllers/self-audit-logs.md @@ -32,9 +32,9 @@ ListSelfAuditLogs( | --- | --- | --- | --- | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/self-mfa.md b/doc/controllers/self-mfa.md index ac88e758..f39acab7 100644 --- a/doc/controllers/self-mfa.md +++ b/doc/controllers/self-mfa.md @@ -30,7 +30,7 @@ GenerateSecretFor2faVerification( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | -| `by` | [`*models.MfaSecretTypeEnum`](../../doc/models/mfa-secret-type-enum.md) | Query, Optional | if `by`==`qrcode`, returns the secret as a qrcode image | +| `by` | [`*models.MfaSecretTypeEnum`](../../doc/models/mfa-secret-type-enum.md) | Query, Optional | if `by`==`qrcode`, returns the secret as a qrcode image
**Default**: `"qrcode"` | ## Response Type diff --git a/doc/controllers/sites-alarms.md b/doc/controllers/sites-alarms.md index 36d0a7e0..208ffa7c 100644 --- a/doc/controllers/sites-alarms.md +++ b/doc/controllers/sites-alarms.md @@ -222,7 +222,7 @@ CountSiteAlarms( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.AlarmCountDisctinctEnum`](../../doc/models/alarm-count-disctinct-enum.md) | Query, Optional | Group by and count the alarms by some distinct field | +| `distinct` | [`*models.AlarmCountDisctinctEnum`](../../doc/models/alarm-count-disctinct-enum.md) | Query, Optional | Group by and count the alarms by some distinct field
**Default**: `"type"` | | `ackAdminName` | `*string` | Query, Optional | Name of the admins who have acked the alarms; accepts multiple values separated by comma | | `acked` | `*bool` | Query, Optional | - | | `mType` | `*string` | Query, Optional | Key-name of the alarms; accepts multiple values separated by comma | @@ -230,9 +230,9 @@ CountSiteAlarms( | `group` | `*string` | Query, Optional | Alarm group name; accepts multiple values separated by comma | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -337,10 +337,10 @@ SearchSiteAlarms( | `acked` | `*bool` | Query, Optional | - | | `severity` | `*string` | Query, Optional | Alarm severity; accepts multiple values separated by comma | | `group` | `*string` | Query, Optional | Alarm group name; accepts multiple values separated by comma | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-anomaly.md b/doc/controllers/sites-anomaly.md index 94d59839..81aeaa8a 100644 --- a/doc/controllers/sites-anomaly.md +++ b/doc/controllers/sites-anomaly.md @@ -88,7 +88,7 @@ GetSiteAnomalyEventsForClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | ## Response Type @@ -147,7 +147,7 @@ GetSiteAnomalyEventsforDevice( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/controllers/sites-asset-filters.md b/doc/controllers/sites-asset-filters.md index 78c35295..c5de2c47 100644 --- a/doc/controllers/sites-asset-filters.md +++ b/doc/controllers/sites-asset-filters.md @@ -247,8 +247,8 @@ ListSiteAssetFilters( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-assets.md b/doc/controllers/sites-assets.md index 156718df..09e4b838 100644 --- a/doc/controllers/sites-assets.md +++ b/doc/controllers/sites-assets.md @@ -243,7 +243,7 @@ ImportSiteAssets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `upsert` | [`*models.ImportSiteAssetsUpsertEnum`](../../doc/models/import-site-assets-upsert-enum.md) | Query, Optional | API will replace the assets with same mac if provided `upsert`==`True`, otherwise will report in errors in response. | +| `upsert` | [`*models.ImportSiteAssetsUpsertEnum`](../../doc/models/import-site-assets-upsert-enum.md) | Query, Optional | API will replace the assets with same mac if provided `upsert`==`True`, otherwise will report in errors in response.
**Default**: `"False"` | | `file` | `*models.FileWrapper` | Form, Optional | CSV file | ## Response Type @@ -299,8 +299,8 @@ ListSiteAssets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-beacons.md b/doc/controllers/sites-beacons.md index 5d16cc6c..271ee25d 100644 --- a/doc/controllers/sites-beacons.md +++ b/doc/controllers/sites-beacons.md @@ -259,8 +259,8 @@ ListSiteBeacons( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-clients-nac.md b/doc/controllers/sites-clients-nac.md index 4c1dbda8..53cc259d 100644 --- a/doc/controllers/sites-clients-nac.md +++ b/doc/controllers/sites-clients-nac.md @@ -43,8 +43,8 @@ CountSiteNacClientEvents( | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listNacEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -146,7 +146,7 @@ CountSiteNacClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteNacClientsCountDistinctEnum`](../../doc/models/site-nac-clients-count-distinct-enum.md) | Query, Optional | NAC Policy Rule ID, if matched | +| `distinct` | [`*models.SiteNacClientsCountDistinctEnum`](../../doc/models/site-nac-clients-count-distinct-enum.md) | Query, Optional | NAC Policy Rule ID, if matched
**Default**: `"type"` | | `lastNacruleId` | `*string` | Query, Optional | NAC Policy Rule ID, if matched | | `nacruleMatched` | `*bool` | Query, Optional | NAC Policy Rule Matched | | `authType` | `*string` | Query, Optional | authentication type, e.g. "eap-tls", "peap-tls", "eap-ttls", "eap-teap", "mab", "psk", "device-auth" | @@ -164,9 +164,9 @@ CountSiteNacClients( | `mdmProvider` | `*string` | Query, Optional | MDM provider of client’s organisation eg “intune”, “jamf” | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -316,10 +316,10 @@ SearchSiteNacClientEvents( | `idpId` | `*uuid.UUID` | Query, Optional | SSO ID, if present and used | | `idpRole` | `*string` | Query, Optional | IDP returned roles/groups for the user | | `idpUsername` | `*string` | Query, Optional | Username presented to the Identity Provider | -| `respAttrs` | `[]string` | Query, Optional | Radius attributes returned by NAC to NAS Devive | +| `respAttrs` | `[]string` | Query, Optional | Radius attributes returned by NAC to NAS Devive
**Constraints**: *Unique Items Required* | | `ssid` | `*string` | Query, Optional | SSID | | `username` | `*string` | Query, Optional | Username presented by the client | -| `usermacLabels` | `[]string` | Query, Optional | labels derived from usermac entry | +| `usermacLabels` | `[]string` | Query, Optional | labels derived from usermac entry
**Constraints**: *Unique Items Required* | | `ap` | `*string` | Query, Optional | AP MAC | | `randomMac` | `*bool` | Query, Optional | AP random macMAC | | `mac` | `*string` | Query, Optional | MAC address | @@ -327,8 +327,8 @@ SearchSiteNacClientEvents( | `timestamp` | `*float64` | Query, Optional | time, in epoch | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -515,9 +515,9 @@ SearchSiteNacClients( | `mdmProvider` | `*string` | Query, Optional | MDM provider of client’s organisation eg “intune”, “jamf” | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-clients-wan.md b/doc/controllers/sites-clients-wan.md index c52791e7..f12a2809 100644 --- a/doc/controllers/sites-clients-wan.md +++ b/doc/controllers/sites-clients-wan.md @@ -39,12 +39,12 @@ CountSiteWanClientEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteWanClientEventsDistinctEnum`](../../doc/models/site-wan-client-events-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteWanClientEventsDistinctEnum`](../../doc/models/site-wan-client-events-distinct-enum.md) | Query, Optional | **Default**: `"type"` | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -131,12 +131,12 @@ CountSiteWanClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteWanClientsCountDistinctEnum`](../../doc/models/site-wan-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteWanClientsCountDistinctEnum`](../../doc/models/site-wan-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -235,8 +235,8 @@ SearchSiteWanClientEvents( | `nacruleId` | `*string` | Query, Optional | nacrule_id | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -343,9 +343,9 @@ SearchSiteWanClients( | `mfg` | `*string` | Query, Optional | Manufacture | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-clients-wired.md b/doc/controllers/sites-clients-wired.md index 47d151a0..3f38ba8a 100644 --- a/doc/controllers/sites-clients-wired.md +++ b/doc/controllers/sites-clients-wired.md @@ -41,16 +41,16 @@ CountSiteWiredClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteWiredClientsCountDistinctEnum`](../../doc/models/site-wired-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteWiredClientsCountDistinctEnum`](../../doc/models/site-wired-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `mac` | `*string` | Query, Optional | client mac | | `deviceMac` | `*string` | Query, Optional | device mac | | `portId` | `*string` | Query, Optional | port id | | `vlan` | `*string` | Query, Optional | vlan | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -159,10 +159,10 @@ SearchSiteWiredClients( | `manufacture` | `*string` | Query, Optional | manufacture | | `text` | `*string` | Query, Optional | single entry of hostname/mac | | `nacruleId` | `*string` | Query, Optional | nacrule_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-clients-wireless.md b/doc/controllers/sites-clients-wireless.md index 6ec4429c..65048b54 100644 --- a/doc/controllers/sites-clients-wireless.md +++ b/doc/controllers/sites-clients-wireless.md @@ -56,10 +56,10 @@ CountSiteWirelessClientEvents( | `proto` | [`*models.Dot11ProtoEnum`](../../doc/models/dot-11-proto-enum.md) | Query, Optional | a / b / g / n / ac / ax | | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `wlanId` | `*string` | Query, Optional | wlan_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -166,7 +166,7 @@ CountSiteWirelessClientSessions( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteClientSessionsCountDistinctEnum`](../../doc/models/site-client-sessions-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteClientSessionsCountDistinctEnum`](../../doc/models/site-client-sessions-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `ap` | `*string` | Query, Optional | AP MAC | | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `clientFamily` | `*string` | Query, Optional | E.g. “Mac”, “iPhone”, “Apple watch” | @@ -177,9 +177,9 @@ CountSiteWirelessClientSessions( | `wlanId` | `*string` | Query, Optional | wlan_id | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -290,7 +290,7 @@ CountSiteWirelessClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteClientsCountDistinctEnum`](../../doc/models/site-clients-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteClientsCountDistinctEnum`](../../doc/models/site-clients-count-distinct-enum.md) | Query, Optional | **Default**: `"device"` | | `ssid` | `*string` | Query, Optional | - | | `ap` | `*string` | Query, Optional | - | | `ipAddress` | `*string` | Query, Optional | - | @@ -301,9 +301,9 @@ CountSiteWirelessClients( | `device` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -412,7 +412,7 @@ GetSiteEventsForClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `mType` | `*string` | Query, Optional | e.g. MARVIS_EVENT_CLIENT_DHCP_STUCK | | `proto` | [`*models.Dot11ProtoEnum`](../../doc/models/dot-11-proto-enum.md) | Query, Optional | a / b / g / n / ac / ax | | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | @@ -421,9 +421,9 @@ GetSiteEventsForClient( | `ssid` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -544,10 +544,10 @@ SearchSiteWirelessClientEvents( | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `wlanId` | `*string` | Query, Optional | wlan_id | | `nacruleId` | `*string` | Query, Optional | nacrule_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -674,10 +674,10 @@ SearchSiteWirelessClientSessions( | `wlanId` | `*string` | Query, Optional | wlan_id | | `pskId` | `*string` | Query, Optional | PSK ID | | `pskName` | `*string` | Query, Optional | PSK Name | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -814,10 +814,10 @@ SearchSiteWirelessClients( | `ssid` | `*string` | Query, Optional | - | | `text` | `*string` | Query, Optional | partial / full MAC address, hostname, username, psk_name or ip | | `nacruleId` | `*string` | Query, Optional | nacrule_id | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-device-profiles.md b/doc/controllers/sites-device-profiles.md index 40c03578..bd39044d 100644 --- a/doc/controllers/sites-device-profiles.md +++ b/doc/controllers/sites-device-profiles.md @@ -27,7 +27,7 @@ ListSiteDeviceProfilesDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether resolve the site variables | +| `resolve` | `*bool` | Query, Optional | whether resolve the site variables
**Default**: `false` | ## Response Type diff --git a/doc/controllers/sites-devices-others.md b/doc/controllers/sites-devices-others.md index 2ab09af1..50b64ace 100644 --- a/doc/controllers/sites-devices-others.md +++ b/doc/controllers/sites-devices-others.md @@ -38,12 +38,12 @@ CountSiteOtherDeviceEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteOtherDeviceEventsCountDistinctEnum`](../../doc/models/site-other-device-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteOtherDeviceEventsCountDistinctEnum`](../../doc/models/site-other-device-events-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listOtherDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -136,8 +136,8 @@ ListSiteOtherDevices( | `serial` | `*string` | Query, Optional | - | | `model` | `*string` | Query, Optional | - | | `name` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -236,8 +236,8 @@ SearchSiteOtherDeviceEvents( | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listOtherDeviceEventsDefinitions) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/sites-devices.md b/doc/controllers/sites-devices.md index af4cfa58..243f5fb7 100644 --- a/doc/controllers/sites-devices.md +++ b/doc/controllers/sites-devices.md @@ -52,7 +52,7 @@ AddSiteDeviceImage( | `deviceId` | `uuid.UUID` | Template, Required | - | | `imageNumber` | `int` | Template, Required | - | | `file` | `models.FileWrapper` | Form, Required | binary file | -| `json` | `*string` | Form, Optional | JSON string describing your upload | +| `json` | `*string` | Form, Optional | - | ## Response Type @@ -120,9 +120,9 @@ CountSiteDeviceConfigHistory( | `mac` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -213,14 +213,14 @@ CountSiteDeviceEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteDeviceEventsCountDistinctEnum`](../../doc/models/site-device-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteDeviceEventsCountDistinctEnum`](../../doc/models/site-device-events-count-distinct-enum.md) | Query, Optional | **Default**: `"model"` | | `model` | `*string` | Query, Optional | - | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `typeCode` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -311,12 +311,12 @@ CountSiteDeviceLastConfig( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteDeviceLastConfigCountDistinctEnum`](../../doc/models/site-device-last-config-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteDeviceLastConfigCountDistinctEnum`](../../doc/models/site-device-last-config-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -414,7 +414,7 @@ CountSiteDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteDevicesCountDistinctEnum`](../../doc/models/site-devices-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteDevicesCountDistinctEnum`](../../doc/models/site-devices-count-distinct-enum.md) | Query, Optional | **Default**: `"model"` | | `hostname` | `*string` | Query, Optional | - | | `model` | `*string` | Query, Optional | - | | `mac` | `*string` | Query, Optional | - | @@ -428,9 +428,9 @@ CountSiteDevices( | `mapId` | `*string` | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -1131,10 +1131,10 @@ ListSiteDevices( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | **Default**: `"ap"` | | `name` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -1266,12 +1266,12 @@ SearchSiteDeviceConfigHistory( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `mac` | `*string` | Query, Optional | Device MAC Address | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -1419,10 +1419,10 @@ SearchSiteDeviceEvents( | `timestamp` | `*string` | Query, Optional | event time | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `lastBy` | `*string` | Query, Optional | Return last/recent event for passed in field | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -1526,14 +1526,14 @@ SearchSiteDeviceLastConfigs( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `mac` | `*string` | Query, Optional | - | | `version` | `*string` | Query, Optional | - | | `name` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -1697,7 +1697,7 @@ SearchSiteDevices( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `hostname` | `*string` | Query, Optional | partial / full hostname | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `model` | `*string` | Query, Optional | device model | | `mac` | `*string` | Query, Optional | device MAC | | `version` | `*string` | Query, Optional | version | @@ -1716,13 +1716,13 @@ SearchSiteDevices( | `band5Bandwith` | `*int` | Query, Optional | Bandwidth of band_5 | | `band6Bandwith` | `*int` | Query, Optional | Bandwidth of band_6 | | `eth0PortSpeed` | `*int` | Query, Optional | Port speed of eth0 | -| `sort` | [`*models.SearchSiteDevicesSortEnum`](../../doc/models/search-site-devices-sort-enum.md) | Query, Optional | sort options | +| `sort` | [`*models.SearchSiteDevicesSortEnum`](../../doc/models/search-site-devices-sort-enum.md) | Query, Optional | sort options
**Default**: `"timestamp"` | | `descSort` | [`*models.SearchSiteDevicesDescSortEnum`](../../doc/models/search-site-devices-desc-sort-enum.md) | Query, Optional | sort options in reverse order | -| `stats` | `*bool` | Query, Optional | whether to return device stats | -| `limit` | `*int` | Query, Optional | - | +| `stats` | `*bool` | Query, Optional | whether to return device stats
**Default**: `false` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-events.md b/doc/controllers/sites-events.md index a8352832..6fdede0c 100644 --- a/doc/controllers/sites-events.md +++ b/doc/controllers/sites-events.md @@ -38,12 +38,12 @@ CountSiteSystemEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteSystemEventsCountDistinctEnum`](../../doc/models/site-system-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteSystemEventsCountDistinctEnum`](../../doc/models/site-system-events-count-distinct-enum.md) | Query, Optional | **Default**: `"type"` | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -130,10 +130,10 @@ GetSiteRoamingEvents( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `mType` | [`*models.FastRoamResultEnum`](../../doc/models/fast-roam-result-enum.md) | Query, Optional | event type | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -222,10 +222,10 @@ SearchSiteSystemEvents( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-guests.md b/doc/controllers/sites-guests.md index 3df34369..e0de1507 100644 --- a/doc/controllers/sites-guests.md +++ b/doc/controllers/sites-guests.md @@ -42,12 +42,12 @@ CountSiteGuestAuthorizations( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteGuestsCountDistinctEnum`](../../doc/models/site-guests-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteGuestsCountDistinctEnum`](../../doc/models/site-guests-count-distinct-enum.md) | Query, Optional | **Default**: `"auth_method"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -129,7 +129,7 @@ DeleteSiteGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -181,7 +181,7 @@ GetSiteGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -331,7 +331,7 @@ ListSiteAllGuestAuthorizationsDerived( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `wlanId` | `*string` | Query, Optional | UUID of single or multiple (Comma separated) WLAN under Site `site_id` (to filter by WLAN) | -| `crossSite` | `*bool` | Query, Optional | whether to get org level guests, default is false i.e get site level guests | +| `crossSite` | `*bool` | Query, Optional | whether to get org level guests, default is false i.e get site level guests
**Default**: `false` | ## Response Type @@ -417,10 +417,10 @@ SearchSiteGuestAuthorization( | `wlanId` | `*string` | Query, Optional | - | | `authMethod` | `*string` | Query, Optional | - | | `ssid` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -523,7 +523,7 @@ UpdateSiteGuestAuthorization( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `guestMac` | `string` | Template, Required | - | +| `guestMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `body` | [`*models.Guest`](../../doc/models/guest.md) | Body, Optional | Request Body | ## Response Type diff --git a/doc/controllers/sites-insights.md b/doc/controllers/sites-insights.md index 27cb7b94..b6572450 100644 --- a/doc/controllers/sites-insights.md +++ b/doc/controllers/sites-insights.md @@ -43,10 +43,10 @@ GetSiteInsightMetrics( | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -133,14 +133,14 @@ GetSiteInsightMetricsForClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -230,13 +230,13 @@ GetSiteInsightMetricsForDevice( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `metric` | `string` | Template, Required | see /api/v1/const/insight_metrics for available metrics | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-location.md b/doc/controllers/sites-location.md index bc25ae86..31ee9b93 100644 --- a/doc/controllers/sites-location.md +++ b/doc/controllers/sites-location.md @@ -151,8 +151,8 @@ GetSiteBeamCoverageOverview( | `mapId` | `*string` | Query, Optional | map_id (filter by map_id) | | `mType` | [`*models.RfClientTypeEnum`](../../doc/models/rf-client-type-enum.md) | Query, Optional | - | | `clientType` | `*string` | Query, Optional | client_type (as filter. optional) | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `resolution` | [`*models.ResolutionEnum`](../../doc/models/resolution-enum.md) | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `resolution` | [`*models.ResolutionEnum`](../../doc/models/resolution-enum.md) | Query, Optional | **Default**: `"default"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | diff --git a/doc/controllers/sites-maps.md b/doc/controllers/sites-maps.md index 7a9c3891..5ff1ad32 100644 --- a/doc/controllers/sites-maps.md +++ b/doc/controllers/sites-maps.md @@ -45,7 +45,7 @@ AddSiteMapImage( | `siteId` | `uuid.UUID` | Template, Required | - | | `mapId` | `uuid.UUID` | Template, Required | - | | `file` | `models.FileWrapper` | Form, Required | binary file | -| `json` | `*string` | Form, Optional | JSON string describing your upload | +| `json` | `*string` | Form, Optional | - | ## Response Type @@ -653,8 +653,8 @@ ListSiteMaps( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-mx-edges.md b/doc/controllers/sites-mx-edges.md index 584a6b25..6a70dcb7 100644 --- a/doc/controllers/sites-mx-edges.md +++ b/doc/controllers/sites-mx-edges.md @@ -46,15 +46,15 @@ CountSiteMxEdgeEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteMxedgeEventsCountDistinctEnum`](../../doc/models/site-mxedge-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteMxedgeEventsCountDistinctEnum`](../../doc/models/site-mxedge-events-count-distinct-enum.md) | Query, Optional | **Default**: `"mxedge_id"` | | `mxedgeId` | `*string` | Query, Optional | mist edge id | | `mxclusterId` | `*string` | Query, Optional | mist edge cluster id | | `mType` | `*string` | Query, Optional | see [listDeviceEventsDefinitions]($e/Constants%20Events/listDeviceEventsDefinitions) | | `service` | `*string` | Query, Optional | service running on mist edge(mxagent, tunterm etc) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -366,8 +366,8 @@ ListSiteMxEdges( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -537,8 +537,8 @@ SearchSiteMistEdgeEvents( | `service` | `*string` | Query, Optional | service running on mist edge(mxagent, tunterm etc) | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/sites-networks.md b/doc/controllers/sites-networks.md index 4a1c0a49..319d54e1 100644 --- a/doc/controllers/sites-networks.md +++ b/doc/controllers/sites-networks.md @@ -27,7 +27,7 @@ ListSiteNetworksDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether resolve the site variables | +| `resolve` | `*bool` | Query, Optional | whether resolve the site variables
**Default**: `false` | ## Response Type diff --git a/doc/controllers/sites-psks.md b/doc/controllers/sites-psks.md index ee4afcf9..7783ae65 100644 --- a/doc/controllers/sites-psks.md +++ b/doc/controllers/sites-psks.md @@ -296,8 +296,8 @@ ListSitePsks( | `ssid` | `*string` | Query, Optional | - | | `role` | `*string` | Query, Optional | - | | `name` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -379,7 +379,7 @@ UpdateSiteMultiplePsks( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `body` | [`[]models.Psk`](../../doc/models/psk.md) | Body, Optional | - | +| `body` | [`[]models.Psk`](../../doc/models/psk.md) | Body, Optional | **Constraints**: *Unique Items Required* | ## Response Type diff --git a/doc/controllers/sites-rfdiags.md b/doc/controllers/sites-rfdiags.md index ce145037..7c1ee7e5 100644 --- a/doc/controllers/sites-rfdiags.md +++ b/doc/controllers/sites-rfdiags.md @@ -232,9 +232,9 @@ GetSiteSiteRfdiagRecording( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-rogues.md b/doc/controllers/sites-rogues.md index 153e487a..eb805916 100644 --- a/doc/controllers/sites-rogues.md +++ b/doc/controllers/sites-rogues.md @@ -45,17 +45,17 @@ CountSiteRogueEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteRogueEventsCountDistinctEnum`](../../doc/models/site-rogue-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteRogueEventsCountDistinctEnum`](../../doc/models/site-rogue-events-count-distinct-enum.md) | Query, Optional | **Default**: `"bssid"` | | `mType` | [`*models.RogueTypeEnum`](../../doc/models/rogue-type-enum.md) | Query, Optional | - | | `ssid` | `*string` | Query, Optional | ssid of the network detected as threat | | `bssid` | `*string` | Query, Optional | bssid of the network detected as threat | | `apMac` | `*string` | Query, Optional | mac of the device that had strongest signal strength for ssid/bssid pair | | `channel` | `*string` | Query, Optional | channel over which ap_mac heard ssid/bssid pair | | `seenOnLan` | `*bool` | Query, Optional | whether the reporting AP see a wireless client (on LAN) connecting to it | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -147,7 +147,7 @@ GetSiteRogueAP( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `rogueBssid` | `string` | Template, Required | - | +| `rogueBssid` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -216,10 +216,10 @@ ListSiteRogueAPs( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `mType` | [`*models.RogueTypeEnum`](../../doc/models/rogue-type-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | ## Response Type @@ -310,10 +310,10 @@ ListSiteRogueClients( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `interval` | `*string` | Query, Optional | Aggregation works by giving a time range plus interval (e.g. 1d, 1h, 10m) where aggregation function would be applied to. | ## Response Type @@ -413,10 +413,10 @@ SearchSiteRogueEvents( | `apMac` | `*string` | Query, Optional | mac of the device that had strongest signal strength for ssid/bssid pair | | `channel` | `*int` | Query, Optional | channel over which ap_mac heard ssid/bssid pair | | `seenOnLan` | `*bool` | Query, Optional | whether the reporting AP see a wireless client (on LAN) connecting to it | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-rrm.md b/doc/controllers/sites-rrm.md index 634b6136..414380a7 100644 --- a/doc/controllers/sites-rrm.md +++ b/doc/controllers/sites-rrm.md @@ -258,8 +258,8 @@ GetSiteCurrentRrmNeighbors( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `band` | [`models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Template, Required | 802.11 Band | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -347,9 +347,9 @@ GetSiteRrmEvents( | `band` | [`*models.Dot11BandEnum`](../../doc/models/dot-11-band-enum.md) | Query, Optional | 802.11 Band | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-rssi-zones.md b/doc/controllers/sites-rssi-zones.md index 290256bd..33c6d8f0 100644 --- a/doc/controllers/sites-rssi-zones.md +++ b/doc/controllers/sites-rssi-zones.md @@ -240,8 +240,8 @@ ListSiteRssiZones( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-service-policies.md b/doc/controllers/sites-service-policies.md index 3752d347..3e888aac 100644 --- a/doc/controllers/sites-service-policies.md +++ b/doc/controllers/sites-service-policies.md @@ -27,7 +27,7 @@ ListSiteServicePoliciesDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether resolve the site variables | +| `resolve` | `*bool` | Query, Optional | whether resolve the site variables
**Default**: `false` | ## Response Type diff --git a/doc/controllers/sites-services.md b/doc/controllers/sites-services.md index 3333fc4f..55b5c7bd 100644 --- a/doc/controllers/sites-services.md +++ b/doc/controllers/sites-services.md @@ -47,7 +47,7 @@ CountSiteServicePathEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteServiceEventsCountDistinctEnum`](../../doc/models/site-service-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteServiceEventsCountDistinctEnum`](../../doc/models/site-service-events-count-distinct-enum.md) | Query, Optional | **Default**: `"type"` | | `mType` | `*string` | Query, Optional | Event type, e.g. GW_SERVICE_PATH_DOWN | | `text` | `*string` | Query, Optional | Description of the event including the reason it is triggered | | `vpnName` | `*string` | Query, Optional | Peer name | @@ -60,8 +60,8 @@ CountSiteServicePathEvents( | `mac` | `*string` | Query, Optional | MAC address | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -161,7 +161,7 @@ ListSiteServicesDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether resolve the site variables | +| `resolve` | `*bool` | Query, Optional | whether resolve the site variables
**Default**: `false` | ## Response Type @@ -276,8 +276,8 @@ SearchSiteServicePathEvents( | `mac` | `*string` | Query, Optional | MAC address | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/sites-skyatp.md b/doc/controllers/sites-skyatp.md index 53ebf567..69d65dd0 100644 --- a/doc/controllers/sites-skyatp.md +++ b/doc/controllers/sites-skyatp.md @@ -41,16 +41,16 @@ CountSiteSkyatpEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteSkyAtpEventsCountDistinctEnum`](../../doc/models/site-sky-atp-events-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteSkyAtpEventsCountDistinctEnum`](../../doc/models/site-sky-atp-events-count-distinct-enum.md) | Query, Optional | **Default**: `"type"` | | `mType` | `*string` | Query, Optional | event type, e.g. cc, fs, mw | | `mac` | `*string` | Query, Optional | client MAC | | `deviceMac` | `*string` | Query, Optional | device MAC | | `threatLevel` | `*int` | Query, Optional | threat level | | `ipAddress` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -153,10 +153,10 @@ SearchSiteSkyatpEvents( | `deviceMac` | `*string` | Query, Optional | device MAC | | `threatLevel` | `*int` | Query, Optional | threat level | | `ipAddress` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-sl-es.md b/doc/controllers/sites-sl-es.md index 493f97a8..9ce3832f 100644 --- a/doc/controllers/sites-sl-es.md +++ b/doc/controllers/sites-sl-es.md @@ -59,7 +59,7 @@ GetSiteSleClassifierDetails( | `classifier` | `string` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -244,7 +244,7 @@ GetSiteSleHistogram( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -422,7 +422,7 @@ GetSiteSleImpactSummary( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `fields` | [`*models.SiteSleImpactSummaryFieldsParameterEnum`](../../doc/models/site-sle-impact-summary-fields-parameter-enum.md) | Query, Optional | - | | `classifier` | `*string` | Query, Optional | - | @@ -644,7 +644,7 @@ GetSiteSleImpactedApplications( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -747,7 +747,7 @@ GetSiteSleImpactedAps( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -856,7 +856,7 @@ GetSiteSleImpactedChassis( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -960,7 +960,7 @@ GetSiteSleImpactedGateways( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -1064,7 +1064,7 @@ GetSiteSleImpactedInterfaces( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -1175,7 +1175,7 @@ GetSiteSleImpactedSwitches( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -1283,7 +1283,7 @@ GetSiteSleImpactedWiredClients( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -1394,7 +1394,7 @@ GetSiteSleImpactedWirelessClients( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `classifier` | `*string` | Query, Optional | - | ## Response Type @@ -1612,7 +1612,7 @@ GetSiteSleSummary( | `metric` | `string` | Template, Required | values from /api/v1/sites/{site_id}/sle/{scope}/{scope_id}/metrics | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-stats-assets.md b/doc/controllers/sites-stats-assets.md index 5c74b346..1d42b442 100644 --- a/doc/controllers/sites-stats-assets.md +++ b/doc/controllers/sites-stats-assets.md @@ -37,7 +37,7 @@ CountSiteAssets( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteAssetsCountDistinctEnum`](../../doc/models/site-assets-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteAssetsCountDistinctEnum`](../../doc/models/site-assets-count-distinct-enum.md) | Query, Optional | **Default**: `"map_id"` | ## Response Type @@ -113,7 +113,7 @@ GetSiteAssetStats( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -207,11 +207,11 @@ GetSiteAssetsOfInterest( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -357,9 +357,9 @@ ListSiteAssetsStats( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -461,9 +461,9 @@ ListSiteDiscoveredAssets( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -556,10 +556,10 @@ SearchSiteAssets( | `apMac` | `*string` | Query, Optional | - | | `beam` | `*string` | Query, Optional | - | | `rssi` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-stats-beacons.md b/doc/controllers/sites-stats-beacons.md index 5522f706..50f5c561 100644 --- a/doc/controllers/sites-stats-beacons.md +++ b/doc/controllers/sites-stats-beacons.md @@ -33,9 +33,9 @@ ListSiteBeaconsStats( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-stats-calls.md b/doc/controllers/sites-stats-calls.md index c1260d7f..db5c31e4 100644 --- a/doc/controllers/sites-stats-calls.md +++ b/doc/controllers/sites-stats-calls.md @@ -38,8 +38,8 @@ CountSiteCalls( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distrinct` | [`*models.CountSiteCallsDistrinctEnum`](../../doc/models/count-site-calls-distrinct-enum.md) | Query, Optional | - | -| `rating` | `*int` | Query, Optional | feedback rating (e.g. "rating=1" or "rating=1,2") | +| `distrinct` | [`*models.CountSiteCallsDistrinctEnum`](../../doc/models/count-site-calls-distrinct-enum.md) | Query, Optional | **Default**: `"mac"` | +| `rating` | `*int` | Query, Optional | feedback rating (e.g. "rating=1" or "rating=1,2")
**Constraints**: `>= 1`, `<= 5` | | `app` | `*string` | Query, Optional | - | | `start` | `*string` | Query, Optional | - | | `end` | `*string` | Query, Optional | - | @@ -136,9 +136,9 @@ ListSiteTroubleshootCalls( | `app` | `*string` | Query, Optional | Third party app name | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -313,10 +313,10 @@ SearchSiteCalls( | `siteId` | `uuid.UUID` | Template, Required | - | | `mac` | `*string` | Query, Optional | device identifier | | `app` | `*string` | Query, Optional | Third party app name | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -388,15 +388,15 @@ TroubleshootSiteCall( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `meetingId` | `string` | Query, Required | meeting_id | | `mac` | `*string` | Query, Optional | device identifier | | `app` | `*string` | Query, Optional | Third party app name | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-stats-clients-wireless.md b/doc/controllers/sites-stats-clients-wireless.md index f0ebd23b..44376951 100644 --- a/doc/controllers/sites-stats-clients-wireless.md +++ b/doc/controllers/sites-stats-clients-wireless.md @@ -35,8 +35,8 @@ GetSiteWirelessClientStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | -| `wired` | `*bool` | Query, Optional | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | +| `wired` | `*bool` | Query, Optional | **Default**: `false` | ## Response Type @@ -108,9 +108,9 @@ GetSiteWirelessClientsStatsByMap( | `mapId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -248,11 +248,11 @@ ListSiteWirelessClientsStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `wired` | `*bool` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `wired` | `*bool` | Query, Optional | **Default**: `false` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-stats-devices.md b/doc/controllers/sites-stats-devices.md index f2025188..2a721ad5 100644 --- a/doc/controllers/sites-stats-devices.md +++ b/doc/controllers/sites-stats-devices.md @@ -326,10 +326,10 @@ ListSiteDevicesStats( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | - | -| `status` | [`*models.StatDeviceStatusFilterEnum`](../../doc/models/stat-device-status-filter-enum.md) | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `mType` | [`*models.DeviceTypeWithAllEnum`](../../doc/models/device-type-with-all-enum.md) | Query, Optional | **Default**: `"ap"` | +| `status` | [`*models.StatDeviceStatusFilterEnum`](../../doc/models/stat-device-status-filter-enum.md) | Query, Optional | **Default**: `"all"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-stats-discovered-switches.md b/doc/controllers/sites-stats-discovered-switches.md index 9ca6ddbf..4ddfa11c 100644 --- a/doc/controllers/sites-stats-discovered-switches.md +++ b/doc/controllers/sites-stats-discovered-switches.md @@ -39,12 +39,12 @@ CountSiteDiscoveredSwitches( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteDiscoveredSwitchesCountDistinctEnum`](../../doc/models/site-discovered-switches-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteDiscoveredSwitchesCountDistinctEnum`](../../doc/models/site-discovered-switches-count-distinct-enum.md) | Query, Optional | **Default**: `"system_name"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -248,10 +248,10 @@ SearchSiteDiscoveredSwitches( | `vendor` | `*string` | Query, Optional | - | | `model` | `*string` | Query, Optional | - | | `version` | `*string` | Query, Optional | - | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -361,12 +361,12 @@ SearchSiteDiscoveredSwitchesMetrics( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `scope` | [`*models.DiscoveredSwitchesMetricScopeEnum`](../../doc/models/discovered-switches-metric-scope-enum.md) | Query, Optional | metric scope | +| `scope` | [`*models.DiscoveredSwitchesMetricScopeEnum`](../../doc/models/discovered-switches-metric-scope-enum.md) | Query, Optional | metric scope
**Default**: `"site"` | | `mType` | [`*models.DiscoveredSwitchMetricTypeEnum`](../../doc/models/discovered-switch-metric-type-enum.md) | Query, Optional | metric type | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-stats-mx-edges.md b/doc/controllers/sites-stats-mx-edges.md index 851a6465..7cc9884b 100644 --- a/doc/controllers/sites-stats-mx-edges.md +++ b/doc/controllers/sites-stats-mx-edges.md @@ -38,7 +38,7 @@ GetSiteMxEdgeStats( | `mxedgeId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -275,9 +275,9 @@ ListSiteMxEdgesStats( | `siteId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-stats-ports.md b/doc/controllers/sites-stats-ports.md index bc5a7f90..ef172f4f 100644 --- a/doc/controllers/sites-stats-ports.md +++ b/doc/controllers/sites-stats-ports.md @@ -64,7 +64,7 @@ CountSiteSwOrGwPorts( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SitePortsCountDistinctEnum`](../../doc/models/site-ports-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SitePortsCountDistinctEnum`](../../doc/models/site-ports-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `fullDuplex` | `*bool` | Query, Optional | indicates full or half duplex | | `mac` | `*string` | Query, Optional | device identifier | | `neighborMac` | `*string` | Query, Optional | Chassis identifier of the chassis type listed | @@ -92,9 +92,9 @@ CountSiteSwOrGwPorts( | `up` | `*bool` | Query, Optional | indicates if interface is up | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -256,7 +256,7 @@ CountSiteSwitchPorts( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `distinct` | [`*models.SiteSwitchPortsCountDistinctEnum`](../../doc/models/site-switch-ports-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteSwitchPortsCountDistinctEnum`](../../doc/models/site-switch-ports-count-distinct-enum.md) | Query, Optional | **Default**: `"mac"` | | `fullDuplex` | `*bool` | Query, Optional | indicates full or half duplex | | `mac` | `*string` | Query, Optional | device identifier | | `neighborMac` | `*string` | Query, Optional | Chassis identifier of the chassis type listed | @@ -284,9 +284,9 @@ CountSiteSwitchPorts( | `up` | `*bool` | Query, Optional | indicates if interface is up | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -497,10 +497,10 @@ SearchSiteSwOrGwPorts( | `lteImsi` | `*string` | Query, Optional | LTE IMSI value, Check for null/empty | | `lteIccid` | `*string` | Query, Optional | LTE ICCID value, Check for null/empty | | `lteImei` | `*string` | Query, Optional | LTE IMEI value, Check for null/empty | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type @@ -747,10 +747,10 @@ SearchSiteSwitchPorts( | `stpRole` | [`*models.SearchSiteSwitchPortsStpRoleEnum`](../../doc/models/search-site-switch-ports-stp-role-enum.md) | Query, Optional | if `up`==`true` | | `authState` | [`*models.SearchSiteSwitchPortsAuthStateEnum`](../../doc/models/search-site-switch-ports-auth-state-enum.md) | Query, Optional | if `up`==`true` && has Authenticator role | | `up` | `*bool` | Query, Optional | indicates if interface is up | -| `limit` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | ## Response Type diff --git a/doc/controllers/sites-vp-ns.md b/doc/controllers/sites-vp-ns.md index c4e36659..e67aff77 100644 --- a/doc/controllers/sites-vp-ns.md +++ b/doc/controllers/sites-vp-ns.md @@ -27,7 +27,7 @@ ListSiteVpnsDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether resolve the site variables | +| `resolve` | `*bool` | Query, Optional | whether resolve the site variables
**Default**: `false` | ## Response Type diff --git a/doc/controllers/sites-wan-usages.md b/doc/controllers/sites-wan-usages.md index 83002f58..9f3b1653 100644 --- a/doc/controllers/sites-wan-usages.md +++ b/doc/controllers/sites-wan-usages.md @@ -51,12 +51,12 @@ CountSiteWanUsage( | `policy` | `*string` | Query, Optional | policy for the wan path | | `tenant` | `*string` | Query, Optional | tenant network in which the packet is sent | | `pathType` | `*string` | Query, Optional | path_type of the port | -| `distinct` | [`*models.WanUsagesCountDisctinctEnum`](../../doc/models/wan-usages-count-disctinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.WanUsagesCountDisctinctEnum`](../../doc/models/wan-usages-count-disctinct-enum.md) | Query, Optional | **Default**: `"policy"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -172,9 +172,9 @@ SearchSiteWanUsage( | `pathType` | `*string` | Query, Optional | path_type of the port | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-webhooks.md b/doc/controllers/sites-webhooks.md index 0e201541..ce35018e 100644 --- a/doc/controllers/sites-webhooks.md +++ b/doc/controllers/sites-webhooks.md @@ -63,8 +63,8 @@ CountSiteWebhooksDeliveries( | `distinct` | [`*models.WebhookDeliveryDistinctEnum`](../../doc/models/webhook-delivery-distinct-enum.md) | Query, Optional | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type @@ -401,8 +401,8 @@ ListSiteWebhooks( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -558,8 +558,8 @@ SearchSiteWebhooksDeliveries( | `topic` | [`*models.WebhookDeliveryTopicEnum`](../../doc/models/webhook-delivery-topic-enum.md) | Query, Optional | webhook topic | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | ## Response Type diff --git a/doc/controllers/sites-wlans.md b/doc/controllers/sites-wlans.md index c4c5f0b9..abe3b4ba 100644 --- a/doc/controllers/sites-wlans.md +++ b/doc/controllers/sites-wlans.md @@ -524,7 +524,7 @@ ListSiteWlanDerived( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `resolve` | `*bool` | Query, Optional | whether to resolve SITE_VARS | +| `resolve` | `*bool` | Query, Optional | whether to resolve SITE_VARS
**Default**: `false` | | `wlanId` | `*string` | Query, Optional | filter by WLAN ID | ## Response Type @@ -582,8 +582,8 @@ ListSiteWlans( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -1154,7 +1154,7 @@ UploadSiteWlanPortalImage( | `siteId` | `uuid.UUID` | Template, Required | - | | `wlanId` | `uuid.UUID` | Template, Required | - | | `file` | `models.FileWrapper` | Form, Required | binary file | -| `json` | `*string` | Form, Optional | JSON string describing your upload | +| `json` | `*string` | Form, Optional | - | ## Response Type diff --git a/doc/controllers/sites-wx-rules.md b/doc/controllers/sites-wx-rules.md index fb8624b5..23e8671f 100644 --- a/doc/controllers/sites-wx-rules.md +++ b/doc/controllers/sites-wx-rules.md @@ -377,8 +377,8 @@ ListSiteWxRules( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-wx-tags.md b/doc/controllers/sites-wx-tags.md index 570a7718..437aad4f 100644 --- a/doc/controllers/sites-wx-tags.md +++ b/doc/controllers/sites-wx-tags.md @@ -407,8 +407,8 @@ ListSiteWxTags( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-wx-tunnels.md b/doc/controllers/sites-wx-tunnels.md index 9bde6fa4..1a56ba8d 100644 --- a/doc/controllers/sites-wx-tunnels.md +++ b/doc/controllers/sites-wx-tunnels.md @@ -335,8 +335,8 @@ ListSiteWxTunnels( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sites-zones.md b/doc/controllers/sites-zones.md index 542f2a13..fab24334 100644 --- a/doc/controllers/sites-zones.md +++ b/doc/controllers/sites-zones.md @@ -48,16 +48,16 @@ CountSiteZoneSessions( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `zoneType` | [`models.ZoneTypeEnum`](../../doc/models/zone-type-enum.md) | Template, Required | - | -| `distinct` | [`*models.SiteZoneCountDistinctEnum`](../../doc/models/site-zone-count-distinct-enum.md) | Query, Optional | - | +| `distinct` | [`*models.SiteZoneCountDistinctEnum`](../../doc/models/site-zone-count-distinct-enum.md) | Query, Optional | **Default**: `"scope_id"` | | `userType` | [`*models.RfClientTypeEnum`](../../doc/models/rf-client-type-enum.md) | Query, Optional | user type | | `user` | `*string` | Query, Optional | client MAC / Asset MAC / SDK UUID | | `scopeId` | `*string` | Query, Optional | if `scope`==`map`/`zone`/`rssizone`, the scope id | -| `scope` | [`*models.ZoneScopeEnum`](../../doc/models/zone-scope-enum.md) | Query, Optional | scope | +| `scope` | [`*models.ZoneScopeEnum`](../../doc/models/zone-scope-enum.md) | Query, Optional | scope
**Default**: `"site"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -358,8 +358,8 @@ ListSiteZones( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -450,12 +450,12 @@ SearchSiteZoneSessions( | `userType` | [`*models.RfClientTypeEnum`](../../doc/models/rf-client-type-enum.md) | Query, Optional | user type, client (default) / sdkclient / asset | | `user` | `*string` | Query, Optional | client MAC / Asset MAC / SDK UUID | | `scopeId` | `*string` | Query, Optional | if `scope`==`map`/`zone`/`rssizone`, the scope id | -| `scope` | [`*models.VisitsScopeEnum`](../../doc/models/visits-scope-enum.md) | Query, Optional | scope | +| `scope` | [`*models.VisitsScopeEnum`](../../doc/models/visits-scope-enum.md) | Query, Optional | scope
**Default**: `"site"` | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/sitesv-beacons.md b/doc/controllers/sitesv-beacons.md index 6b4919c9..4860d5e7 100644 --- a/doc/controllers/sitesv-beacons.md +++ b/doc/controllers/sitesv-beacons.md @@ -256,8 +256,8 @@ ListSiteVBeacons( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/utilities-common.md b/doc/controllers/utilities-common.md index d231ffdb..c98ad7c4 100644 --- a/doc/controllers/utilities-common.md +++ b/doc/controllers/utilities-common.md @@ -488,7 +488,7 @@ GetSiteDeviceConfigCmd( | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | | `deviceId` | `uuid.UUID` | Template, Required | - | -| `sort` | `*bool` | Query, Optional | Make output cmds sorted (for better readability) or not. | +| `sort` | `*bool` | Query, Optional | Make output cmds sorted (for better readability) or not.
**Default**: `false` | ## Response Type diff --git a/doc/controllers/utilities-lan.md b/doc/controllers/utilities-lan.md index ff537ad9..f0ba9783 100644 --- a/doc/controllers/utilities-lan.md +++ b/doc/controllers/utilities-lan.md @@ -441,7 +441,7 @@ ReauthOrgDot1xWiredClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -505,7 +505,7 @@ ReauthSiteDot1xWiredClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/controllers/utilities-pca-ps.md b/doc/controllers/utilities-pca-ps.md index e677e13c..50208056 100644 --- a/doc/controllers/utilities-pca-ps.md +++ b/doc/controllers/utilities-pca-ps.md @@ -193,9 +193,9 @@ ListOrgPacketCaptures( | `orgId` | `uuid.UUID` | Template, Required | - | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type @@ -286,9 +286,9 @@ ListSitePacketCaptures( | `clientMac` | `*string` | Query, Optional | optional client mac filter | | `start` | `*int` | Query, Optional | start datetime, can be epoch or relative time like -1d, -1w; -1d if not specified | | `end` | `*int` | Query, Optional | end datetime, can be epoch or relative time like -1d, -2h; now if not specified | -| `duration` | `*string` | Query, Optional | duration like 7d, 2w | -| `limit` | `*int` | Query, Optional | - | -| `page` | `*int` | Query, Optional | - | +| `duration` | `*string` | Query, Optional | duration like 7d, 2w
**Default**: `"1d"` | +| `limit` | `*int` | Query, Optional | **Default**: `100`
**Constraints**: `>= 0` | +| `page` | `*int` | Query, Optional | **Default**: `1`
**Constraints**: `>= 1` | ## Response Type diff --git a/doc/controllers/utilities-upgrade.md b/doc/controllers/utilities-upgrade.md index cda72461..9b3ecee6 100644 --- a/doc/controllers/utilities-upgrade.md +++ b/doc/controllers/utilities-upgrade.md @@ -694,7 +694,7 @@ ListSiteAvailableDeviceVersions( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | - | +| `mType` | [`*models.DeviceTypeEnum`](../../doc/models/device-type-enum.md) | Query, Optional | **Default**: `"ap"` | | `model` | `*string` | Query, Optional | fetch version for device model, use/combine with `type` as needed (for switch and gateway devices) | ## Response Type @@ -1024,7 +1024,7 @@ UpgradeOrgJsiDevice( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `deviceMac` | `string` | Template, Required | - | +| `deviceMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | | `body` | [`*models.VersionString`](../../doc/models/version-string.md) | Body, Optional | - | ## Response Type diff --git a/doc/controllers/utilities-wi-fi.md b/doc/controllers/utilities-wi-fi.md index b9190fe9..8e384a0f 100644 --- a/doc/controllers/utilities-wi-fi.md +++ b/doc/controllers/utilities-wi-fi.md @@ -43,7 +43,7 @@ DeauthSiteWirelessClientsConnectedToARogue( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `rogueBssid` | `string` | Template, Required | - | +| `rogueBssid` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -151,7 +151,7 @@ DisconnectSiteWirelessClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -261,7 +261,7 @@ ReauthOrgDot1xWirelessClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `orgId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -313,7 +313,7 @@ ReauthSiteDot1xWirelessClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type @@ -636,7 +636,7 @@ UnauthorizeSiteWirelessClient( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `siteId` | `uuid.UUID` | Template, Required | - | -| `clientMac` | `string` | Template, Required | - | +| `clientMac` | `string` | Template, Required | **Constraints**: *Pattern*: `^[0-9a-fA-F]{12}$` | ## Response Type diff --git a/doc/models/const-nac-event.md b/doc/models/const-nac-event.md index 331940bd..5b6cbb10 100644 --- a/doc/models/const-nac-event.md +++ b/doc/models/const-nac-event.md @@ -48,7 +48,7 @@ "random_mac": true, "site_id": "441a1214-6928-442a-8e92-e1d34b8ec6a6", "ssid": "Test_Suriya-SSID", - "timestamp": 1685658478.438995, + "timestamp": 1685658478.43899, "type": "NAC_CLIENT_CERT_CHECK_SUCCESS", "username": "suriyas@juniper.net", "wcid": "b43637b0-f0d9-0a1d-1ec2-73c394a9f679" diff --git a/doc/models/event-nac-client.md b/doc/models/event-nac-client.md index efe05cde..081bde36 100644 --- a/doc/models/event-nac-client.md +++ b/doc/models/event-nac-client.md @@ -65,7 +65,7 @@ ], "site_id": "441a1214-6928-442a-8e92-e1d34b8ec6a6", "ssid": "mist_nac", - "timestamp": 1691512031.358188, + "timestamp": 1691512031.35819, "type": "NAC_CLIENT_PERMIT", "usermac_labels": [ "bldg5", diff --git a/doc/models/fwupdate-stat.md b/doc/models/fwupdate-stat.md index b9c61d50..96db5a2c 100644 --- a/doc/models/fwupdate-stat.md +++ b/doc/models/fwupdate-stat.md @@ -22,7 +22,7 @@ "progress": 10, "status": "inprogress", "status_id": 5, - "timestamp": 1716480189.8164835, + "timestamp": 1716480189.81648, "will_retry": false } ``` diff --git a/doc/models/image-import.md b/doc/models/image-import.md index 250ac777..ef8ff545 100644 --- a/doc/models/image-import.md +++ b/doc/models/image-import.md @@ -10,7 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `File` | `[]byte` | Required | binary file | -| `Json` | `*string` | Optional | JSON string describing your upload | +| `Json` | `*string` | Optional | - | ## Example (as JSON) diff --git a/doc/models/installer-device.md b/doc/models/installer-device.md index a177c7d3..d8f4545e 100644 --- a/doc/models/installer-device.md +++ b/doc/models/installer-device.md @@ -37,7 +37,7 @@ "ext_ip": "12.34.56.78", "height": 2.7, "ip": "192.168.1.111", - "last_seen": 1687887907.5919843, + "last_seen": 1687887907.59198, "mac": "5c5b35000018", "map_id": "845a23bf-bed9-e43c-4c86-6fa474be7ae5", "model": "AP41", diff --git a/doc/models/response-inventory-error-exception.md b/doc/models/response-inventory-error-exception.md new file mode 100644 index 00000000..38b3d53b --- /dev/null +++ b/doc/models/response-inventory-error-exception.md @@ -0,0 +1,76 @@ + +# Response Inventory Error Exception + +## Structure + +`ResponseInventoryErrorException` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Added` | `[]string` | Optional | - | +| `Duplicated` | `[]string` | Optional | - | +| `Error` | `[]string` | Optional | - | +| `InventoryAdded` | [`[]models.ResponseInventoryInventoryAddedItems`](../../doc/models/response-inventory-inventory-added-items.md) | Optional | **Constraints**: *Minimum Items*: `1`, *Unique Items Required* | +| `InventoryDuplicated` | [`[]models.ResponseInventoryInventoryDuplicatedItems`](../../doc/models/response-inventory-inventory-duplicated-items.md) | Optional | **Constraints**: *Minimum Items*: `1`, *Unique Items Required* | +| `Reason` | `[]string` | Optional | **Constraints**: *Unique Items Required* | + +## Example (as JSON) + +```json +{ + "added": [ + "added8" + ], + "duplicated": [ + "duplicated7", + "duplicated8", + "duplicated9" + ], + "error": [ + "error1", + "error2" + ], + "inventory_added": [ + { + "mac": "mac0", + "magic": "magic6", + "model": "model4", + "serial": "serial6", + "type": "type6" + }, + { + "mac": "mac0", + "magic": "magic6", + "model": "model4", + "serial": "serial6", + "type": "type6" + }, + { + "mac": "mac0", + "magic": "magic6", + "model": "model4", + "serial": "serial6", + "type": "type6" + } + ], + "inventory_duplicated": [ + { + "mac": "mac0", + "magic": "magic6", + "model": "model4", + "serial": "serial6", + "type": "type6" + }, + { + "mac": "mac0", + "magic": "magic6", + "model": "model4", + "serial": "serial6", + "type": "type6" + } + ] +} +``` + diff --git a/doc/models/response-inventory.md b/doc/models/response-inventory.md index 15677eb0..a45df76a 100644 --- a/doc/models/response-inventory.md +++ b/doc/models/response-inventory.md @@ -14,6 +14,7 @@ | `Error` | `[]string` | Optional | - | | `InventoryAdded` | [`[]models.ResponseInventoryInventoryAddedItems`](../../doc/models/response-inventory-inventory-added-items.md) | Optional | **Constraints**: *Minimum Items*: `1`, *Unique Items Required* | | `InventoryDuplicated` | [`[]models.ResponseInventoryInventoryDuplicatedItems`](../../doc/models/response-inventory-inventory-duplicated-items.md) | Optional | **Constraints**: *Minimum Items*: `1`, *Unique Items Required* | +| `Reason` | `[]string` | Optional | **Constraints**: *Unique Items Required* | ## Example (as JSON) diff --git a/doc/models/response-stats-assets.md b/doc/models/response-stats-assets.md index 2404094e..f9c64e51 100644 --- a/doc/models/response-stats-assets.md +++ b/doc/models/response-stats-assets.md @@ -40,8 +40,8 @@ "name": "6fa474be7ae5", "rssi": -60, "temperatur": 23, - "x": 280.19918140310193, - "y": 420.2987721046529 + "x": 280.199181403102, + "y": 420.298772104653 } ], "start": 128, diff --git a/doc/models/response-zone-search.md b/doc/models/response-zone-search.md index d9466ee5..d9df8297 100644 --- a/doc/models/response-zone-search.md +++ b/doc/models/response-zone-search.md @@ -20,10 +20,10 @@ ```json { - "end": 1541705289.769911, + "end": 1541705289.76991, "limit": 1, "next": "/api/v1/sites/67970e46-4e12-11e6-9188-0242ac110007/zones/visits/search?limit=2&end=1541705247.000&scope_id=85fbba9e-4e12-11e6-9188-0242ac110007&user_type=asset&start=1541618889.77", - "start": 1541618889.769886, + "start": 1541618889.76989, "total": 5892, "results": [ { diff --git a/doc/models/service-path-event.md b/doc/models/service-path-event.md index 799352b4..dcf8ef47 100644 --- a/doc/models/service-path-event.md +++ b/doc/models/service-path-event.md @@ -33,7 +33,7 @@ "port_id": "ge-1/0/6", "site_id": "441a1214-6928-442a-8e92-e1d34b8ec6a6", "text": "Peer Path Down", - "timestamp": 1697037328.651775, + "timestamp": 1697037328.65177, "type": "GW_SERVICE_PATH_REMOVE", "version": "6.1.5-14.lts", "vpn_name": "Syracuse_HUB", diff --git a/doc/models/stats-asset.md b/doc/models/stats-asset.md index c26f1078..3f9cee6b 100644 --- a/doc/models/stats-asset.md +++ b/doc/models/stats-asset.md @@ -52,8 +52,8 @@ Asset statistics "name": "6fa474be7ae5", "rssi": -60, "temperatur": 23, - "x": 280.19918140310193, - "y": 420.2987721046529 + "x": 280.199181403102, + "y": 420.298772104653 } ``` diff --git a/doc/models/webhook-delivery.md b/doc/models/webhook-delivery.md index a3fd8c23..f72c88d8 100644 --- a/doc/models/webhook-delivery.md +++ b/doc/models/webhook-delivery.md @@ -37,7 +37,7 @@ "site_id": "441a1214-6928-442a-8e92-e1d34b8ec6a6", "status": "failure", "status_code": 200, - "timestamp": 1687962508.583656, + "timestamp": 1687962508.58366, "topic": "audits", "webhook_id": "7a11b901-f719-4c91-8aef-deb8699a6364", "error": "error0" diff --git a/doc/models/webhook-nac-events-event.md b/doc/models/webhook-nac-events-event.md index 4c57ab7c..d285200a 100644 --- a/doc/models/webhook-nac-events-event.md +++ b/doc/models/webhook-nac-events-event.md @@ -55,7 +55,7 @@ ], "site_id": "441a1214-6928-442a-8e92-e1d34b8ec6a6", "ssid": "##mist_nac", - "timestamp": 1691512031.358188, + "timestamp": 1691512031.35819, "type": "NAC_CLIENT_PERMIT", "username": "user@deaflyz.net", "vlan": "750", diff --git a/doc/models/wlan-portal-template-setting.md b/doc/models/wlan-portal-template-setting.md index e9443499..b320dc75 100644 --- a/doc/models/wlan-portal-template-setting.md +++ b/doc/models/wlan-portal-template-setting.md @@ -123,7 +123,7 @@ portal template wlan settings | `SmsCodeSubmit` | `*string` | Optional | Label for confirmation code submit button
**Default**: `"Sign In"` | | `SmsCodeTitle` | `*string` | Optional | **Default**: `"Access Code"` | | `SmsCountryFieldLabel` | `*string` | Optional | **Default**: `"Country Code"` | -| `SmsCountryFormat` | `*string` | Optional | **Default**: `"1"` | +| `SmsCountryFormat` | `*string` | Optional | **Default**: `"+1"` | | `SmsHaveAccessCode` | `*string` | Optional | Label for checkbox to specify that the user has access code
**Default**: `"I have an access code"` | | `SmsIsTwilio` | `*bool` | Optional | **Default**: `false` | | `SmsMessageFormat` | `*string` | Optional | format of access code sms message. {{code}} and {{duration}} are place holders and should be retained as is. | @@ -250,7 +250,7 @@ portal template wlan settings "smsCodeSubmit": "Sign In", "smsCodeTitle": "Access Code", "smsCountryFieldLabel": "Country Code", - "smsCountryFormat": "1", + "smsCountryFormat": "+1", "smsHaveAccessCode": "I have an access code", "smsIsTwilio": false, "smsNumberCancel": "Cancel", diff --git a/mistapi/admins_login_test.go b/mistapi/admins_login_test.go new file mode 100644 index 00000000..5df37dba --- /dev/null +++ b/mistapi/admins_login_test.go @@ -0,0 +1,46 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestAdminsLoginTestLogin tests the behavior of the AdminsLogin +func TestAdminsLoginTestLogin(t *testing.T) { + ctx := context.Background() + var body models.Login + errBody := json.Unmarshal([]byte(`{"email":"test@mistsys.com","password":"foryoureyesonly","two_factor":"123456"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := adminsLogin.Login(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(false,"Set-Cookie",""), + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"email":"test@mistsys.com","two_factor_passed":false,"two_factor_required":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestAdminsLoginTestTwoFactor tests the behavior of the AdminsLogin +func TestAdminsLoginTestTwoFactor(t *testing.T) { + ctx := context.Background() + var body models.TwoFactorString + errBody := json.Unmarshal([]byte(`{"two_factor":"123456"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := adminsLogin.TwoFactor(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/admins_logout_test.go b/mistapi/admins_logout_test.go new file mode 100644 index 00000000..3157afec --- /dev/null +++ b/mistapi/admins_logout_test.go @@ -0,0 +1,23 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestAdminsLogoutTestLogout tests the behavior of the AdminsLogout +func TestAdminsLogoutTestLogout(t *testing.T) { + ctx := context.Background() + apiResponse, err := adminsLogout.Logout(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"forward_url":"https://my.sso/custom_logout_url"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/admins_lookup_test.go b/mistapi/admins_lookup_test.go new file mode 100644 index 00000000..71fd907e --- /dev/null +++ b/mistapi/admins_lookup_test.go @@ -0,0 +1,30 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestAdminsLookupTestLookup tests the behavior of the AdminsLookup +func TestAdminsLookupTestLookup(t *testing.T) { + ctx := context.Background() + var body models.EmailString + errBody := json.Unmarshal([]byte(`{"email":"test@mistsys.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := adminsLookup.Lookup(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"sso_url":"https://my.sso/idp_sso_url"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/admins_recover_password_test.go b/mistapi/admins_recover_password_test.go new file mode 100644 index 00000000..463d8212 --- /dev/null +++ b/mistapi/admins_recover_password_test.go @@ -0,0 +1,24 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestAdminsRecoverPasswordTestRecoverPassword tests the behavior of the AdminsRecoverPassword +func TestAdminsRecoverPasswordTestRecoverPassword(t *testing.T) { + ctx := context.Background() + var body models.Recover + errBody := json.Unmarshal([]byte(`{"email":"test@mistsys.com","recaptcha":"string","recaptcha_flavor":"hcaptcha"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := adminsRecoverPassword.RecoverPassword(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/admins_test.go b/mistapi/admins_test.go new file mode 100644 index 00000000..3fbfa876 --- /dev/null +++ b/mistapi/admins_test.go @@ -0,0 +1,41 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestAdminsTestRegisterNewAdmin tests the behavior of the Admins +func TestAdminsTestRegisterNewAdmin(t *testing.T) { + ctx := context.Background() + var body models.AdminInvite + errBody := json.Unmarshal([]byte(`{"account_only":false,"allow_mist":false,"city":"Cupertino","country":"United States","email":"test@mistsys.com","first_name":"John","invite_code":"MISTROCKS","last_name":"Smith","org_name":"Smith LLC","password":"foryoureyesonly","recaptcha":"string","recaptcha_flavor":"hcaptcha","referer_invite_token":"Dm2gtT8dwMeM4Bc2E8FLIaA96VHOjPat","return_to":"http://mist.zendesk.com/hc/quickstart.pdf","state":"California","street_address":"1601 S De Anza Blvd Ste 248","street_address 2":"1601 S De Anza Blvd Ste 248","zipcode":"95014"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := admins.RegisterNewAdmin(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestAdminsTestGetAdminRegistrationInfo tests the behavior of the Admins +func TestAdminsTestGetAdminRegistrationInfo(t *testing.T) { + ctx := context.Background() + recaptchaFlavor := models.RecaptchaFlavorEnum("google") + apiResponse, err := admins.GetAdminRegistrationInfo(ctx, &recaptchaFlavor) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"flavor":"google","required":true,"sitekey":"6LdAewsTAAAAAE25XKQhPEQ2FiMTft-WrZXQ5NUd"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/constants_definitions_test.go b/mistapi/constants_definitions_test.go new file mode 100644 index 00000000..a3b7d595 --- /dev/null +++ b/mistapi/constants_definitions_test.go @@ -0,0 +1,184 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestConstantsDefinitionsTestListApChannels tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListApChannels(t *testing.T) { + ctx := context.Background() + countryCode := "US" + apiResponse, err := constantsDefinitions.ListApChannels(ctx, &countryCode) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"band24_40mhz_allowed":true,"band24_channels":{"20":[1,2,3,4,5,6,7,8,9,10,11],"40":[1,2,3,4,5,6,7,8,9,10,11]},"band24_enabled":true,"band5_channels":{"20":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165],"40":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161],"80":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161],"dfs":[52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144],"outdoor":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165]},"band5_enabled":true,"band6_channels":{"160":[1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213,217,221],"20":[1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,233],"40":[1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229],"80":[1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213,217,221],"psc":[5,21,37,53,69,85,101,117,133,149,165,181,197,213,229]},"band6_enabled":true,"certified":true,"code":840,"dfs_ok":true,"key":"US","name":"United States","uses":"US_FCC"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListApLedDefinition tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListApLedDefinition(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListApLedDefinition(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"code":"01","description":"LED not working","key":"LED_FAILURE","name":"LED Failure"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListAppCategoryDefinitions tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListAppCategoryDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListAppCategoryDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"Images","filters":{"srx":["Enhanced_Images_Media","Enhanced_Web_Images","Enhanced_Image_Servers"]},"key":"Images"},{"display":"Standard","includes":["Adult","FileSharing","Games","Images","Malware","NewsAndReference","Recreation","Religion","Security","Sports","Technology","Violence"],"key":"Standard"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListAppSubCategoryDefinitions tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListAppSubCategoryDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListAppSubCategoryDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"Office Documents","key":"Office_Documents","traffic_type":"data_interactive"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListApplications tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListApplications(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListApplications(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"app_id":true,"app_image_url":"","app_probe":true,"category":"FileSharing","group":"File Sharing","key":"dropbox","name":"Dropbox","signature_based":true,"ssr_app_id":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListCountryCodes tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListCountryCodes(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListCountryCodes(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"alpha2":"FR","certified":true,"name":"France","numeric":250}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListGatewayApplications tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListGatewayApplications(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListGatewayApplications(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"app_id":true,"key":"4shared","name":"4shared","ssr_app_id":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListInsightMetrics tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListInsightMetrics(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListInsightMetrics(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"bytes":{"description":"aggregated bytes over time","example":[185,197,250],"intervals":{"10m":{"interval":600,"max_age":86400},"1h":{"interval":3600,"max_age":1209600}},"report_durations":{"1d":{"duration":86400,"interval":3600},"1w":{"duration":604800,"interval":3600}},"report_scopes":["site","org"],"scopes":["site","ap","client"],"type":"timeseries","unit":"byte"},"num_clients":{"description":"number of client over time","example":[18,null,15],"intervals":{"10m":{"interval":600,"max_age":86400},"1h":{"interval":3600,"max_age":1209600}},"report_durations":{"1d":{"duration":86400,"interval":3600},"1w":{"duration":604800,"interval":3600}},"report_scopes":["site","org"],"scopes":["site","ap","device"],"type":"timeseries","unit":""}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListSiteLanguages tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListSiteLanguages(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListSiteLanguages(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"English (US)","display_native":"English (US)","key":"en-US"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestGetLicenseTypes tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestGetLicenseTypes(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.GetLicenseTypes(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"description":"Wired Assurance 12","includes":["sub_ex12a","sub_ex12p"],"key":"sub_ex12","name":"SUB-EX12"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsDefinitionsTestListTrafficTypes tests the behavior of the ConstantsDefinitions +func TestConstantsDefinitionsTestListTrafficTypes(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsDefinitions.ListTrafficTypes(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"VoIP Video","dscp":32,"failover_policy":"non_revertible","max_jitter":250,"max_latency":1500,"max_loss":35,"name":"voip_video","traffic_class":"medium"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/constants_events_test.go b/mistapi/constants_events_test.go new file mode 100644 index 00000000..14da491e --- /dev/null +++ b/mistapi/constants_events_test.go @@ -0,0 +1,119 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestConstantsEventsTestListAlarmDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListAlarmDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListAlarmDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"Device offline","example":{"aps":["d420b02000fa"],"count":1,"group":"infrastructure","hostnames":["Vendor_AP2"],"id":"e70c308f-7007-4866-9ecd-0d01842979ea","last_seen":1629753888,"org_id":"09dac91f-6e73-4100-89f7-698e0fafbb1b","severity":"warn","site_id":"dcfb31a1-d615-4361-8c95-b9dde05aa704","timestamp":1629753888,"type":"device_down"},"fields":["aps","hostnames"],"group":"infrastructure","key":"device_down","marvis_suggestion_category":"string","severity":"warn"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListClientEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListClientEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListClientEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"11r Association","key":"CLIENT_AUTH_ASSOCIATION_11R"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListDeviceEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListDeviceEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListDeviceEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"description":"AP was assigned to a site","display":"AP Assigned","example":{"ap":"5c5b35000001","audit_id":"e9a88814-fa81-5bdc-34b0-84e8735420e5","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1552408871,"type":"AP_ASSIGNED"},"key":"AP_ASSIGNED"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListMxEdgeEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListMxEdgeEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListMxEdgeEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"description":"Config change on ME was triggered as a result of change made by user","display":"ME Config changed by user","example":{"audit_id":"e9a88814-fa81-5bdc-34b0-84e8735420e5","mxcluster_id":"ed4665ed-c9ad-4835-8ca5-dda642765ad3","mxedge_id":"387804a7-3474-85ce-15a2-f9a9684c9c9","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","service":"mxagent","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1552408871,"type":"ME_CONFIG_CHANGED_BY_USER"},"key":"ME_CONFIG_CHANGED_BY_USER"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListNacEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListNacEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListNacEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"ap":"5c5b355008c0","bssid":"5c5b35548892","cert_cn":"suriyas","cert_expiry":1711557441,"cert_issuer":"/DC=net/DC=jnpr/CN=Juniper Networks Issuing AWS1 CA","cert_san_upn":["suriyas@juniper.net"],"cert_serial":"1300103d29e56ef083797bedc2000100103d29","cert_subject":"/CN=suriyas/emailAddress=suriyas@juniper.net","eap_type":"EAP-TLS","nas_vendor":"Mist","org_id":"94de66e8-556a-4d56-8780-a114620a5c42","random_mac":true,"site_id":"b5a005ab-47d4-41f7-97bf-733f9cc252dd","ssid":"Test_Suriya-SSID","timestamp":1685658478.4389949,"type":"NAC_CLIENT_CERT_CHECK_SUCCESS","username":"suriyas@juniper.net","wcid":"b43637b0-f0d9-0a1d-1ec2-73c394a9f679"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListOtherDeviceEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListOtherDeviceEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListOtherDeviceEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"Connected to NCM","example":{"device_mac":"5c5b351e13b5","mac":"0030447771c0","org_id":"c080ce4d-4e35-4373-bdc4-08df15d257f5","site_id":"1df889ad-9111-4c0e-a00b-8a008b83eb68","text":"Connected to NCM","timestamp":1675827825.765,"type":"CELLULAR_EDGE_CONNECTED_TO_NCM","vendor":"cradlepoint"},"key":"CELLULAR_EDGE_CONNECTED_TO_NCM"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsEventsTestListSystemEventsDefinitions tests the behavior of the ConstantsEvents +func TestConstantsEventsTestListSystemEventsDefinitions(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsEvents.ListSystemEventsDefinitions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"AP Disconnect","group":"ap_health","key":"ap_disconnected"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/constants_models_test.go b/mistapi/constants_models_test.go new file mode 100644 index 00000000..e8b96b63 --- /dev/null +++ b/mistapi/constants_models_test.go @@ -0,0 +1,39 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestConstantsModelsTestListMxEdgeModels tests the behavior of the ConstantsModels +func TestConstantsModelsTestListMxEdgeModels(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsModels.ListMxEdgeModels(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"display":"X10","model":"ME-X10","ports":{"0":{"display":"xe0","speed":10000},"1":{"display":"xe1","speed":10000},"2":{"display":"xe2","speed":10000},"3":{"display":"xe3","speed":10000}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestConstantsModelsTestListSupportedOtherDeviceModels tests the behavior of the ConstantsModels +func TestConstantsModelsTestListSupportedOtherDeviceModels(t *testing.T) { + ctx := context.Background() + apiResponse, err := constantsModels.ListSupportedOtherDeviceModels(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"_vendor_model_id":"65","display":"W1850","model":"W1850","type":"router","vendor":"cradlepoint"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/errors/errors.go b/mistapi/errors/errors.go index 4a3d20bd..65a99fc9 100644 --- a/mistapi/errors/errors.go +++ b/mistapi/errors/errors.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/apimatic/go-core-runtime/https" "github.com/google/uuid" + "mistapi/models" ) // ErrorDeleteFailed is a custom error. @@ -170,3 +171,26 @@ func NewResponseHttp429Error(apiError https.ApiError) error { func (r ResponseHttp429Error) Error() string { return fmt.Sprintf("ResponseHttp429Error occured: %v", r.Message) } + +// ResponseInventoryError is a custom error. +type ResponseInventoryError struct { + https.ApiError + Added []string `json:"added,omitempty"` + Duplicated []string `json:"duplicated,omitempty"` + MError []string `json:"error,omitempty"` + InventoryAdded []models.ResponseInventoryInventoryAddedItems `json:"inventory_added,omitempty"` + InventoryDuplicated []models.ResponseInventoryInventoryDuplicatedItems `json:"inventory_duplicated,omitempty"` + Reason []string `json:"reason,omitempty"` +} + +// NewResponseInventoryError is a constructor for ResponseInventoryError. +// It creates and returns a pointer to a new ResponseInventoryError instance with the given statusCode and body. +func NewResponseInventoryError(apiError https.ApiError) error { + return &ResponseInventoryError{ApiError: apiError} +} + +// Error implements the Error method for the error interface. +// It returns a formatted error message for ResponseInventoryError. +func (r ResponseInventoryError) Error() string { + return fmt.Sprintf("ResponseInventoryError occured: %v", r.Message) +} diff --git a/mistapi/installer.go b/mistapi/installer.go index 2043881b..e4ad6f8a 100644 --- a/mistapi/installer.go +++ b/mistapi/installer.go @@ -203,7 +203,7 @@ func (i *Installer) ClaimInstallerDevices( ), ) req.AppendErrors(map[string]https.ErrorBuilder[error]{ - "400": {Message: "Bad Request if none of the entries are valid"}, + "400": {Message: "OK - if any of entries are valid or there’s no errors", Unmarshaller: errors.NewResponseInventoryError}, "401": {Message: "Unauthorized", Unmarshaller: errors.NewResponseHttp401Error}, "403": {Message: "Permission Denied", Unmarshaller: errors.NewResponseHttp403Error}, "404": {Message: "Not found. The API endpoint doesn’t exist or resource doesn’ t exist", Unmarshaller: errors.NewResponseHttp404}, diff --git a/mistapi/installer_test.go b/mistapi/installer_test.go new file mode 100644 index 00000000..01b3d2b2 --- /dev/null +++ b/mistapi/installer_test.go @@ -0,0 +1,222 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestInstallerTestListInstallerAlarmTemplates tests the behavior of the Installer +func TestInstallerTestListInstallerAlarmTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := installer.ListInstallerAlarmTemplates(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","name":"AlarmTemplate 1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestListInstallerDeviceProfiles tests the behavior of the Installer +func TestInstallerTestListInstallerDeviceProfiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + apiResponse, err := installer.ListInstallerDeviceProfiles(ctx, orgId, &mType) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","name":"DeviceProfile 1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestListInstallerListOfRenctlyClaimedDevices tests the behavior of the Installer +func TestInstallerTestListInstallerListOfRenctlyClaimedDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + limit := int(100) + page := int(1) + apiResponse, err := installer.ListInstallerListOfRenctlyClaimedDevices(ctx, orgId, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"connected":true,"deviceprofile_name":"SJ1","height":2.7,"mac":"5c5b35000018","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","model":"AP41","name":"hallway","orientation":90,"serial":"FXLH2015150025","site_name":"SJ1","x":150,"y":300}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestClaimInstallerDevices tests the behavior of the Installer +func TestInstallerTestClaimInstallerDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + body := []string{ "6JG8E-PTFV2-A9Z2N","DVH4V-SNMSZ-PDXBR" } + apiResponse, err := installer.ClaimInstallerDevices(ctx, orgId, body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"added":["6JG8E-PTFV2-A9Z2N"],"duplicated":["DVH4V-SNMSZ-PDXBR"],"error":["PO1025335ohoh"],"inventory_added":[{"mac":"5c5b35000018","magic":"6JG8EPTFV2A9Z2N","model":"AP41","serial":"FXLH2015150025","type":"ap"}],"inventory_duplicated":[{"mac":"5c5b35000012","magic":"DVH4VSNMSZPDXBR","model":"AP41","serial":"FXLH2015150027","type":"ap"}],"reason":["belongs to another org ('e2f543f7-d6e1-409f-a565-e77a1f098d3b' (other) != '0de5d6fc-219a-414d-a840-67d6b919ad8f' (you))"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestUnassignInstallerRecentlyClaimedDevice tests the behavior of the Installer +func TestInstallerTestUnassignInstallerRecentlyClaimedDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + resp, err := installer.UnassignInstallerRecentlyClaimedDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestInstallerTestProvisionInstallerDevices tests the behavior of the Installer +func TestInstallerTestProvisionInstallerDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + var body models.InstallerProvisionDevice + errBody := json.Unmarshal([]byte(`{"deviceprofile_name":"SJ1","height":2.7,"name":"SJ1-AP1","orientation":90,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"SJ1","x":150,"y":300}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := installer.ProvisionInstallerDevices(ctx, orgId, deviceMac, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestInstallerTestStartInstallerLocateDevice tests the behavior of the Installer +func TestInstallerTestStartInstallerLocateDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + resp, err := installer.StartInstallerLocateDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestInstallerTestStopInstallerLocateDevice tests the behavior of the Installer +func TestInstallerTestStopInstallerLocateDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + resp, err := installer.StopInstallerLocateDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestInstallerTestListInstallerRfTemplatesNames tests the behavior of the Installer +func TestInstallerTestListInstallerRfTemplatesNames(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := installer.ListInstallerRfTemplatesNames(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","name":"RFTemplate 1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestListInstallerSiteGroups tests the behavior of the Installer +func TestInstallerTestListInstallerSiteGroups(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := installer.ListInstallerSiteGroups(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"581328b6-e382-f54e-c9dc-999983183a34","name":"SiteGroup 1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestInstallerTestListInstallerSites tests the behavior of the Installer +func TestInstallerTestListInstallerSites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := installer.ListInstallerSites(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","country_code":"US","id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","latlng":{"lat":37.295833,"lng":-122.032946},"name":"Mist Office","rftemplate_name":"rftemplate1","sitegroup_names":["sg1","sg2"],"timezone":"America/Los_Angeles"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/models/image_import.go b/mistapi/models/image_import.go index 220d81eb..15293a5b 100644 --- a/mistapi/models/image_import.go +++ b/mistapi/models/image_import.go @@ -10,7 +10,6 @@ import ( type ImageImport struct { // binary file File []byte `json:"file"` - // JSON string describing your upload Json *string `json:"json,omitempty"` AdditionalProperties map[string]any `json:"_"` } diff --git a/mistapi/models/response_inventory.go b/mistapi/models/response_inventory.go index 41c5026c..01033ea0 100644 --- a/mistapi/models/response_inventory.go +++ b/mistapi/models/response_inventory.go @@ -11,6 +11,7 @@ type ResponseInventory struct { Error []string `json:"error,omitempty"` InventoryAdded []ResponseInventoryInventoryAddedItems `json:"inventory_added,omitempty"` InventoryDuplicated []ResponseInventoryInventoryDuplicatedItems `json:"inventory_duplicated,omitempty"` + Reason []string `json:"reason,omitempty"` AdditionalProperties map[string]any `json:"_"` } @@ -41,6 +42,9 @@ func (r ResponseInventory) toMap() map[string]any { if r.InventoryDuplicated != nil { structMap["inventory_duplicated"] = r.InventoryDuplicated } + if r.Reason != nil { + structMap["reason"] = r.Reason + } return structMap } @@ -52,7 +56,7 @@ func (r *ResponseInventory) UnmarshalJSON(input []byte) error { if err != nil { return err } - additionalProperties, err := UnmarshalAdditionalProperties(input, "added", "duplicated", "error", "inventory_added", "inventory_duplicated") + additionalProperties, err := UnmarshalAdditionalProperties(input, "added", "duplicated", "error", "inventory_added", "inventory_duplicated", "reason") if err != nil { return err } @@ -63,6 +67,7 @@ func (r *ResponseInventory) UnmarshalJSON(input []byte) error { r.Error = temp.Error r.InventoryAdded = temp.InventoryAdded r.InventoryDuplicated = temp.InventoryDuplicated + r.Reason = temp.Reason return nil } @@ -73,4 +78,5 @@ type tempResponseInventory struct { Error []string `json:"error,omitempty"` InventoryAdded []ResponseInventoryInventoryAddedItems `json:"inventory_added,omitempty"` InventoryDuplicated []ResponseInventoryInventoryDuplicatedItems `json:"inventory_duplicated,omitempty"` + Reason []string `json:"reason,omitempty"` } diff --git a/mistapi/ms_ps_admins_test.go b/mistapi/ms_ps_admins_test.go new file mode 100644 index 00000000..1116ee33 --- /dev/null +++ b/mistapi/ms_ps_admins_test.go @@ -0,0 +1,173 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsAdminsTestListMspAdmins tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestListMspAdmins(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsAdmins.ListMspAdmins(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"admin_id":"456b7016-a916-a4b1-78dd-72b947c152b7","email":"jsmith@mycorp.org","first_name":"Joe","last_name":"Smith","privileges":[{"role":"admin","scope":"msp"},{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","role":"admin","scope":"org"},{"orggroup_ids":["507f1bab-13ba-73e2-f291-2bcb8d1362b0"],"role":"read","scope":"orggroup"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsAdminsTestRevokeMspAdmin tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestRevokeMspAdmin(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + adminId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsAdmins.RevokeMspAdmin(ctx, mspId, adminId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsAdminsTestGetMspAdmin tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestGetMspAdmin(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + adminId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsAdmins.GetMspAdmin(ctx, mspId, adminId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsAdminsTestUpdateMspAdmin tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestUpdateMspAdmin(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + adminId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"jsnow@abc.com","first_name":"string","last_name":"string","privileges":[{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","role":"admin","scope":"org","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},{"role":"admin","scope":"site","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsAdmins.UpdateMspAdmin(ctx, mspId, adminId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsAdminsTestInviteMspAdmin tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestInviteMspAdmin(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsAdmins.InviteMspAdmin(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsAdminsTestUninviteMspAdmin tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestUninviteMspAdmin(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + inviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsAdmins.UninviteMspAdmin(ctx, mspId, inviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsAdminsTestUpdateMspAdminInvite tests the behavior of the MSPsAdmins +func TestMSPsAdminsTestUpdateMspAdminInvite(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + inviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsAdmins.UpdateMspAdminInvite(ctx, mspId, inviteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_inventory_test.go b/mistapi/ms_ps_inventory_test.go new file mode 100644 index 00000000..ab6cf9d7 --- /dev/null +++ b/mistapi/ms_ps_inventory_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestMSPsInventoryTestGetMspInventoryByMac tests the behavior of the MSPsInventory +func TestMSPsInventoryTestGetMspInventoryByMac(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + apiResponse, err := msPsInventory.GetMspInventoryByMac(ctx, mspId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"mac":"5c5b35000018","model":"AP200","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","serial":"FXLH2015150025","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","type":"ap"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_licenses_test.go b/mistapi/ms_ps_licenses_test.go new file mode 100644 index 00000000..8c83d9ce --- /dev/null +++ b/mistapi/ms_ps_licenses_test.go @@ -0,0 +1,94 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsLicensesTestClaimMspLicence tests the behavior of the MSPsLicenses +func TestMSPsLicensesTestClaimMspLicence(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.CodeString + errBody := json.Unmarshal([]byte(`{"code":"ZHT3K-H36DT-MG85D-M61AC"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsLicenses.ClaimMspLicence(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"inventory_added":[{"mac":"5c5b35000018","magic":"6JG8EPTFV2A9Z2N","model":"AP41","serial":"FXLH2015150025","type":"ap"}],"inventory_duplicated":[{"mac":"5c5b35000012","magic":"DVH4VSNMSZPDXBR","model":"AP41","serial":"FXLH2015150027","type":"ap"}],"license_added":[{"end":1520380800,"quantity":180,"start":1504828800,"type":"SUB-MAN"},{"end":1520380800,"quantity":120,"start":1504828800,"type":"SUB-LOC"}],"license_duplicated":[{"end":1520380800,"quantity":180,"start":1504828800,"type":"SUB-MAN"}],"license_error":[{"order":"00000464","reason":""}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsLicensesTestListMspLicenses tests the behavior of the MSPsLicenses +func TestMSPsLicensesTestListMspLicenses(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsLicenses.ListMspLicenses(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"amendments":[{"created_time":1644684842,"end_time":1744156799,"id":"ff0a14f6-1234-5678-90ab-c8e64d4bc6c6","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1644684842,"end_time":1744156799,"id":"c1c28812-1234-5678-90ab-dc95680da61e","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"},{"created_time":1644684842,"end_time":1744243199,"id":"96c0a41f-1234-5678-90ab-afe74817e9fd","modified_time":1644684842,"quantity":-1,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"}],"entitled":{"SUB-ENG":26,"SUB-EX24":9,"SUB-MAN":26,"SUB-VNA":26},"licenses":[{"created_time":1555353534,"end_time":1586822399,"id":"693a41a6-1234-5678-90ab-f53dbd3a31c0","modified_time":1555353534,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":0,"start_time":1555286400,"subscription_id":"VNA-000000aa","type":"SUB-VNA"},{"created_time":1576132516,"end_time":1586822399,"id":"656607cf-1234-5678-90ab-fc9035614ea5","modified_time":1576132516,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":8,"remaining_quantity":0,"start_time":1576022400,"subscription_id":"VNA-000000ab","type":"SUB-VNA"},{"created_time":1579204568,"end_time":1730764800,"id":"db50d0bc-1234-5678-90ab-e439958cb06b","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"MAN-000000ac","type":"SUB-MAN"},{"created_time":1579204568,"end_time":1730764800,"id":"2ff9e84a-1234-5678-90ab-fb9ec0726e01","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"ENG-000000ad","type":"SUB-ENG"},{"created_time":1579204568,"end_time":1730764800,"id":"16df7ea6-1234-5678-90ab-78018cd4024d","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"VNA-000000ae","type":"SUB-VNA"},{"created_time":1586237081,"end_time":1744243199,"id":"1b6f68d5-1234-5678-90ab-70d3e6d18c73","modified_time":1586237081,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1586237097,"end_time":1744243199,"id":"1375c9bf-1234-5678-90ab-9c636708c89e","modified_time":1586237097,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"MAN-000000ba","type":"SUB-MAN"},{"created_time":1586237137,"end_time":1744243199,"id":"5974e979-1234-5678-90ab-438f833ec1c9","modified_time":1586237137,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"ENG-000000bb","type":"SUB-ENG"},{"created_time":1629947267,"end_time":1744243199,"id":"340a9cb3-1234-5678-90ab-b009344dbf3c","modified_time":1629947267,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":9,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"},{"created_time":1632941870,"end_time":1744156799,"id":"9b599b0f-1234-5678-90ab-406081b58e7f","modified_time":1632941870,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":10,"start_time":1632873600,"subscription_id":"ENG-000000bd","type":"SUB-ENG"},{"created_time":1632941882,"end_time":1744156799,"id":"d6d8ead3-1234-5678-90ab-98badeac7287","modified_time":1632941882,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":11,"remaining_quantity":9,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"}],"summary":{"SUB-ENG":18,"SUB-EX24":3,"SUB-MAN":22,"SUB-VNA":20}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsLicensesTestMoveOrDeleteMspLicenseToAnotherOrg tests the behavior of the MSPsLicenses +func TestMSPsLicensesTestMoveOrDeleteMspLicenseToAnotherOrg(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MspLicenseAction + errBody := json.Unmarshal([]byte(`{"op":"delete","subscription_id":"SUB-0000144"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := msPsLicenses.MoveOrDeleteMspLicenseToAnotherOrg(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsLicensesTestListMspOrgLicenses tests the behavior of the MSPsLicenses +func TestMSPsLicensesTestListMspOrgLicenses(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsLicenses.ListMspOrgLicenses(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"amendments":[{"created_time":1644684842,"end_time":1744156799,"id":"ff0a14f6-1234-5678-90ab-c8e64d4bc6c6","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1644684842,"end_time":1744156799,"id":"c1c28812-1234-5678-90ab-dc95680da61e","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"},{"created_time":1644684842,"end_time":1744243199,"id":"96c0a41f-1234-5678-90ab-afe74817e9fd","modified_time":1644684842,"quantity":-1,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"}],"entitled":{"SUB-ENG":26,"SUB-EX24":9,"SUB-MAN":26,"SUB-VNA":26},"licenses":[{"created_time":1555353534,"end_time":1586822399,"id":"693a41a6-1234-5678-90ab-f53dbd3a31c0","modified_time":1555353534,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":0,"start_time":1555286400,"subscription_id":"VNA-000000aa","type":"SUB-VNA"},{"created_time":1576132516,"end_time":1586822399,"id":"656607cf-1234-5678-90ab-fc9035614ea5","modified_time":1576132516,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":8,"remaining_quantity":0,"start_time":1576022400,"subscription_id":"VNA-000000ab","type":"SUB-VNA"},{"created_time":1579204568,"end_time":1730764800,"id":"db50d0bc-1234-5678-90ab-e439958cb06b","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"MAN-000000ac","type":"SUB-MAN"},{"created_time":1579204568,"end_time":1730764800,"id":"2ff9e84a-1234-5678-90ab-fb9ec0726e01","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"ENG-000000ad","type":"SUB-ENG"},{"created_time":1579204568,"end_time":1730764800,"id":"16df7ea6-1234-5678-90ab-78018cd4024d","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"VNA-000000ae","type":"SUB-VNA"},{"created_time":1586237081,"end_time":1744243199,"id":"1b6f68d5-1234-5678-90ab-70d3e6d18c73","modified_time":1586237081,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1586237097,"end_time":1744243199,"id":"1375c9bf-1234-5678-90ab-9c636708c89e","modified_time":1586237097,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"MAN-000000ba","type":"SUB-MAN"},{"created_time":1586237137,"end_time":1744243199,"id":"5974e979-1234-5678-90ab-438f833ec1c9","modified_time":1586237137,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"ENG-000000bb","type":"SUB-ENG"},{"created_time":1629947267,"end_time":1744243199,"id":"340a9cb3-1234-5678-90ab-b009344dbf3c","modified_time":1629947267,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":9,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"},{"created_time":1632941870,"end_time":1744156799,"id":"9b599b0f-1234-5678-90ab-406081b58e7f","modified_time":1632941870,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":10,"start_time":1632873600,"subscription_id":"ENG-000000bd","type":"SUB-ENG"},{"created_time":1632941882,"end_time":1744156799,"id":"d6d8ead3-1234-5678-90ab-98badeac7287","modified_time":1632941882,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":11,"remaining_quantity":9,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"}],"summary":{"SUB-ENG":18,"SUB-EX24":3,"SUB-MAN":22,"SUB-VNA":20}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_logo_test.go b/mistapi/ms_ps_logo_test.go new file mode 100644 index 00000000..b18635e5 --- /dev/null +++ b/mistapi/ms_ps_logo_test.go @@ -0,0 +1,37 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestMSPsLogoTestDeleteMspLogo tests the behavior of the MSPsLogo +func TestMSPsLogoTestDeleteMspLogo(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsLogo.DeleteMspLogo(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsLogoTestPostMspLogo tests the behavior of the MSPsLogo +func TestMSPsLogoTestPostMspLogo(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := msPsLogo.PostMspLogo(ctx, mspId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/ms_ps_logs_test.go b/mistapi/ms_ps_logs_test.go new file mode 100644 index 00000000..c8a24821 --- /dev/null +++ b/mistapi/ms_ps_logs_test.go @@ -0,0 +1,59 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsLogsTestListMspAuditLogs tests the behavior of the MSPsLogs +func TestMSPsLogsTestListMspAuditLogs(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := msPsLogs.ListMspAuditLogs(ctx, mspId, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"results":[{"admin_id":"72bfa2bd-e58a-4670-9d20-a1468f7a6f58","admin_name":"test@mistsys.com","id":"c6f9347b-b0a4-4a23-b927-fa9249f2ffb2","message":"TEST AUDIT","org_id":"469f6eca-6276-4993-bfeb-53cbbbba6f58","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1431382121}],"start":1428939600,"total":135}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsLogsTestCountMspAuditLogs tests the behavior of the MSPsLogs +func TestMSPsLogsTestCountMspAuditLogs(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.MspLogsCountDistinctEnum("admin_name") + apiResponse, err := msPsLogs.CountMspAuditLogs(ctx, mspId, &distinct) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_marvis_test.go b/mistapi/ms_ps_marvis_test.go new file mode 100644 index 00000000..dbd811fe --- /dev/null +++ b/mistapi/ms_ps_marvis_test.go @@ -0,0 +1,32 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsMarvisTestCountMspsMarvisActions tests the behavior of the MSPsMarvis +func TestMSPsMarvisTestCountMspsMarvisActions(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.MspMarvisSuggestionsCountDistinctEnum("org_id") + limit := int(100) + page := int(1) + apiResponse, err := msPsMarvis.CountMspsMarvisActions(ctx, mspId, &distinct, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"status","limit":1000,"results":[{"count":24,"status":"002e176a-0000-000-1111-002e208b20e1"},{"count":12,"status":"2d3f176a-0000-000-2222-002e208f176a"},{"count":15,"status":"08b2176a-0000-000-3333-002e208b2d3f"}],"total":3}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_org_groups_test.go b/mistapi/ms_ps_org_groups_test.go new file mode 100644 index 00000000..b1b32d0b --- /dev/null +++ b/mistapi/ms_ps_org_groups_test.go @@ -0,0 +1,122 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsOrgGroupsTestListMspOrgGroups tests the behavior of the MSPsOrgGroups +func TestMSPsOrgGroupsTestListMspOrgGroups(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsOrgGroups.ListMspOrgGroups(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgGroupsTestCreateMspOrgGroup tests the behavior of the MSPsOrgGroups +func TestMSPsOrgGroupsTestCreateMspOrgGroup(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Orggroup + errBody := json.Unmarshal([]byte(`{"name":"string","org_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsOrgGroups.CreateMspOrgGroup(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgGroupsTestDeleteMspOrgGroup tests the behavior of the MSPsOrgGroups +func TestMSPsOrgGroupsTestDeleteMspOrgGroup(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orggroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsOrgGroups.DeleteMspOrgGroup(ctx, mspId, orggroupId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsOrgGroupsTestGetMspOrgGroup tests the behavior of the MSPsOrgGroups +func TestMSPsOrgGroupsTestGetMspOrgGroup(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orggroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsOrgGroups.GetMspOrgGroup(ctx, mspId, orggroupId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgGroupsTestUpdateMspOrgGroup tests the behavior of the MSPsOrgGroups +func TestMSPsOrgGroupsTestUpdateMspOrgGroup(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orggroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := msPsOrgGroups.UpdateMspOrgGroup(ctx, mspId, orggroupId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_orgs_test.go b/mistapi/ms_ps_orgs_test.go new file mode 100644 index 00000000..64583872 --- /dev/null +++ b/mistapi/ms_ps_orgs_test.go @@ -0,0 +1,187 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsOrgsTestListMspOrgs tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestListMspOrgs(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsOrgs.ListMspOrgs(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgsTestCreateMspOrg tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestCreateMspOrg(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Org + errBody := json.Unmarshal([]byte(`{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":10}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsOrgs.CreateMspOrg(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgsTestManageMspOrgs tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestManageMspOrgs(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MspOrgChange + errBody := json.Unmarshal([]byte(`{"op":"assign","org_ids":["2b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := msPsOrgs.ManageMspOrgs(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsOrgsTestSearchMspOrgs tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestSearchMspOrgs(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + limit := int(100) + apiResponse, err := msPsOrgs.SearchMspOrgs(ctx, mspId, nil, nil, nil, nil, nil, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1614383378.4365287,"limit":10,"results":[{"msp_id":"d287e62f-0000-0000-0000-f2b9ba0a531f","name":"Test Org","num_aps":9,"num_sites":5,"num_switches":1,"num_unassigned_aps":1,"org_id":"bb1a8bf6-0000-0000-0000-8053a663cf65","sub_ana_required":9,"sub_ast_entitled":5,"sub_ast_required":3,"sub_eng_required":3,"sub_ex12_required":1,"sub_insufficient":true,"sub_man_required":9,"sub_vna_entitled":1,"timestamp":1614322563.513937,"trial_enabled":false,"usage_types":["sub_eng"]},{"msp_id":"d287e62f-0000-0000-0000-f2b9ba0a531f","name":"Rogue Test1","num_aps":1,"num_sites":1,"org_id":"0fb81690-0000-0000-0000-9596d1d1534f","sub_ana_entitled":1,"sub_ana_required":1,"sub_insufficient":false,"sub_man_entitled":1,"sub_man_required":1,"timestamp":1614309876.5009551}],"start":1613778578.4365668,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgsTestDeleteMspOrg tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestDeleteMspOrg(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsOrgs.DeleteMspOrg(ctx, mspId, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsOrgsTestGetMspOrg tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestGetMspOrg(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsOrgs.GetMspOrg(ctx, mspId, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgsTestUpdateMspOrg tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestUpdateMspOrg(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := msPsOrgs.UpdateMspOrg(ctx, mspId, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsOrgsTestListMspOrgStats tests the behavior of the MSPsOrgs +func TestMSPsOrgsTestListMspOrgStats(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := msPsOrgs.ListMspOrgStats(ctx, mspId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/ms_ps_sso_roles_test.go b/mistapi/ms_ps_sso_roles_test.go new file mode 100644 index 00000000..0c62e8dd --- /dev/null +++ b/mistapi/ms_ps_sso_roles_test.go @@ -0,0 +1,90 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestMSPsSSORolesTestListMspSsoRoles tests the behavior of the MSPsSSORoles +func TestMSPsSSORolesTestListMspSsoRoles(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSsoRoles.ListMspSsoRoles(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestMSPsSSORolesTestCreateMspSsoRole tests the behavior of the MSPsSSORoles +func TestMSPsSSORolesTestCreateMspSsoRole(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := msPsSsoRoles.CreateMspSsoRole(ctx, mspId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","privileges":[{"orggroup_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","role":"read","scope":"orggroup"}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSORolesTestDeleteMspSsoRole tests the behavior of the MSPsSSORoles +func TestMSPsSSORolesTestDeleteMspSsoRole(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoroleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsSsoRoles.DeleteMspSsoRole(ctx, mspId, ssoroleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsSSORolesTestUpdateMspSsoRole tests the behavior of the MSPsSSORoles +func TestMSPsSSORolesTestUpdateMspSsoRole(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoroleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := msPsSsoRoles.UpdateMspSsoRole(ctx, mspId, ssoroleId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","privileges":[{"orggroup_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","role":"read","scope":"orggroup"}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_sso_test.go b/mistapi/ms_ps_sso_test.go new file mode 100644 index 00000000..439e7aeb --- /dev/null +++ b/mistapi/ms_ps_sso_test.go @@ -0,0 +1,192 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsSSOTestListMspSsos tests the behavior of the MSPsSSO +func TestMSPsSSOTestListMspSsos(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSso.ListMspSsos(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestCreateMspSso tests the behavior of the MSPsSSO +func TestMSPsSSOTestCreateMspSso(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := msPsSso.CreateMspSso(ctx, mspId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestDeleteMspSso tests the behavior of the MSPsSSO +func TestMSPsSSOTestDeleteMspSso(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPsSso.DeleteMspSso(ctx, mspId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsSSOTestGetMspSso tests the behavior of the MSPsSSO +func TestMSPsSSOTestGetMspSso(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSso.GetMspSso(ctx, mspId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestUpdateMspSso tests the behavior of the MSPsSSO +func TestMSPsSSOTestUpdateMspSso(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Sso + errBody := json.Unmarshal([]byte(`{"custom_logout_url":"string","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","name":"string","nameid_format":"email"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPsSso.UpdateMspSso(ctx, mspId, ssoId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestListMspSsoLatestFailures tests the behavior of the MSPsSSO +func TestMSPsSSOTestListMspSsoLatestFailures(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSso.ListMspSsoLatestFailures(ctx, mspId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"detail":"string","saml_assertion_xml":"string","timestamp":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestGetMspSsoSamlMetadata tests the behavior of the MSPsSSO +func TestMSPsSSOTestGetMspSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSso.GetMspSsoSamlMetadata(ctx, mspId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"acs_url":"https://api.mist.com/api/v1/saml/llDfa13f/login","entity_id":"https://api.mist.com/api/v1/saml/llDfa13f/login","logout_url":"https://api.mist.com/api/v1/saml/llDfa13f/logout","metadata_xml":"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsSSOTestDownloadMspSsoSamlMetadata tests the behavior of the MSPsSSO +func TestMSPsSSOTestDownloadMspSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPsSso.DownloadMspSsoSamlMetadata(ctx, mspId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/ms_ps_test.go b/mistapi/ms_ps_test.go new file mode 100644 index 00000000..168af887 --- /dev/null +++ b/mistapi/ms_ps_test.go @@ -0,0 +1,116 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsTestCreateMsp tests the behavior of the MSPs +func TestMSPsTestCreateMsp(t *testing.T) { + ctx := context.Background() + var body models.Msp + errBody := json.Unmarshal([]byte(`{"name":"MSP"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPs.CreateMsp(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsTestDeleteMsp tests the behavior of the MSPs +func TestMSPsTestDeleteMsp(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := msPs.DeleteMsp(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestMSPsTestGetMspDetails tests the behavior of the MSPs +func TestMSPsTestGetMspDetails(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := msPs.GetMspDetails(ctx, mspId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsTestUpdateMsp tests the behavior of the MSPs +func TestMSPsTestUpdateMsp(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Msp + errBody := json.Unmarshal([]byte(`{"name":"MSP"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := msPs.UpdateMsp(ctx, mspId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsTestSearchMspOrgGroup tests the behavior of the MSPs +func TestMSPsTestSearchMspOrgGroup(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.MspSearchTypeEnum("orgs") + q := "search" + limit := int(100) + + + duration := "1d" + apiResponse, err := msPs.SearchMspOrgGroup(ctx, mspId, mType, &q, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"limit":0,"page":0,"results":[{"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","text":"string","type":"string"}],"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/ms_ps_tickets_test.go b/mistapi/ms_ps_tickets_test.go new file mode 100644 index 00000000..054117a4 --- /dev/null +++ b/mistapi/ms_ps_tickets_test.go @@ -0,0 +1,53 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestMSPsTicketsTestListMspTickets tests the behavior of the MSPsTickets +func TestMSPsTicketsTestListMspTickets(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := msPsTickets.ListMspTickets(ctx, mspId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestMSPsTicketsTestCountMspTickets tests the behavior of the MSPsTickets +func TestMSPsTicketsTestCountMspTickets(t *testing.T) { + ctx := context.Background() + mspId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.MspTicketsCountDistinctEnum("status") + apiResponse, err := msPsTickets.CountMspTickets(ctx, mspId, &distinct) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_admins_test.go b/mistapi/orgs_admins_test.go new file mode 100644 index 00000000..3a62b912 --- /dev/null +++ b/mistapi/orgs_admins_test.go @@ -0,0 +1,137 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAdminsTestListOrgAdmins tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestListOrgAdmins(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsAdmins.ListOrgAdmins(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"admin_id":"456b7016-a916-a4b1-78dd-72b947c152b7","email":"jsmith@mycorp.org","first_name":"Joe","last_name":"Smith","privileges":[{"role":"admin","scope":"msp"},{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","role":"admin","scope":"org"},{"orggroup_ids":["507f1bab-13ba-73e2-f291-2bcb8d1362b0"],"role":"read","scope":"orggroup"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAdminsTestRevokeOrgAdmin tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestRevokeOrgAdmin(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + adminId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAdmins.RevokeOrgAdmin(ctx, orgId, adminId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAdminsTestUpdateOrgAdmin tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestUpdateOrgAdmin(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + adminId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"jsnow@abc.com","expire_time":0,"first_name":"John","hours":24,"last_name":"Sno","phone":"string","phone2":"string","privileges":[{"msp_id":"c0cf23fc-d82f-4219-988c-82fb61d8c875","name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","org_name":"string","orggroup_ids":["497f6eca-6276-4993-bfeb-53d5bbba6f08"],"role":"admin","scope":"org","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","sitegroup_ids":["497f6eca-6276-4993-bfeb-53d6bbba6f08"],"views":"switch_admin"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAdmins.UpdateOrgAdmin(ctx, orgId, adminId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAdminsTestInviteOrgAdmin tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestInviteOrgAdmin(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAdmins.InviteOrgAdmin(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAdminsTestUninviteOrgAdmin tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestUninviteOrgAdmin(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + inviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAdmins.UninviteOrgAdmin(ctx, orgId, inviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAdminsTestUpdateOrgAdminInvite tests the behavior of the OrgsAdmins +func TestOrgsAdminsTestUpdateOrgAdminInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + inviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAdmins.UpdateOrgAdminInvite(ctx, orgId, inviteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_alarm_templates_test.go b/mistapi/orgs_alarm_templates_test.go new file mode 100644 index 00000000..5d5ad650 --- /dev/null +++ b/mistapi/orgs_alarm_templates_test.go @@ -0,0 +1,170 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAlarmTemplatesTestListOrgAlarmTemplates tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestListOrgAlarmTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsAlarmTemplates.ListOrgAlarmTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAlarmTemplatesTestCreateOrgAlarmTemplate tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestCreateOrgAlarmTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsAlarmTemplates.CreateOrgAlarmTemplate(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAlarmTemplatesTestUnsuppressOrgSuppressedAlarms tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestUnsuppressOrgSuppressedAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAlarmTemplates.UnsuppressOrgSuppressedAlarms(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmTemplatesTestListOrgSuppressedAlarms tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestListOrgSuppressedAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + scope := models.SuppressedAlarmScopeEnum("site") + apiResponse, err := orgsAlarmTemplates.ListOrgSuppressedAlarms(ctx, orgId, &scope) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"duration":48,"site_id":"581328b6-e382-f54e-c9dc-9c998d183a34"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAlarmTemplatesTestSuppressOrgAlarm tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestSuppressOrgAlarm(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SuppressedAlarm + errBody := json.Unmarshal([]byte(`{"duration":3600,"scheduled_time":1678232980,"scope":"org"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarmTemplates.SuppressOrgAlarm(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmTemplatesTestDeleteOrgAlarmTemplate tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestDeleteOrgAlarmTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmtemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAlarmTemplates.DeleteOrgAlarmTemplate(ctx, orgId, alarmtemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmTemplatesTestGetOrgAlarmTemplate tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestGetOrgAlarmTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmtemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsAlarmTemplates.GetOrgAlarmTemplate(ctx, orgId, alarmtemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAlarmTemplatesTestUpdateOrgAlarmTemplate tests the behavior of the OrgsAlarmTemplates +func TestOrgsAlarmTemplatesTestUpdateOrgAlarmTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmtemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AlarmTemplate + errBody := json.Unmarshal([]byte(`{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"name":"string","rules":{"adhoc_network":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"air_magnet_scan":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"ap_offline":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"bad_cable":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"beacon_flood":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"bssid_spoofing":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"device_down":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"device_restarted":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"dhcp_failure":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"disassociation_flood":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"dot1x_failure":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"eap_dictionary_attack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"eap_failure_injection":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"eap_handshake_flood":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"eap_spoofed_success":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"eapol_logoff_attack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"essid_jack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"excessive_client":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"excessive_eapol_start":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"gateway_down":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"gw_bad_cable":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"gw_negotiation_mismatch":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"honeypot_ssid":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"krack_attack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"missing_vlan":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"monkey_jack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"negotiation_mismatch":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"non_compliant":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"out_of_sequence":{"enabled":true},"psk_failure":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"repeated_auth_failures":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"rogue_ap":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"rogue_client":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"secpolicy_violation":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"ssid_injection":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"switch_down":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"tkip_icv_attack":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"vendor_ie_missing":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"watched_station":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true},"zero_ssid_association":{"delivery":{"additional_emails":["string"],"enabled":true,"to_org_admins":true,"to_site_admins":true},"enabled":true}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAlarmTemplates.UpdateOrgAlarmTemplate(ctx, orgId, alarmtemplateId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_alarms_test.go b/mistapi/orgs_alarms_test.go new file mode 100644 index 00000000..630e7fda --- /dev/null +++ b/mistapi/orgs_alarms_test.go @@ -0,0 +1,159 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAlarmsTestAckOrgMultipleAlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestAckOrgMultipleAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Alarms + errBody := json.Unmarshal([]byte(`{"alarm_ids":["ccb8c94d-ca56-4075-932f-1f2ab444ff2c","98ff4a3d-ec9b-4138-a42e-54fc3335179d"],"note":"maintenance window"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarms.AckOrgMultipleAlarms(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmsTestAckOrgAllAlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestAckOrgAllAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NoteString + errBody := json.Unmarshal([]byte(`{"note":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarms.AckOrgAllAlarms(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmsTestCountOrgAlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestCountOrgAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsAlarms.CountOrgAlarms(ctx, orgId, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAlarmsTestSearchOrgAlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestSearchOrgAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsAlarms.SearchOrgAlarms(ctx, orgId, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAlarmsTestUnackOrgMultipleAlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestUnackOrgMultipleAlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Alarms + errBody := json.Unmarshal([]byte(`{"alarm_ids":["ccb8c94d-ca56-4075-932f-1f2ab444ff2c","98ff4a3d-ec9b-4138-a42e-54fc3335179d"],"note":"maintenance window"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarms.UnackOrgMultipleAlarms(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmsTestUnackOrgAllArlarms tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestUnackOrgAllArlarms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NoteString + errBody := json.Unmarshal([]byte(`{"note":"maintenance window"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarms.UnackOrgAllArlarms(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAlarmsTestAckOrgAlarm tests the behavior of the OrgsAlarms +func TestOrgsAlarmsTestAckOrgAlarm(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NoteString + errBody := json.Unmarshal([]byte(`{"note":"maintenance window"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsAlarms.AckOrgAlarm(ctx, orgId, alarmId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_antivirus_profiles_test.go b/mistapi/orgs_antivirus_profiles_test.go new file mode 100644 index 00000000..22a23304 --- /dev/null +++ b/mistapi/orgs_antivirus_profiles_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAntivirusProfilesTestListOrgAntivirusProfiles tests the behavior of the OrgsAntivirusProfiles +func TestOrgsAntivirusProfilesTestListOrgAntivirusProfiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsAntivirusProfiles.ListOrgAntivirusProfiles(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAntivirusProfilesTestCreateOrgAntivirusProfile tests the behavior of the OrgsAntivirusProfiles +func TestOrgsAntivirusProfilesTestCreateOrgAntivirusProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Avprofile + errBody := json.Unmarshal([]byte(`{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAntivirusProfiles.CreateOrgAntivirusProfile(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAntivirusProfilesTestDeleteOrgAntivirusProfile tests the behavior of the OrgsAntivirusProfiles +func TestOrgsAntivirusProfilesTestDeleteOrgAntivirusProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + avprofilesId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAntivirusProfiles.DeleteOrgAntivirusProfile(ctx, orgId, avprofilesId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAntivirusProfilesTestGetOrgAntivirusProfile tests the behavior of the OrgsAntivirusProfiles +func TestOrgsAntivirusProfilesTestGetOrgAntivirusProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + avprofilesId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsAntivirusProfiles.GetOrgAntivirusProfile(ctx, orgId, avprofilesId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAntivirusProfilesTestUpdateOrgAntivirusProfile tests the behavior of the OrgsAntivirusProfiles +func TestOrgsAntivirusProfilesTestUpdateOrgAntivirusProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + avprofilesId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Avprofile + errBody := json.Unmarshal([]byte(`{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAntivirusProfiles.UpdateOrgAntivirusProfile(ctx, orgId, avprofilesId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"fallback_action":"permit","max_filesize":10000,"mime_whitelist":[],"name":"av-custom","protocols":[],"url_whitelist":[]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_ap_templates_test.go b/mistapi/orgs_ap_templates_test.go new file mode 100644 index 00000000..369e2a0c --- /dev/null +++ b/mistapi/orgs_ap_templates_test.go @@ -0,0 +1,57 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAPTemplatesTestListOrgAptemplates tests the behavior of the OrgsAPTemplates +func TestOrgsAPTemplatesTestListOrgAptemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsApTemplates.ListOrgAptemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"ap_matching":{"enabled":true,"rules":[{"match_model":"string","name":"string","port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}}}]},"created_time":0,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53cbbbba9f08","modified_time":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":true,"enable_arp_spoof":true,"enable_shared_radio_scanning":false,"enabled":true,"locate_connected":false,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":true,"mesh_enabled":true,"proxy_arp":false}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAPTemplatesTestCreateOrgAptemplate tests the behavior of the OrgsAPTemplates +func TestOrgsAPTemplatesTestCreateOrgAptemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.ApTemplate + errBody := json.Unmarshal([]byte(`{"ap_matching":{"enabled":true,"rules":[{"match_model":"string","name":"string","port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}}}]},"wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":true,"enable_arp_spoof":true,"enable_shared_radio_scanning":false,"enabled":true,"locate_connected":false,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":true,"mesh_enabled":true,"proxy_arp":false}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsApTemplates.CreateOrgAptemplate(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ap_matching":{"enabled":true,"rules":[{"match_model":"string","name":"string","port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}}}]},"created_time":0,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53cbbbba8f08","modified_time":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":true,"enable_arp_spoof":true,"enable_shared_radio_scanning":false,"enabled":true,"locate_connected":false,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":true,"mesh_enabled":true,"proxy_arp":false}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_api_tokens_test.go b/mistapi/orgs_api_tokens_test.go new file mode 100644 index 00000000..a41d0cb9 --- /dev/null +++ b/mistapi/orgs_api_tokens_test.go @@ -0,0 +1,122 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAPITokensTestListOrgApiTokens tests the behavior of the OrgsAPITokens +func TestOrgsAPITokensTestListOrgApiTokens(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsApiTokens.ListOrgApiTokens(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_by":"user@mycorp.com","created_time":1626875902,"id":"497f6eca-6276-4993-bfeb-53f0bbba6f08","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","privileges":[{"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","role":"admin","scope":"org"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAPITokensTestCreateOrgApiToken tests the behavior of the OrgsAPITokens +func TestOrgsAPITokensTestCreateOrgApiToken(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsApiTokens.CreateOrgApiToken(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_by":"user@mycorp.com","created_time":1626875902,"id":"497f6eca-6276-4993-bfeb-53efbbba6f08","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","privileges":[{"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","role":"admin","scope":"org"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAPITokensTestDeleteOrgApiToken tests the behavior of the OrgsAPITokens +func TestOrgsAPITokensTestDeleteOrgApiToken(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsApiTokens.DeleteOrgApiToken(ctx, orgId, apitokenId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAPITokensTestGetOrgApiToken tests the behavior of the OrgsAPITokens +func TestOrgsAPITokensTestGetOrgApiToken(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsApiTokens.GetOrgApiToken(ctx, orgId, apitokenId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_by":"user@mycorp.com","created_time":1626875902,"id":"497f6eca-6276-4993-bfeb-53efbbba6f08","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","privileges":[{"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","role":"admin","scope":"org"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAPITokensTestUpdateOrgApiToken tests the behavior of the OrgsAPITokens +func TestOrgsAPITokensTestUpdateOrgApiToken(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OrgApitoken + errBody := json.Unmarshal([]byte(`{"name":"org_token_xyz","privileges":[{"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","role":"admin","scope":"org"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsApiTokens.UpdateOrgApiToken(ctx, orgId, apitokenId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_by":"user@mycorp.com","created_time":1626875902,"id":"497f6eca-6276-4993-bfeb-53efbbba6f08","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","privileges":[{"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","role":"admin","scope":"org"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_asset_filters_test.go b/mistapi/orgs_asset_filters_test.go new file mode 100644 index 00000000..b8ecccea --- /dev/null +++ b/mistapi/orgs_asset_filters_test.go @@ -0,0 +1,126 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsAssetFiltersTestListOrgAssetFilters tests the behavior of the OrgsAssetFilters +func TestOrgsAssetFiltersTestListOrgAssetFilters(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsAssetFilters.ListOrgAssetFilters(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAssetFiltersTestCreateOrgAssetFilters tests the behavior of the OrgsAssetFilters +func TestOrgsAssetFiltersTestCreateOrgAssetFilters(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AssetFilter + errBody := json.Unmarshal([]byte(`{"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","mfg_company_id":0,"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAssetFilters.CreateOrgAssetFilters(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAssetFiltersTestDeleteOrgAssetFilter tests the behavior of the OrgsAssetFilters +func TestOrgsAssetFiltersTestDeleteOrgAssetFilter(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAssetFilters.DeleteOrgAssetFilter(ctx, orgId, assetfilterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAssetFiltersTestGetOrgAssetFilter tests the behavior of the OrgsAssetFilters +func TestOrgsAssetFiltersTestGetOrgAssetFilter(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsAssetFilters.GetOrgAssetFilter(ctx, orgId, assetfilterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAssetFiltersTestUpdateOrgAssetFilters tests the behavior of the OrgsAssetFilters +func TestOrgsAssetFiltersTestUpdateOrgAssetFilters(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AssetFilter + errBody := json.Unmarshal([]byte(`{"disabled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab2","mfg_company_id":0,"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsAssetFilters.UpdateOrgAssetFilters(ctx, orgId, assetfilterId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_assets_test.go b/mistapi/orgs_assets_test.go new file mode 100644 index 00000000..07173f4c --- /dev/null +++ b/mistapi/orgs_assets_test.go @@ -0,0 +1,149 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsAssetsTestListOrgAssets tests the behavior of the OrgsAssets +func TestOrgsAssetsTestListOrgAssets(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsAssets.ListOrgAssets(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsAssetsTestCreateOrgAsset tests the behavior of the OrgsAssets +func TestOrgsAssetsTestCreateOrgAsset(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsAssets.CreateOrgAsset(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAssetsTestImportOrgAssets tests the behavior of the OrgsAssets +func TestOrgsAssetsTestImportOrgAssets(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsAssets.ImportOrgAssets(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAssetsTestDeleteOrgAsset tests the behavior of the OrgsAssets +func TestOrgsAssetsTestDeleteOrgAsset(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAssets.DeleteOrgAsset(ctx, orgId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsAssetsTestDeleteOrgAsset1 tests the behavior of the OrgsAssets +func TestOrgsAssetsTestDeleteOrgAsset1(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsAssets.DeleteOrgAsset(ctx, orgId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 201) +} + +// TestOrgsAssetsTestGetOrgAsset tests the behavior of the OrgsAssets +func TestOrgsAssetsTestGetOrgAsset(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsAssets.GetOrgAsset(ctx, orgId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsAssetsTestUpdateOrgAsset tests the behavior of the OrgsAssets +func TestOrgsAssetsTestUpdateOrgAsset(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsAssets.UpdateOrgAsset(ctx, orgId, assetId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_cert_test.go b/mistapi/orgs_cert_test.go new file mode 100644 index 00000000..771942c6 --- /dev/null +++ b/mistapi/orgs_cert_test.go @@ -0,0 +1,83 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsCertTestGetOrgCertificates tests the behavior of the OrgsCert +func TestOrgsCertTestGetOrgCertificates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsCert.GetOrgCertificates(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cert":"-----BEGIN CERTIFICATE-----\nMIIowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsCertTestClearOrgCertificates tests the behavior of the OrgsCert +func TestOrgsCertTestClearOrgCertificates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsCert.ClearOrgCertificates(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cert":"-----BEGIN CERTIFICATE-----\nMIIowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsCertTestTruncateOrgCrlFile tests the behavior of the OrgsCert +func TestOrgsCertTestTruncateOrgCrlFile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsCert.TruncateOrgCrlFile(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsCertTestGetOrgSslProxyCert tests the behavior of the OrgsCert +func TestOrgsCertTestGetOrgSslProxyCert(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsCert.GetOrgSslProxyCert(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cert":"-----BEGIN CERTIFICATE-----\\nMIIowDQYJKoZIhvcNAQELBQE\\n-----END CERTIFICATE-----"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_clients_marvis_test.go b/mistapi/orgs_clients_marvis_test.go new file mode 100644 index 00000000..e52394cd --- /dev/null +++ b/mistapi/orgs_clients_marvis_test.go @@ -0,0 +1,126 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsMarvisTestListOrgMarvisClientInvites tests the behavior of the OrgsClientsMarvis +func TestOrgsClientsMarvisTestListOrgMarvisClientInvites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsClientsMarvis.ListOrgMarvisClientInvites(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"3a14098f-b995-7552-b0a4-b8ee39b337a6”","name":"Handhelds"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsMarvisTestCreateOrgMarvisClientInvites tests the behavior of the OrgsClientsMarvis +func TestOrgsClientsMarvisTestCreateOrgMarvisClientInvites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MarvisClient + errBody := json.Unmarshal([]byte(`{"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsClientsMarvis.CreateOrgMarvisClientInvites(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"3a14098f-b995-7552-b0a4-b8ee39b337a6”","name":"Handhelds"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsMarvisTestDeleteOrgMarvisClientInvite tests the behavior of the OrgsClientsMarvis +func TestOrgsClientsMarvisTestDeleteOrgMarvisClientInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + marvisinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsClientsMarvis.DeleteOrgMarvisClientInvite(ctx, orgId, marvisinviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsClientsMarvisTestGetOrgMarvisClientInvites tests the behavior of the OrgsClientsMarvis +func TestOrgsClientsMarvisTestGetOrgMarvisClientInvites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + marvisinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsClientsMarvis.GetOrgMarvisClientInvites(ctx, orgId, marvisinviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"3a14098f-b995-7552-b0a4-b8ee39b337a6”","name":"Handhelds"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsMarvisTestUpdateOrgMarvisClientInvite tests the behavior of the OrgsClientsMarvis +func TestOrgsClientsMarvisTestUpdateOrgMarvisClientInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + marvisinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MarvisClient + errBody := json.Unmarshal([]byte(`{"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsClientsMarvis.UpdateOrgMarvisClientInvite(ctx, orgId, marvisinviteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"3a14098f-b995-7552-b0a4-b8ee39b337a6”","name":"Handhelds"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_clients_nac_test.go b/mistapi/orgs_clients_nac_test.go new file mode 100644 index 00000000..cf747b0d --- /dev/null +++ b/mistapi/orgs_clients_nac_test.go @@ -0,0 +1,161 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsNACTestCountOrgNacClients tests the behavior of the OrgsClientsNAC +func TestOrgsClientsNACTestCountOrgNacClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgNacClientsCountDistinctEnum("type") + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsNac.CountOrgNacClients(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsNACTestCountOrgNacClientEvents tests the behavior of the OrgsClientsNAC +func TestOrgsClientsNACTestCountOrgNacClientEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsClientsNac.CountOrgNacClientEvents(ctx, orgId, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsNACTestSearchOrgNacClientEvents tests the behavior of the OrgsClientsNAC +func TestOrgsClientsNACTestSearchOrgNacClientEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsClientsNac.SearchOrgNacClientEvents(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513176951,"limit":10,"results":[{"ap":"5c5b35513227","auth_type":"eap-ttls","bssid":"5c5b355fafcc","dryrun_nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264012","dryrun_nacrule_matched":true,"idp_id":"912ef72e-2239-4996-b81e-469e87a27cd6","idp_role":["itsuperusers","vip"],"mac":"ac3eb179e535","nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264c62","nacrule_matched":true,"nas_vendor":"juniper-mist","org_id":"27547ac2-d114-4e04-beb1-f3f1e6e81ec6","random_mac":false,"resp_attrs":["Tunnel-Type=VLAN","Tunnel-Medium-Type=IEEE-802","Tunnel-Private-Group-Id=750","User-Name=anonymous"],"site_id":"441a1214-6928-442a-8e92-e1d34b8ec6a6","ssid":"mist_nac","timestamp":1691512031.3581879,"type":"NAC_CLIENT_PERMIT","username":"user@deaflyz.net","vlan":"750"}],"start":1512572151,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsNACTestSearchOrgNacClients tests the behavior of the OrgsClientsNAC +func TestOrgsClientsNACTestSearchOrgNacClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsNac.SearchOrgNacClients(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513362753,"limit":3,"results":[{"ap":["5c5b35bf16bb","d4dc090041b4"],"auth_type":"eap-tls","cert_cn":["string"],"cert_issuer":["string"],"idp_id":"string","idp_role":["string"],"last_ap":"string","last_cert_cn":"string","last_cert_expiry":0,"last_cert_issuer":"string","last_nacrule_id":"string","last_nacrule_name":"string","last_nas_vendor":"string","last_ssid":"string","last_status":"string","mac":"string","nacrule_id":["string"],"nacrule_matched":true,"nacrule_name":["string"],"nas_vendor":["string"],"org_id":"31f27122-68a9-47a4-b526-8fb8a62a8acb","random_mac":true,"site_id":"832b1d74-9531-409b-ae37-4d7f3edbde92","ssid":["string"],"timestamp":1694689718.612,"type":"wireless"}],"start":1513276353,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_clients_sdk_test.go b/mistapi/orgs_clients_sdk_test.go new file mode 100644 index 00000000..b5a763e9 --- /dev/null +++ b/mistapi/orgs_clients_sdk_test.go @@ -0,0 +1,33 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsSDKTestUpdateSdkClient tests the behavior of the OrgsClientsSDK +func TestOrgsClientsSDKTestUpdateSdkClient(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkclientId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NameString + errBody := json.Unmarshal([]byte(`{"name":"John Smith"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsClientsSdk.UpdateSdkClient(ctx, orgId, sdkclientId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_clients_wan_test.go b/mistapi/orgs_clients_wan_test.go new file mode 100644 index 00000000..8fd1b8e9 --- /dev/null +++ b/mistapi/orgs_clients_wan_test.go @@ -0,0 +1,122 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsWanTestCountOrgWanClientEvents tests the behavior of the OrgsClientsWan +func TestOrgsClientsWanTestCountOrgWanClientEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgWanClientsEventsCountDistinctEnum("type") + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsClientsWan.CountOrgWanClientEvents(ctx, orgId, &distinct, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWanTestCountOrgWanClients tests the behavior of the OrgsClientsWan +func TestOrgsClientsWanTestCountOrgWanClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgWanClientsCountDistinctEnum("mac") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsWan.CountOrgWanClients(ctx, orgId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWanTestSearchOrgWanClientEvents tests the behavior of the OrgsClientsWan +func TestOrgsClientsWanTestSearchOrgWanClientEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsClientsWan.SearchOrgWanClientEvents(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":{"When":"2022-12-31 23:59:59.293000+00:00","ev_type":"CLIENT_IP_ASSIGNED","metadata":{},"org_id":"b0b9f142-aaba-11e6-aafc-0242ac110002","random_mac":true,"site_id":"fc656275-b157-43fd-b922-5f4f341c19bf","text":"DHCP Ack IP 192.168.88.216","wcid":"62bbfb75-10d8-49d1-dec7-d2df91624287"},"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWanTestSearchOrgWanClients tests the behavior of the OrgsClientsWan +func TestOrgsClientsWanTestSearchOrgWanClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsWan.SearchOrgWanClients(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"When":"2022-12-31T23:59:43.497+0000","hostname":["sonoszp"],"ip":["192.168.1.139"],"last_hostname":"sonoszp","last_ip":"192.168.1.139","mfg":"Sonos","org_id":"b4e16c72-d50e-4c03-a952-a3217e231e2c","site_id":"f688779c-e335-4f88-8d7c-9c5e9964528b","wcid":"8bbe7389-212b-c65d-2208-00fab2017936"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_clients_wired_test.go b/mistapi/orgs_clients_wired_test.go new file mode 100644 index 00000000..dd765d1a --- /dev/null +++ b/mistapi/orgs_clients_wired_test.go @@ -0,0 +1,68 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsWiredTestCountOrgWiredClients tests the behavior of the OrgsClientsWired +func TestOrgsClientsWiredTestCountOrgWiredClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgWiredClientsCountDistinctEnum("mac") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsWired.CountOrgWiredClients(ctx, orgId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWiredTestSearchOrgWiredClients tests the behavior of the OrgsClientsWired +func TestOrgsClientsWiredTestSearchOrgWiredClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsClientsWired.SearchOrgWiredClients(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1648529800.8221116,"limit":1000,"results":[{"device_mac":["001122334455"],"device_mac_port":[{"device_mac":"001122334455","ip":"","port_id":"et-0/0/1","port_parent":"","start":"2020-12-10T00:07:36.262+0000","vlan":1,"when":"2022-03-29T04:56:05.172+0000"}],"ip":["11.216.202.61"],"mac":"112233445566","org_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","port_id":["et-0/0/1"],"site_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","timestamp":1571174567.807,"vlan":[0,1001]}],"start":1648443400.8221116,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_clients_wireless_test.go b/mistapi/orgs_clients_wireless_test.go new file mode 100644 index 00000000..ed5c540b --- /dev/null +++ b/mistapi/orgs_clients_wireless_test.go @@ -0,0 +1,182 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsClientsWirelessTestCountOrgWirelessClients tests the behavior of the OrgsClientsWireless +func TestOrgsClientsWirelessTestCountOrgWirelessClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgClientsCountDistinctEnum("device") + + + + + + + + + ipAddress := "192.168.1.1" + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsWireless.CountOrgWirelessClients(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, &ipAddress, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWirelessTestSearchOrgWirelessClientEvents tests the behavior of the OrgsClientsWireless +func TestOrgsClientsWirelessTestSearchOrgWirelessClientEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsClientsWireless.SearchOrgWirelessClientEvents(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"ap":"string","band":"24","bssid":"string","channel":0,"proto":"a","ssid":"string","text":"string","timestamp":0,"type":"string","type_code":0,"wlan_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWirelessTestSearchOrgWirelessClients tests the behavior of the OrgsClientsWireless +func TestOrgsClientsWirelessTestSearchOrgWirelessClients(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + ipAddress := "192.168.1.1" + + + + + + pskId := "000000ab-00ab-00ab-00ab-0000000000ab" + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsClientsWireless.SearchOrgWirelessClients(ctx, orgId, nil, nil, &ipAddress, nil, nil, nil, nil, nil, &pskId, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":17141231418.812,"limit":118,"next":"next8","results":[{"ap":["a83a79a947ee","003e73170b4c"],"app_version":["0.100.3"],"band":"5","device":["Mac"],"ftc":false,"hardware":"Apple Wi-Fi adapter","hostname":["hostname-a","hostname-b"],"ip":["10.5.23.43","192.168.0.2"],"last_ap":"a83a79a947ee","last_devuce":"Mac","last_firmware":"wl0: Jan 20 2024 04:08:41 version 20.103.12.0.8.7.171 FWID 01-e09d2675","last_hostname":"hostname-a","last_ip":"10.5.23.43","last_model":"MBP 16\\\" M1 2021","last_os":"Sonoma","last_os_version":"14.4.1 (Build 23E224)","last_psk_id":"abf7dc5c-bb51-4bb7-93b6-5547400ffe11","last_psk_name":"iot","last_ssid":"IoT SSID","last_username":"user@corp.com","last_vlan":10,"last_wlan_id":"e5d67b07-aae8-494b-8584-cbc20c8110aa","mac":"bcd074000000","mfg":"Apple","model":"MBP 16\\\" M1 2021","org_id":"1abff1aa-4571-4c1f-a409-153a1e7a7a24","os":["Sonoma"],"os_version":["14.4.1 (Build 23E224)"],"protocol":"ax","psk_id":["abf7dc5c-bb51-4bb7-93b6-5547400ffe11"],"psk_name":["iot"],"sdk_version":["0.100.3"],"site_id":"25ff5219-9be7-4db9-907d-0c9b60445147","site_ids":["25ff5219-9be7-4db9-907d-0c9b60445147"],"ssid":["IoT SSID"],"timestamp":1714124722.113,"username":["user@corp.com"],"vlan":[10]}],"start":10,"total":44}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWirelessTestCountOrgWirelessClientsSessions tests the behavior of the OrgsClientsWireless +func TestOrgsClientsWirelessTestCountOrgWirelessClientsSessions(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgClientSessionsCountDistinctEnum("device") + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsClientsWireless.CountOrgWirelessClientsSessions(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsClientsWirelessTestSearchOrgWirelessClientSessions tests the behavior of the OrgsClientsWireless +func TestOrgsClientsWirelessTestSearchOrgWirelessClientSessions(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + pskId := "000000ab-00ab-00ab-00ab-0000000000ab" + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsClientsWireless.SearchOrgWirelessClientSessions(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, &pskId, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513177200,"limit":10,"results":[{"ap":"5c5b350e0262","band":"5","client_manufacture":"Apple","connect":1565208388,"disconnect":1565208448,"duration":60.09423865,"mac":"b019c66c8348","org_id":"3139f2c2-fac6-11e5-8156-0242ac110006","site_id":"70e0f468-fc13-11e5-85ad-0242ac110008","ssid":"Dummy WLAN 2","tags":["disassociate"],"timestamp":1565208448.662,"wlan_id":"99bb4c74-f954-4f36-b844-6b030faffabc"}],"start":1511967600,"total":100}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_cradlepoint_test.go b/mistapi/orgs_cradlepoint_test.go new file mode 100644 index 00000000..a0a4183f --- /dev/null +++ b/mistapi/orgs_cradlepoint_test.go @@ -0,0 +1,72 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsCradlepointTestDeleteOrgCradlepointConnection tests the behavior of the OrgsCradlepoint +func TestOrgsCradlepointTestDeleteOrgCradlepointConnection(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsCradlepoint.DeleteOrgCradlepointConnection(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsCradlepointTestSetupOrgCradlepointConnectionToMist tests the behavior of the OrgsCradlepoint +func TestOrgsCradlepointTestSetupOrgCradlepointConnectionToMist(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsCradlepoint.SetupOrgCradlepointConnectionToMist(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsCradlepointTestUpdateOrgCradlepointConnectionToMist tests the behavior of the OrgsCradlepoint +func TestOrgsCradlepointTestUpdateOrgCradlepointConnectionToMist(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AccountCradlepointConfig + errBody := json.Unmarshal([]byte(`{"cp_api_id":"84446d61-2206-4ea5-855a-0043f980be54","cp_api_key":"79c329da9893e34099c7d8ad5cb9c941","ecm_api_id":"73446d61-2206-4ea5-855a-0043f980be62","ecm_api_key":"68b329da9893e34099c7d8ad5cb9c9405"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsCradlepoint.UpdateOrgCradlepointConnectionToMist(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsCradlepointTestSyncOrgCradlepointRouters tests the behavior of the OrgsCradlepoint +func TestOrgsCradlepointTestSyncOrgCradlepointRouters(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsCradlepoint.SyncOrgCradlepointRouters(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_crl_test.go b/mistapi/orgs_crl_test.go new file mode 100644 index 00000000..4c383a4b --- /dev/null +++ b/mistapi/orgs_crl_test.go @@ -0,0 +1,26 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsCRLTestGetOrgCrlFile tests the behavior of the OrgsCRL +func TestOrgsCRLTestGetOrgCrlFile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsCrl.GetOrgCrlFile(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_device_profiles_test.go b/mistapi/orgs_device_profiles_test.go new file mode 100644 index 00000000..7e8e84c5 --- /dev/null +++ b/mistapi/orgs_device_profiles_test.go @@ -0,0 +1,187 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsDeviceProfilesTestListOrgDeviceProfiles tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestListOrgDeviceProfiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + limit := int(100) + page := int(1) + apiResponse, err := orgsDeviceProfiles.ListOrgDeviceProfiles(ctx, orgId, &mType, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"aeroscout":{"enabled":false,"host":"aero.pvt.net","locate_connected":true},"ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"created_time":0,"disable_eth1":false,"disable_eth2":false,"disable_eth3":false,"disable_module":false,"for_site":true,"height":0,"id":"497f6eca-6276-4993-bfeb-53cbbbba6108","ip_config":{"dns":["8.8.8.8","4.4.4.4"],"dns_suffix":[".mist.local",".mist.com"],"gateway":"10.2.1.254","gateway6":"2607:f8b0:4005:808::1","ip":"10.2.1.1","ip6":"2607:f8b0:4005:808::2004","mtu":0,"netmask":"255.255.255.0","netmask6":"/32","type":"static","type6":"static","vlan_id":1},"led":{"brightness":255,"enabled":true},"map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","mesh":{"enabled":false,"group":1,"role":"base"},"modified_time":0,"name":"string","notes":"string","ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","orientation":0,"orientation_overwrite":true,"poe_passthrough":false,"port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}},"pwr_config":{"base":0},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","type":"ap","x":0,"y":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDeviceProfilesTestCreateOrgDeviceProfiles tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestCreateOrgDeviceProfiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Deviceprofile + errBody := json.Unmarshal([]byte(`{"aeroscout":{"enabled":false,"host":"aero.pvt.net","locate_connected":true},"led":{"brightness":255,"enabled":true},"name":"string","ntp_servers":["10.10.10.10"],"type":"ap","usb_config":{"cacert":"string","channel":3,"enabled":true,"host":"1.1.1.1","port":0,"type":"imagotag","verify_cert":true,"vlan_id":1}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsDeviceProfiles.CreateOrgDeviceProfiles(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aeroscout":{"enabled":true,"host":"string"},"ble_config":{"beacon_enabled":true,"beacon_rate":0,"beacon_rate_mode":"default","beam_disabled":[0],"eddystone_uid_adv_power":-100,"eddystone_uid_beams":"string","eddystone_uid_enabled":true,"eddystone_uid_freq_msec":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_adv_power":0,"eddystone_url_beams":"string","eddystone_url_enabled":true,"eddystone_url_freq_msec":0,"eddystone_url_url":"string","ibeacon_adv_power":-100,"ibeacon_beams":"string","ibeacon_enabled":true,"ibeacon_freq_msec":0,"ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":1,"power_mode":"string"},"created_time":0,"disable_eth1":true,"disable_module":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ip_config":{"dns":["string"],"dns_suffix":["string"],"gateway":"192.168.0.1","gateway6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","ip":"192.168.0.1","ip6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","mtu":0,"netmask":"192.168.0.1","netmask6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","type":"static","type6":"static","vlan_id":1},"mesh":{"enabled":true,"group":0,"role":"base"},"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","poe_passthrough":true,"radio_config":{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_24_usage":"24","band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_5_on_24_radio":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"scanning_enabled":true},"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","switch_config":{"enabled":true,"eth0":{"port_vlan_id":1,"vlan_ids":[0]},"eth1":{"port_vlan_id":1,"vlan_ids":[0]},"eth2":{"port_vlan_id":1,"vlan_ids":[0]},"eth3":{"port_vlan_id":1,"vlan_ids":[0]},"module":{"port_vlan_id":1,"vlan_ids":[0]},"wds":{"port_vlan_id":1,"vlan_ids":[0]}},"usb_config":{"cacert":"string","channel":0,"enabled":true,"host":"string","port":0,"type":"imagotag","verify_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDeviceProfilesTestDeleteOrgDeviceProfile tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestDeleteOrgDeviceProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsDeviceProfiles.DeleteOrgDeviceProfile(ctx, orgId, deviceprofileId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsDeviceProfilesTestGetOrgDeviceProfile tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestGetOrgDeviceProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsDeviceProfiles.GetOrgDeviceProfile(ctx, orgId, deviceprofileId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aeroscout":{"enabled":true,"host":"string"},"ble_config":{"beacon_enabled":true,"beacon_rate":0,"beacon_rate_mode":"default","beam_disabled":[0],"eddystone_uid_adv_power":-100,"eddystone_uid_beams":"string","eddystone_uid_enabled":true,"eddystone_uid_freq_msec":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_adv_power":0,"eddystone_url_beams":"string","eddystone_url_enabled":true,"eddystone_url_freq_msec":0,"eddystone_url_url":"string","ibeacon_adv_power":-100,"ibeacon_beams":"string","ibeacon_enabled":true,"ibeacon_freq_msec":0,"ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":1,"power_mode":"string"},"created_time":0,"disable_eth1":true,"disable_module":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ip_config":{"dns":["string"],"dns_suffix":["string"],"gateway":"192.168.0.1","gateway6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","ip":"192.168.0.1","ip6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","mtu":0,"netmask":"192.168.0.1","netmask6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","type":"static","type6":"static","vlan_id":1},"mesh":{"enabled":true,"group":0,"role":"base"},"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","poe_passthrough":true,"radio_config":{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_24_usage":"24","band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_5_on_24_radio":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"scanning_enabled":true},"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","switch_config":{"enabled":true,"eth0":{"port_vlan_id":1,"vlan_ids":[0]},"eth1":{"port_vlan_id":1,"vlan_ids":[0]},"eth2":{"port_vlan_id":1,"vlan_ids":[0]},"eth3":{"port_vlan_id":1,"vlan_ids":[0]},"module":{"port_vlan_id":1,"vlan_ids":[0]},"wds":{"port_vlan_id":1,"vlan_ids":[0]}},"usb_config":{"cacert":"string","channel":0,"enabled":true,"host":"string","port":0,"type":"imagotag","verify_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDeviceProfilesTestUpdateOrgDeviceProfile tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestUpdateOrgDeviceProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Deviceprofile + errBody := json.Unmarshal([]byte(`{"aeroscout":{"enabled":true,"host":"string"},"ble_config":{"beacon_enabled":true,"beacon_rate":0,"beacon_rate_mode":"default","beam_disabled":[0],"eddystone_uid_adv_power":-100,"eddystone_uid_beams":"string","eddystone_uid_enabled":true,"eddystone_uid_freq_msec":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_adv_power":0,"eddystone_url_beams":"string","eddystone_url_enabled":true,"eddystone_url_freq_msec":0,"eddystone_url_url":"string","ibeacon_adv_power":-100,"ibeacon_beams":"string","ibeacon_enabled":true,"ibeacon_freq_msec":0,"ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":1,"power_mode":"string"},"disable_eth1":true,"disable_module":true,"ip_config":{"dns":["string"],"dns_suffix":["string"],"gateway":"192.168.0.1","gateway6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","ip":"192.168.0.1","ip6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","mtu":0,"netmask":"192.168.0.1","netmask6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","type":"static","type6":"static","vlan_id":1},"mesh":{"enabled":true,"group":0,"role":"base"},"name":"string","poe_passthrough":true,"radio_config":{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_24_usage":"24","band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_5_on_24_radio":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"scanning_enabled":true},"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","switch_config":{"enabled":true,"eth0":{"port_vlan_id":1,"vlan_ids":[0]},"eth1":{"port_vlan_id":1,"vlan_ids":[0]},"eth2":{"port_vlan_id":1,"vlan_ids":[0]},"eth3":{"port_vlan_id":1,"vlan_ids":[0]},"module":{"port_vlan_id":1,"vlan_ids":[0]},"wds":{"port_vlan_id":1,"vlan_ids":[0]}},"usb_config":{"cacert":"string","channel":0,"enabled":true,"host":"string","port":0,"type":"imagotag","verify_cert":true}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsDeviceProfiles.UpdateOrgDeviceProfile(ctx, orgId, deviceprofileId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aeroscout":{"enabled":true,"host":"string"},"ble_config":{"beacon_enabled":true,"beacon_rate":0,"beacon_rate_mode":"default","beam_disabled":[0],"eddystone_uid_adv_power":-100,"eddystone_uid_beams":"string","eddystone_uid_enabled":true,"eddystone_uid_freq_msec":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_adv_power":0,"eddystone_url_beams":"string","eddystone_url_enabled":true,"eddystone_url_freq_msec":0,"eddystone_url_url":"string","ibeacon_adv_power":-100,"ibeacon_beams":"string","ibeacon_enabled":true,"ibeacon_freq_msec":0,"ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":1,"power_mode":"string"},"created_time":0,"disable_eth1":true,"disable_module":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ip_config":{"dns":["string"],"dns_suffix":["string"],"gateway":"192.168.0.1","gateway6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","ip":"192.168.0.1","ip6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","mtu":0,"netmask":"192.168.0.1","netmask6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","type":"static","type6":"static","vlan_id":1},"mesh":{"enabled":true,"group":0,"role":"base"},"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","poe_passthrough":true,"radio_config":{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_24_usage":"24","band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"band_5_on_24_radio":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":0,"disabled":true,"power":0,"power_max":0,"power_min":0,"preamble":"auto","usage":"24"},"scanning_enabled":true},"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","switch_config":{"enabled":true,"eth0":{"port_vlan_id":1,"vlan_ids":[0]},"eth1":{"port_vlan_id":1,"vlan_ids":[0]},"eth2":{"port_vlan_id":1,"vlan_ids":[0]},"eth3":{"port_vlan_id":1,"vlan_ids":[0]},"module":{"port_vlan_id":1,"vlan_ids":[0]},"wds":{"port_vlan_id":1,"vlan_ids":[0]}},"usb_config":{"cacert":"string","channel":0,"enabled":true,"host":"string","port":0,"type":"imagotag","verify_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDeviceProfilesTestAssignOrgDeviceProfile tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestAssignOrgDeviceProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["5c5b350e0001","5c5b350e0003"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsDeviceProfiles.AssignOrgDeviceProfile(ctx, orgId, deviceprofileId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDeviceProfilesTestUnassignOrgDeviceProfile tests the behavior of the OrgsDeviceProfiles +func TestOrgsDeviceProfilesTestUnassignOrgDeviceProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["5c5b350e0001","5c5b350e0003"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsDeviceProfiles.UnassignOrgDeviceProfile(ctx, orgId, deviceprofileId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_devices_others_test.go b/mistapi/orgs_devices_others_test.go new file mode 100644 index 00000000..6311489b --- /dev/null +++ b/mistapi/orgs_devices_others_test.go @@ -0,0 +1,183 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsDevicesOthersTestListOrgOtherDevices tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestListOrgOtherDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + limit := int(100) + page := int(1) + apiResponse, err := orgsDevicesOthers.ListOrgOtherDevices(ctx, orgId, nil, nil, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1676983730,"device_mac":"001122334455","id":"ae9dee49-69e7-4710-a114-5b827a777738","mac":"5c5b35000018","model":"AP41","modified_time":1676983730,"name":"hallway","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","serial":"FXLH2015150025","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","vendor":"cradlepoint"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesOthersTestUpdateOrgOtherDevices tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestUpdateOrgOtherDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OtherDeviceUpdateMulti + errBody := json.Unmarshal([]byte(`{"device_mac":"0adfea67e65b","macs":["5c5b350e0001","5c5b350e0003"],"op":"assign","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsDevicesOthers.UpdateOrgOtherDevices(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsDevicesOthersTestCountOrgOtherDeviceEvents tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestCountOrgOtherDeviceEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgOtherdevicesEventsCountDistinctEnum("mac") + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsDevicesOthers.CountOrgOtherDeviceEvents(ctx, orgId, &distinct, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesOthersTestSearchOrgOtherDeviceEvents tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestSearchOrgOtherDeviceEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsDevicesOthers.SearchOrgOtherDeviceEvents(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":{"device_mac":"string","mac":"5c5b351e13b5","org_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862a","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","text":"Plugged: The Internal 5GB (SIM1) has been inserted into Internal 1.","timestamp":547235620.89,"type":"CELLULAR_EDGE_MODEM_WAN_PLUGGED","vendor":"cradlepoint"},"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesOthersTestDeleteOrgOtherDevice tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestDeleteOrgOtherDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + resp, err := orgsDevicesOthers.DeleteOrgOtherDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsDevicesOthersTestGetOrgOtherDevice tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestGetOrgOtherDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + apiResponse, err := orgsDevicesOthers.GetOrgOtherDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1676983730,"device_mac":"001122334455","id":"ae9dee49-69e7-4710-a114-5b827a777738","mac":"5c5b35000018","model":"AP41","modified_time":1676983730,"name":"hallway","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","serial":"FXLH2015150025","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","vendor":"cradlepoint"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesOthersTestUpdateOrgOtherDevice tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestUpdateOrgOtherDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + var body models.OtherDeviceUpdate + errBody := json.Unmarshal([]byte(`{"device_mac":"0adfea67e65b","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsDevicesOthers.UpdateOrgOtherDevice(ctx, orgId, deviceMac, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsDevicesOthersTestRebootOrgOtherDevice tests the behavior of the OrgsDevicesOthers +func TestOrgsDevicesOthersTestRebootOrgOtherDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + resp, err := orgsDevicesOthers.RebootOrgOtherDevice(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_devices_ssr_test.go b/mistapi/orgs_devices_ssr_test.go new file mode 100644 index 00000000..aefd211e --- /dev/null +++ b/mistapi/orgs_devices_ssr_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsDevicesSSRTestGetOrg128TRegistrationCommands tests the behavior of the OrgsDevicesSSR +func TestOrgsDevicesSSRTestGetOrg128TRegistrationCommands(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsDevicesSsr.GetOrg128TRegistrationCommands(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"conductor_cmd":"register mist eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcmdfaWQiOiIyODE4ZTM4Ni04ZGVjLTI1NjItOWVkZS01YjhhMGZiYmRjNzEiLCJzdmMiOiIxMjhyb3V0ZXIiLCJwcm92aWRlciI6ImF3cyIsImVudiI6ImxvY2FsIiwiZXB0ZXJtX3VybCI6IndzczovL2xvY2FsL3dzIiwiaWF0IjoxNjEzODQ3NDg0LCJleHAiOjE2NDUzODM0ODR9.YnhgThKYAj1uaooi6j-zY8dMipp5YqJxnn79B9TB5XQ","registration_code":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcmdfaWQiOiIyODE4ZTM4Ni04ZGVjLTI1NjItOWVkZS01YjhhMGZiYmRjNzEiLCJzdmMiOiIxMjhyb3V0ZXIiLCJwcm92aWRlciI6ImF3cyIsImVudiI6ImxvY2FsIiwiZXB0ZXJtX3VybCI6IndzczovL2xvY2FsL3dzIiwiaWF0IjoxNjEzODQ3NDg0LCJleHAiOjE2NDUzODM0ODR9.YnhgThKYAj1uaooi6j-zY8dMipp5YqJxnn79B9TB5XQ","router_shell_cmd":"128agent register --registration-code eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcmdfaWQiOiIyODE4ZTM4Ni04ZGVjLTI1NjItOWVkZS01YjhhMGZiYmRjNzEiLCJzdmMiOiIxMjhyb3V0ZXIiLCJwcm92aWRlciI6ImF3cyIsImVudiI6ImxvY2FsIiwiZXB0ZXJtX3VybCI6IndzczovL2xvY2FsL3dzIiwiaWF0IjoxNjEzODQ3NDg0LCJleHAiOjE2NDUzODM0ODR9.YnhgThKYAj1uaooi6j-zY8dMipp5YqJxnn79B9TB5XQ"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_devices_test.go b/mistapi/orgs_devices_test.go new file mode 100644 index 00000000..8222e5a7 --- /dev/null +++ b/mistapi/orgs_devices_test.go @@ -0,0 +1,227 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsDevicesTestListOrgDevices tests the behavior of the OrgsDevices +func TestOrgsDevicesTestListOrgDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsDevices.ListOrgDevices(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"mac":"string","name":"string"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestCountOrgDevices tests the behavior of the OrgsDevices +func TestOrgsDevicesTestCountOrgDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgDevicesCountDistinctEnum("model") + + + + + + + ipAddress := "192.168.1.1" + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsDevices.CountOrgDevices(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, &ipAddress, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestCountOrgDeviceEvents tests the behavior of the OrgsDevices +func TestOrgsDevicesTestCountOrgDeviceEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgDevicesEventsCountDistinctEnum("model") + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsDevices.CountOrgDeviceEvents(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestSearchOrgDeviceEvents tests the behavior of the OrgsDevices +func TestOrgsDevicesTestSearchOrgDeviceEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + deviceType := models.DeviceTypeEnum("ap") + + + + lastBy := "port_id" + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsDevices.SearchOrgDeviceEvents(ctx, orgId, nil, nil, &deviceType, nil, nil, nil, &lastBy, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"ap":"5c5b351e13b5","apfw":"5c5b351e13b5","model":"BT11-WW","org_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862a","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","text":"Succeeding DNS query from 172.29.101.134 to 172.29.101.7 for \"portal.mistsys.com\" on vlan 1, id 60224","timestamp":1547235620.89,"type":"CLIENT_DNS_OK"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestCountOrgDeviceLastConfigs tests the behavior of the OrgsDevices +func TestOrgsDevicesTestCountOrgDeviceLastConfigs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + + + + limit := int(100) + apiResponse, err := orgsDevices.CountOrgDeviceLastConfigs(ctx, orgId, &mType, nil, nil, nil, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestSearchOrgDeviceLastConfigs tests the behavior of the OrgsDevices +func TestOrgsDevicesTestSearchOrgDeviceLastConfigs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + + + + + + limit := int(100) + duration := "1d" + apiResponse, err := orgsDevices.SearchOrgDeviceLastConfigs(ctx, orgId, &mType, nil, nil, nil, nil, nil, &limit, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":10,"results":[{"channel_24":11,"channel_5":100,"radio_macs":["5c5b352e000a","5c5b352e000b","5c5b352e000c"],"radios":[{"band":"24","channel":11},{"band":"5","channel":100}],"secpolicy_violated":false,"ssids":["test24","test5"],"ssids_24":["test24"],"ssids_5":["test5"],"timestamp":1531855856.643369,"version":"apfw-0.2.14754-cersei-75c8","wlans":[{"auth":"psk","bands":["24"],"id":"be22bba7-8e22-e1cf-5185-b880816fe2cf","ssid":"test24","vlan_ids":["1"]},{"auth":"psk","bands":["5"],"id":"f8c18724-4118-3487-811a-f98964988604","ssid":"test5","vlan_ids":["1"]}]}],"start":1531776183,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestListOrgApsMacs tests the behavior of the OrgsDevices +func TestOrgsDevicesTestListOrgApsMacs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsDevices.ListOrgApsMacs(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"mac":"5c5b35000001","radio_macs":["5c5b35000040","5c5b35000050","5c5b35000060"]},{"mac":"5c5b45000001","radio_macs":["5c5b45000040","5c5b45000050","5c5b45000060"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsDevicesTestGetOrgJuniperDevicesCommand tests the behavior of the OrgsDevices +func TestOrgsDevicesTestGetOrgJuniperDevicesCommand(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsDevices.GetOrgJuniperDevicesCommand(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cmd":"set system services ssh...\n...\nset system services outbound-ssh client mist ..."}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_evpn_topologies_test.go b/mistapi/orgs_evpn_topologies_test.go new file mode 100644 index 00000000..3739a266 --- /dev/null +++ b/mistapi/orgs_evpn_topologies_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsEVPNTopologiesTestListOrgEvpnTopologies tests the behavior of the OrgsEVPNTopologies +func TestOrgsEVPNTopologiesTestListOrgEvpnTopologies(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsEvpnTopologies.ListOrgEvpnTopologies(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsEVPNTopologiesTestCreateOrgEvpnTopology tests the behavior of the OrgsEVPNTopologies +func TestOrgsEVPNTopologiesTestCreateOrgEvpnTopology(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.EvpnTopology + errBody := json.Unmarshal([]byte(`{"name":"CC","pod_names":{"1":"default","2":"default"},"switches":[{"mac":"5c5b35000003","role":"collapsed-core"},{"mac":"5c5b35000004","role":"collapsed-core"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsEvpnTopologies.CreateOrgEvpnTopology(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsEVPNTopologiesTestDeleteOrgEvpnTopology tests the behavior of the OrgsEVPNTopologies +func TestOrgsEVPNTopologiesTestDeleteOrgEvpnTopology(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsEvpnTopologies.DeleteOrgEvpnTopology(ctx, orgId, evpnTopologyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsEVPNTopologiesTestGetOrgEvpnTolopogy tests the behavior of the OrgsEVPNTopologies +func TestOrgsEVPNTopologiesTestGetOrgEvpnTolopogy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsEvpnTopologies.GetOrgEvpnTolopogy(ctx, orgId, evpnTopologyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsEVPNTopologiesTestUpdateOrgEvpnTopology tests the behavior of the OrgsEVPNTopologies +func TestOrgsEVPNTopologiesTestUpdateOrgEvpnTopology(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.EvpnTopology + errBody := json.Unmarshal([]byte(`{"overwrite":false,"switches":[{"mac":"5c5b35000003","role":"collapsed-core"},{"mac":"5c5b35000004","role":"none"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsEvpnTopologies.UpdateOrgEvpnTopology(ctx, orgId, evpnTopologyId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_gateway_templates_test.go b/mistapi/orgs_gateway_templates_test.go new file mode 100644 index 00000000..83b06970 --- /dev/null +++ b/mistapi/orgs_gateway_templates_test.go @@ -0,0 +1,120 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsGatewayTemplatesTestListOrgGatewayTemplates tests the behavior of the OrgsGatewayTemplates +func TestOrgsGatewayTemplatesTestListOrgGatewayTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsGatewayTemplates.ListOrgGatewayTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsGatewayTemplatesTestCreateOrgGatewayTemplate tests the behavior of the OrgsGatewayTemplates +func TestOrgsGatewayTemplatesTestCreateOrgGatewayTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.GatewayTemplate + errBody := json.Unmarshal([]byte(`{"dhcpd_config":{"Corp-Mgmt":{"dns_servers":["8.8.8.8"],"dns_suffix":["stag.one"],"gateway":"10.3.172.9","ip_end":"10.3.172.99","ip_start":"10.3.172.50","type":"local"},"Corp-lan":{"dns_servers":["8.8.8.8"],"dns_suffix":["stag.one"],"gateway":"10.3.171.9","ip_end":"10.3.171.99","ip_start":"10.3.171.50","type":"local"}},"dnsOverride":true,"dns_servers":["10.3.20.201","10.3.51.222","1.1.1.1"],"dns_suffix":["example.com"],"extra_routes":{"10.101.0.0/16":{"via":"10.3.100.10"}},"ip_configs":{"Corp-Core":{"ip":"10.3.100.9","netmask":"/24","type":"static"},"Corp-Mgmt":{"ip":"10.3.172.9","netmask":"/24","type":"static"},"Corp-lan":{"ip":"10.3.171.9","netmask":"/24","type":"static"}},"name":"ITParis","ntpOverride":true,"ntp_servers":["10.3.51.222"],"path_preferences":{"core":{"paths":[{"networks":["Corp-Core"],"type":"local"}],"strategy":"ordered"},"lab":{"paths":[{"networks":["Corp-lan"],"type":"local"}],"strategy":"ordered"},"mgmt":{"paths":[{"networks":["Corp-Mgmt"],"type":"local"}],"strategy":"ordered"},"untrust":{"paths":[{"name":"wan","type":"wan"}],"strategy":"ordered"}},"port_config":{"ge-0/0/0":{"aggregated":false,"ip_config":{"gateway":"192.168.1.1","ip":"192.168.1.9","netmask":"/24","type":"static"},"name":"wan","redundant":false,"traffic_shaping":{"enabled":false},"usage":"wan","wan_type":"broadband"},"ge-0/0/6-7":{"ae_disable_lacp":false,"ae_idx":"0","ae_lacp_force_up":true,"aggregated":true,"networks":["Corp-lan","Corp-Mgmt","Corp-Core"],"usage":"lan"}},"service_policies":[{"action":"allow","idp":{"enabled":false},"name":"ITParis-Internal","path_preference":"core","services":["internal_dns","drive"],"tenants":["ITParis"]},{"action":"allow","idp":{"enabled":false},"name":"ITParis-internet","path_preference":"untrust","services":["internet_any"],"tenants":["ITParis"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-core","path_preference":"core","services":["internal_dns","internal_ntp"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-mxe-tt-in","path_preference":"mxe-in","services":["internal_any"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-untrust","path_preference":"untrust","services":["mxedge-updates","radsec","icmp","internet_dns","internet_ntp"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mxe-data-0-to-untrust","path_preference":"untrust","services":["internet_any"],"tenants":["ITParis"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-mgt","path_preference":"mgmt","services":["mgmt"],"tenants":["domain.Corp-Core","lan.Corp-Core","servers.Corp-Core","Corp-Core"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-edge-in","path_preference":"mxe-in","services":["internal_any"],"tenants":["lan.Corp-Core","Corp-Core"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-iot","path_preference":"iot","services":["iot"],"tenants":["lan.Corp-Core","servers-hassio.Corp-Core","servers-kubes.Corp-Core"]},{"action":"allow","idp":{"enabled":false},"name":"tanker-to-cctv","path_preference":"iot","services":["rtsp"],"tenants":["servers-tanker.Corp-Core"]},{"action":"allow","idp":{"enabled":false},"name":"core-to-untrust","path_preference":"untrust","services":["internet_any"],"tenants":["lan.Corp-Core","domain.Corp-Core","servers.Corp-Core"]},{"action":"deny","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"iot-upgrade-cctv","path_preference":"untrust","services":["motioneye","nodejs","raspbian"],"tenants":["printer"]}],"type":"standalone"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsGatewayTemplates.CreateOrgGatewayTemplate(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsGatewayTemplatesTestDeleteOrgGatewayTemplate tests the behavior of the OrgsGatewayTemplates +func TestOrgsGatewayTemplatesTestDeleteOrgGatewayTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + gatewaytemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsGatewayTemplates.DeleteOrgGatewayTemplate(ctx, orgId, gatewaytemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsGatewayTemplatesTestGetOrgGatewayTemplate tests the behavior of the OrgsGatewayTemplates +func TestOrgsGatewayTemplatesTestGetOrgGatewayTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + gatewaytemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsGatewayTemplates.GetOrgGatewayTemplate(ctx, orgId, gatewaytemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsGatewayTemplatesTestUpdateOrgGatewayTemplate tests the behavior of the OrgsGatewayTemplates +func TestOrgsGatewayTemplatesTestUpdateOrgGatewayTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + gatewaytemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.GatewayTemplate + errBody := json.Unmarshal([]byte(`{"dhcpd_config":{"Corp-Mgmt":{"dns_servers":["8.8.8.8"],"dns_suffix":["stag.one"],"gateway":"10.3.172.9","ip_end":"10.3.172.99","ip_start":"10.3.172.50","type":"local"},"Corp-lan":{"dns_servers":["8.8.8.8"],"dns_suffix":["stag.one"],"gateway":"10.3.171.9","ip_end":"10.3.171.99","ip_start":"10.3.171.50","type":"local"}},"dnsOverride":true,"dns_servers":["10.3.20.201","10.3.51.222","1.1.1.1"],"dns_suffix":["example.com"],"extra_routes":{"10.101.0.0/16":{"via":"10.3.100.10"}},"ip_configs":{"Corp-Core":{"ip":"10.3.100.9","netmask":"/24","type":"static"},"Corp-Mgmt":{"ip":"10.3.172.9","netmask":"/24","type":"static"},"Corp-lan":{"ip":"10.3.171.9","netmask":"/24","type":"static"}},"name":"ITParis","ntpOverride":true,"ntp_servers":["10.3.51.222"],"path_preferences":{"core":{"paths":[{"networks":["Corp-Core"],"type":"local"}],"strategy":"ordered"},"lab":{"paths":[{"networks":["Corp-lan"],"type":"local"}],"strategy":"ordered"},"mgmt":{"paths":[{"networks":["Corp-Mgmt"],"type":"local"}],"strategy":"ordered"},"untrust":{"paths":[{"name":"wan","type":"wan"}],"strategy":"ordered"}},"port_config":{"ge-0/0/0":{"aggregated":false,"ip_config":{"gateway":"192.168.1.1","ip":"192.168.1.9","netmask":"/24","type":"static"},"name":"wan","redundant":false,"traffic_shaping":{"enabled":false},"usage":"wan","wan_type":"broadband"},"ge-0/0/6-7":{"ae_disable_lacp":false,"ae_idx":"0","ae_lacp_force_up":true,"aggregated":true,"networks":["Corp-lan","Corp-Mgmt","Corp-Core"],"usage":"lan"}},"service_policies":[{"action":"allow","idp":{"enabled":false},"name":"ITParis-Internal","path_preference":"core","services":["internal_dns","drive"],"tenants":["ITParis"]},{"action":"allow","idp":{"enabled":false},"name":"ITParis-internet","path_preference":"untrust","services":["internet_any"],"tenants":["ITParis"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-core","path_preference":"core","services":["internal_dns","internal_ntp"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-mxe-tt-in","path_preference":"mxe-in","services":["internal_any"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mgmt-to-untrust","path_preference":"untrust","services":["mxedge-updates","radsec","icmp","internet_dns","internet_ntp"],"tenants":["Corp-Mgmt"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"mxe-data-0-to-untrust","path_preference":"untrust","services":["internet_any"],"tenants":["ITParis"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-mgt","path_preference":"mgmt","services":["mgmt"],"tenants":["domain.Corp-Core","lan.Corp-Core","servers.Corp-Core","Corp-Core"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-edge-in","path_preference":"mxe-in","services":["internal_any"],"tenants":["lan.Corp-Core","Corp-Core"]},{"action":"allow","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"core-to-iot","path_preference":"iot","services":["iot"],"tenants":["lan.Corp-Core","servers-hassio.Corp-Core","servers-kubes.Corp-Core"]},{"action":"allow","idp":{"enabled":false},"name":"tanker-to-cctv","path_preference":"iot","services":["rtsp"],"tenants":["servers-tanker.Corp-Core"]},{"action":"allow","idp":{"enabled":false},"name":"core-to-untrust","path_preference":"untrust","services":["internet_any"],"tenants":["lan.Corp-Core","domain.Corp-Core","servers.Corp-Core"]},{"action":"deny","idp":{"alert_only":true,"enabled":true,"profile":"standard"},"name":"iot-upgrade-cctv","path_preference":"untrust","services":["motioneye","nodejs","raspbian"],"tenants":["printer"]}],"type":"standalone"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsGatewayTemplates.UpdateOrgGatewayTemplate(ctx, orgId, gatewaytemplateId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_guests_test.go b/mistapi/orgs_guests_test.go new file mode 100644 index 00000000..57966c11 --- /dev/null +++ b/mistapi/orgs_guests_test.go @@ -0,0 +1,145 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsGuestsTestListOrgGuestAuthorizations tests the behavior of the OrgsGuests +func TestOrgsGuestsTestListOrgGuestAuthorizations(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsGuests.ListOrgGuestAuthorizations(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsGuestsTestCountOrgGuestAuthorizations tests the behavior of the OrgsGuests +func TestOrgsGuestsTestCountOrgGuestAuthorizations(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgGuestsCountDistinctEnum("auth_method") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsGuests.CountOrgGuestAuthorizations(ctx, orgId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsGuestsTestSearchOrgGuestAuthorization tests the behavior of the OrgsGuests +func TestOrgsGuestsTestSearchOrgGuestAuthorization(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId := "00000000-0000-0000-0000-000000000000" + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsGuests.SearchOrgGuestAuthorization(ctx, orgId, &wlanId, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":2,"next":"/api/v1/sites/8aaba0aa-09cc-44bd-9709-33b98040550c/guests/search?wlan_id=88ffe630-95b8-11e8-b294-346895ed1b7d&end=1531855849.000&limit=2&start=1531776183.0","results":[{"ap":"5c5b350e0001","auth_method":"passphrase","authorized_expiring_time":1531810258.1862731,"authorized_time":1531782218,"company":"mistsystems","email":"user@mistsys.com","name":"john","ssid":"openNet","timestamp":1531782218},{"ap":"5c5b350e0001","auth_method":"facebook","authorized_expiring_time":1531810821.145,"authorized_time":1531782632,"company":"xyz inc.","email":"cool_user@yahoo.com","name":"John White","ssid":"openNet","timestamp":1531782632}],"start":1531776183,"total":14}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsGuestsTestDeleteOrgGuestAuthorization tests the behavior of the OrgsGuests +func TestOrgsGuestsTestDeleteOrgGuestAuthorization(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + resp, err := orgsGuests.DeleteOrgGuestAuthorization(ctx, orgId, guestMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsGuestsTestGetOrgGuestAuthorization tests the behavior of the OrgsGuests +func TestOrgsGuestsTestGetOrgGuestAuthorization(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + apiResponse, err := orgsGuests.GetOrgGuestAuthorization(ctx, orgId, guestMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsGuestsTestUpdateOrgGuestAuthorization tests the behavior of the OrgsGuests +func TestOrgsGuestsTestUpdateOrgGuestAuthorization(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + var body models.Guest + errBody := json.Unmarshal([]byte(`{"authorized":true,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsGuests.UpdateOrgGuestAuthorization(ctx, orgId, guestMac, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_idp_profiles_test.go b/mistapi/orgs_idp_profiles_test.go new file mode 100644 index 00000000..5e1060aa --- /dev/null +++ b/mistapi/orgs_idp_profiles_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsIDPProfilesTestListOrgIdpProfiles tests the behavior of the OrgsIDPProfiles +func TestOrgsIDPProfilesTestListOrgIdpProfiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsIdpProfiles.ListOrgIdpProfiles(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"base_profile":"strict","created_time":0,"id":"874ca978-d736-4d4b-bc90-a49a29eec133","modified_time":0,"name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsIDPProfilesTestCreateOrgIdpProfile tests the behavior of the OrgsIDPProfiles +func TestOrgsIDPProfilesTestCreateOrgIdpProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.IdpProfile + errBody := json.Unmarshal([]byte(`{"base_profile":"strict","name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsIdpProfiles.CreateOrgIdpProfile(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"base_profile":"strict","created_time":0,"id":"874ca978-d736-4d4b-bc90-a49a29eec133","modified_time":0,"name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsIDPProfilesTestDeleteOrgIdpProfile tests the behavior of the OrgsIDPProfiles +func TestOrgsIDPProfilesTestDeleteOrgIdpProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + idpprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsIdpProfiles.DeleteOrgIdpProfile(ctx, orgId, idpprofileId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsIDPProfilesTestGetOrgIdpProfile tests the behavior of the OrgsIDPProfiles +func TestOrgsIDPProfilesTestGetOrgIdpProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + idpprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsIdpProfiles.GetOrgIdpProfile(ctx, orgId, idpprofileId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"base_profile":"strict","created_time":0,"id":"874ca978-d736-4d4b-bc90-a49a29eec133","modified_time":0,"name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsIDPProfilesTestUpdateOrgIdpProfile tests the behavior of the OrgsIDPProfiles +func TestOrgsIDPProfilesTestUpdateOrgIdpProfile(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + idpprofileId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.IdpProfile + errBody := json.Unmarshal([]byte(`{"base_profile":"strict","name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsIdpProfiles.UpdateOrgIdpProfile(ctx, orgId, idpprofileId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"base_profile":"strict","created_time":0,"id":"874ca978-d736-4d4b-bc90-a49a29eec133","modified_time":0,"name":"relaxed","overwrites":[{"action":"alert","matching":{"attack_name":["HTTP:INVALID:HDR-FIELD"],"dst_subnet":["63.1.2.0/24"],"severity":["major"]}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_inventory.go b/mistapi/orgs_inventory.go index 3c21f1e6..e75a4c25 100644 --- a/mistapi/orgs_inventory.go +++ b/mistapi/orgs_inventory.go @@ -141,7 +141,7 @@ func (o *OrgsInventory) AddOrgInventory( ), ) req.AppendErrors(map[string]https.ErrorBuilder[error]{ - "400": {Message: "if none of the entries are valid"}, + "400": {Message: "OK - if any of entries are valid or there’s no errors", Unmarshaller: errors.NewResponseInventoryError}, "401": {Message: "Unauthorized", Unmarshaller: errors.NewResponseHttp401Error}, "403": {Message: "Permission Denied", Unmarshaller: errors.NewResponseHttp403Error}, "404": {Message: "Not found. The API endpoint doesn’t exist or resource doesn’ t exist", Unmarshaller: errors.NewResponseHttp404}, diff --git a/mistapi/orgs_inventory_test.go b/mistapi/orgs_inventory_test.go new file mode 100644 index 00000000..17f21255 --- /dev/null +++ b/mistapi/orgs_inventory_test.go @@ -0,0 +1,159 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsInventoryTestGetOrgInventory tests the behavior of the OrgsInventory +func TestOrgsInventoryTestGetOrgInventory(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + mType := models.DeviceTypeEnum("ap") + + + + vc := bool(false) + unassigned := bool(true) + limit := int(100) + page := int(1) + apiResponse, err := orgsInventory.GetOrgInventory(ctx, orgId, nil, nil, &mType, nil, nil, nil, &vc, &unassigned, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"connected":true,"created_time":1542328276,"deviceprofile_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","id":"00000000-0000-0000-0000-5c5b35000018","mac":"5c5b35000018","model":"AP41","modified_time":1542829778,"name":"hallway","serial":"FXLH2015150025","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","type":"ap"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsInventoryTestAddOrgInventory tests the behavior of the OrgsInventory +func TestOrgsInventoryTestAddOrgInventory(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + body := []string{ "6JG8E-PTFV2-A9Z2N","DVH4V-SNMSZ-PDXBR" } + apiResponse, err := orgsInventory.AddOrgInventory(ctx, orgId, body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"added":["6JG8E-PTFV2-A9Z2N"],"duplicated":["DVH4V-SNMSZ-PDXBR"],"error":["PO1025335ohoh"],"inventory_added":[{"mac":"5c5b35000018","magic":"6JG8EPTFV2A9Z2N","model":"AP41","serial":"FXLH2015150025","type":"ap"}],"inventory_duplicated":[{"mac":"5c5b35000012","magic":"DVH4VSNMSZPDXBR","model":"AP41","serial":"FXLH2015150027","type":"ap"}],"reason":["belongs to another org ('e2f543f7-d6e1-409f-a565-e77a1f098d3b' (other) != '0de5d6fc-219a-414d-a840-67d6b919ad8f' (you))"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsInventoryTestUpdateOrgInventoryAssignment tests the behavior of the OrgsInventory +func TestOrgsInventoryTestUpdateOrgInventoryAssignment(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.InventoryUpdate + errBody := json.Unmarshal([]byte(`{"disable_auto_config":false,"macs":["5c5b350e0001"],"managed":false,"no_reassign":false,"op":"assign","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsInventory.UpdateOrgInventoryAssignment(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"error":[],"op":"assign","reason":[],"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsInventoryTestCreateOrgGatewayHaCluster tests the behavior of the OrgsInventory +func TestOrgsInventoryTestCreateOrgGatewayHaCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.HaClusterConfig + errBody := json.Unmarshal([]byte(`{"disable_auto_config":true,"managed":true,"nodes":[{"mac":"aff827549235"},{"mac":"8396cd006c8c"}],"site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsInventory.CreateOrgGatewayHaCluster(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsInventoryTestDeleteOrgGatewayHaCluster tests the behavior of the OrgsInventory +func TestOrgsInventoryTestDeleteOrgGatewayHaCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsInventory.DeleteOrgGatewayHaCluster(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsInventoryTestReevaluateOrgAutoAssignment tests the behavior of the OrgsInventory +func TestOrgsInventoryTestReevaluateOrgAutoAssignment(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsInventory.ReevaluateOrgAutoAssignment(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsInventoryTestReplaceOrgDevices tests the behavior of the OrgsInventory +func TestOrgsInventoryTestReplaceOrgDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.ReplaceDevice + errBody := json.Unmarshal([]byte(`{"discard":[],"inventory_mac":"5c5b35000301","mac":"5c5b35000101","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsInventory.ReplaceOrgDevices(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"error":[],"op":"assign","reason":[],"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_jse_test.go b/mistapi/orgs_jse_test.go new file mode 100644 index 00000000..21e22c0b --- /dev/null +++ b/mistapi/orgs_jse_test.go @@ -0,0 +1,85 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsJSETestGetOrgJseInfo tests the behavior of the OrgsJSE +func TestOrgsJSETestGetOrgJseInfo(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsJse.GetOrgJseInfo(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cloud_name":"devcentral.juniperclouds.net","org_names":["Mist-Sys","Mist-Eng"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsJSETestDeleteOrgJsecCredential tests the behavior of the OrgsJSE +func TestOrgsJSETestDeleteOrgJsecCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsJse.DeleteOrgJsecCredential(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsJSETestGetOrgJsecCredential tests the behavior of the OrgsJSE +func TestOrgsJSETestGetOrgJsecCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsJse.GetOrgJsecCredential(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsJSETestSetupOrgJsecCredential tests the behavior of the OrgsJSE +func TestOrgsJSETestSetupOrgJsecCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AccountJseConfig + errBody := json.Unmarshal([]byte(`{"cloud_name":"devcentral.juniperclouds.net","password":"foryoureyesonly","username":"john@abc.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsJse.SetupOrgJsecCredential(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_jsi_test.go b/mistapi/orgs_jsi_test.go new file mode 100644 index 00000000..808791d8 --- /dev/null +++ b/mistapi/orgs_jsi_test.go @@ -0,0 +1,96 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsJSITestListOrgJsiDevices tests the behavior of the OrgsJSI +func TestOrgsJSITestListOrgJsiDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + + + + apiResponse, err := orgsJsi.ListOrgJsiDevices(ctx, orgId, &limit, &page, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"ext_ip":"73.92.124.103","last_seen":1654636867,"mac":"c15353123096","model":"EX2300-C-12P","serial":"DGCOO0015"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsJSITestAdoptOrgJsiDevice tests the behavior of the OrgsJSI +func TestOrgsJSITestAdoptOrgJsiDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsJsi.AdoptOrgJsiDevice(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cmd":"set system services ssh...\n...\nset system services outbound-ssh client mist ..."}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsJSITestCreateOrgJsiDeviceShellSession tests the behavior of the OrgsJSI +func TestOrgsJSITestCreateOrgJsiDeviceShellSession(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + apiResponse, err := orgsJsi.CreateOrgJsiDeviceShellSession(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsJSITestListOrgJsiPastPurchases tests the behavior of the OrgsJSI +func TestOrgsJSITestListOrgJsiPastPurchases(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + + + apiResponse, err := orgsJsi.ListOrgJsiPastPurchases(ctx, orgId, &limit, &page, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"contract_end_time":1708214400,"contract_id":"68247710","contract_sku":"PAR-SDCE-EX4300T48","contract_start_time":1629331200,"customer_po":"4501942932","distributor":"dist1","eol_time":1671062400,"eos_time":1828828800,"installed_address":"Address","model":"EX4300-48T","order_id":"15909647","reseller":"reseller1","serial":"PE3721050223","sku":"EX4300-48T-AFI","type":"switch","warranty_end_time":2258236800,"warranty_start_time":1619395200,"warranty_type":"Enhanced Hardware Warranty"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_licenses_test.go b/mistapi/orgs_licenses_test.go new file mode 100644 index 00000000..5e4d5554 --- /dev/null +++ b/mistapi/orgs_licenses_test.go @@ -0,0 +1,94 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsLicensesTestClaimOrgLicense tests the behavior of the OrgsLicenses +func TestOrgsLicensesTestClaimOrgLicense(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.ClaimActivation + errBody := json.Unmarshal([]byte(`{"code":"ZHT3K-H36DT-MG85D-M61AC","type":"all"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsLicenses.ClaimOrgLicense(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"inventory_added":[{"mac":"5c5b35000018","magic":"6JG8EPTFV2A9Z2N","model":"AP41","serial":"FXLH2015150025","type":"ap"}],"inventory_duplicated":[{"mac":"5c5b35000012","magic":"DVH4VSNMSZPDXBR","model":"AP41","serial":"FXLH2015150027","type":"ap"}],"license_added":[{"end":1520380800,"quantity":180,"start":1504828800,"type":"SUB-MAN"},{"end":1520380800,"quantity":120,"start":1504828800,"type":"SUB-LOC"}],"license_duplicated":[{"end":1520380800,"quantity":180,"start":1504828800,"type":"SUB-MAN"}],"license_error":[{"order":"00000464","reason":""}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsLicensesTestGetOrgLicencesSummary tests the behavior of the OrgsLicenses +func TestOrgsLicensesTestGetOrgLicencesSummary(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsLicenses.GetOrgLicencesSummary(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"amendments":[{"created_time":1644684842,"end_time":1744156799,"id":"ff0a14f6-1234-5678-90ab-c8e64d4bc6c6","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1644684842,"end_time":1744156799,"id":"c1c28812-1234-5678-90ab-dc95680da61e","modified_time":1644684842,"quantity":-1,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"},{"created_time":1644684842,"end_time":1744243199,"id":"96c0a41f-1234-5678-90ab-afe74817e9fd","modified_time":1644684842,"quantity":-1,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"}],"entitled":{"SUB-ENG":26,"SUB-EX24":9,"SUB-MAN":26,"SUB-VNA":26},"licenses":[{"created_time":1555353534,"end_time":1586822399,"id":"693a41a6-1234-5678-90ab-f53dbd3a31c0","modified_time":1555353534,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":0,"start_time":1555286400,"subscription_id":"VNA-000000aa","type":"SUB-VNA"},{"created_time":1576132516,"end_time":1586822399,"id":"656607cf-1234-5678-90ab-fc9035614ea5","modified_time":1576132516,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":8,"remaining_quantity":0,"start_time":1576022400,"subscription_id":"VNA-000000ab","type":"SUB-VNA"},{"created_time":1579204568,"end_time":1730764800,"id":"db50d0bc-1234-5678-90ab-e439958cb06b","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"MAN-000000ac","type":"SUB-MAN"},{"created_time":1579204568,"end_time":1730764800,"id":"2ff9e84a-1234-5678-90ab-fb9ec0726e01","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"ENG-000000ad","type":"SUB-ENG"},{"created_time":1579204568,"end_time":1730764800,"id":"16df7ea6-1234-5678-90ab-78018cd4024d","modified_time":1579204568,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":2,"remaining_quantity":2,"start_time":1572998400,"subscription_id":"VNA-000000ae","type":"SUB-VNA"},{"created_time":1586237081,"end_time":1744243199,"id":"1b6f68d5-1234-5678-90ab-70d3e6d18c73","modified_time":1586237081,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"VNA-000000af","type":"SUB-VNA"},{"created_time":1586237097,"end_time":1744243199,"id":"1375c9bf-1234-5678-90ab-9c636708c89e","modified_time":1586237097,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"MAN-000000ba","type":"SUB-MAN"},{"created_time":1586237137,"end_time":1744243199,"id":"5974e979-1234-5678-90ab-438f833ec1c9","modified_time":1586237137,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":14,"remaining_quantity":14,"start_time":1586563200,"subscription_id":"ENG-000000bb","type":"SUB-ENG"},{"created_time":1629947267,"end_time":1744243199,"id":"340a9cb3-1234-5678-90ab-b009344dbf3c","modified_time":1629947267,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":9,"start_time":1586476800,"subscription_id":"EX24-000000bc","type":"SUB-EX24"},{"created_time":1632941870,"end_time":1744156799,"id":"9b599b0f-1234-5678-90ab-406081b58e7f","modified_time":1632941870,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":10,"remaining_quantity":10,"start_time":1632873600,"subscription_id":"ENG-000000bd","type":"SUB-ENG"},{"created_time":1632941882,"end_time":1744156799,"id":"d6d8ead3-1234-5678-90ab-98badeac7287","modified_time":1632941882,"order_id":"00000000","org_id":"9777c1a0-1234-5678-90ab-02e208b2d34f","quantity":11,"remaining_quantity":9,"start_time":1632873600,"subscription_id":"MAN-000008be","type":"SUB-MAN"}],"summary":{"SUB-ENG":18,"SUB-EX24":3,"SUB-MAN":22,"SUB-VNA":20}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsLicensesTestMoveOrDeleteOrgLicenseToAnotherOrg tests the behavior of the OrgsLicenses +func TestOrgsLicensesTestMoveOrDeleteOrgLicenseToAnotherOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OrgLicenseAction + errBody := json.Unmarshal([]byte(`{"notes":"customer notes","op":"annotate","subscription_id":"SUB-000144"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsLicenses.MoveOrDeleteOrgLicenseToAnotherOrg(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsLicensesTestGetOrgLicencesBySite tests the behavior of the OrgsLicenses +func TestOrgsLicensesTestGetOrgLicencesBySite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsLicenses.GetOrgLicencesBySite(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"fully_loaded":{"SUB-LOC":30,"SUB-MAN":80},"num_devices":80,"site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","usages":{"SUB-LOC":30,"SUB-MAN":60}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_linked_applications_test.go b/mistapi/orgs_linked_applications_test.go new file mode 100644 index 00000000..ad9000bf --- /dev/null +++ b/mistapi/orgs_linked_applications_test.go @@ -0,0 +1,50 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsLinkedApplicationsTestLinkOrgToJuniperJuniperAccount tests the behavior of the OrgsLinkedApplications +func TestOrgsLinkedApplicationsTestLinkOrgToJuniperJuniperAccount(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AccountJuniperConfig + errBody := json.Unmarshal([]byte(`{"password":"password","username":"john@nmo.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsLinkedApplications.LinkOrgToJuniperJuniperAccount(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"account":{"linked_by":"John Smith (john@abccorp.com)","name":"ABC Corp"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsLinkedApplicationsTestUnlinkOrgFromJuniperCustomerId tests the behavior of the OrgsLinkedApplications +func TestOrgsLinkedApplicationsTestUnlinkOrgFromJuniperCustomerId(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsLinkedApplications.UnlinkOrgFromJuniperCustomerId(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_logs_test.go b/mistapi/orgs_logs_test.go new file mode 100644 index 00000000..3da846cc --- /dev/null +++ b/mistapi/orgs_logs_test.go @@ -0,0 +1,68 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsLogsTestListOrgAuditLogs tests the behavior of the OrgsLogs +func TestOrgsLogsTestListOrgAuditLogs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsLogs.ListOrgAuditLogs(ctx, orgId, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"results":[{"admin_id":"72bfa2bd-e58a-4670-9d20-a1468f7a6f58","admin_name":"test@mistsys.com","id":"c6f9347b-b0a4-4a23-b927-fa9249f2ffb2","message":"TEST AUDIT","org_id":"469f6eca-6276-4993-bfeb-53cbbbba6f58","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1431382121}],"start":1428939600,"total":135}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsLogsTestCountOrgAuditLogs tests the behavior of the OrgsLogs +func TestOrgsLogsTestCountOrgAuditLogs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgLogsCountDistinctEnum("admin_name") + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsLogs.CountOrgAuditLogs(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_maps_test.go b/mistapi/orgs_maps_test.go new file mode 100644 index 00000000..1ca855d0 --- /dev/null +++ b/mistapi/orgs_maps_test.go @@ -0,0 +1,32 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsMapsTestImportOrgMaps tests the behavior of the OrgsMaps +func TestOrgsMapsTestImportOrgMaps(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + autoDeviceprofileAssignment := bool(true) + + + + apiResponse, err := orgsMaps.ImportOrgMaps(ctx, orgId, &autoDeviceprofileAssignment, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aps":[{"action":"assigned-placed","floorplan_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","height":3,"mac":"5c5b35000001","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","orientation":45}],"floorplans":[{"action":"imported","id":"cbdb7f0b-3be0-4872-88f9-58790b509c23","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","name":"map1"}],"site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","summary":{"num_ap_assigned":1,"num_inv_assigned":1,"num_map_assigned":1}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_marvis_test.go b/mistapi/orgs_marvis_test.go new file mode 100644 index 00000000..f94ee355 --- /dev/null +++ b/mistapi/orgs_marvis_test.go @@ -0,0 +1,33 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsMarvisTestTroubleshootOrg tests the behavior of the OrgsMarvis +func TestOrgsMarvisTestTroubleshootOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + apiResponse, err := orgsMarvis.TroubleshootOrg(ctx, orgId, nil, nil, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1655151856,"results":[{"category":"client","reason":"slow association","recommendation":"Ensure the IP helper-address is configured on the VLAN interface.","text":"Clients of the AP had slow association 8% of the time on Bhavabhi and 5 GHz. ..."}],"start":1655065456}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_mx_clusters_test.go b/mistapi/orgs_mx_clusters_test.go new file mode 100644 index 00000000..667574a3 --- /dev/null +++ b/mistapi/orgs_mx_clusters_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsMxClustersTestListOrgMxEdgeClusters tests the behavior of the OrgsMxClusters +func TestOrgsMxClustersTestListOrgMxEdgeClusters(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsMxClusters.ListOrgMxEdgeClusters(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"for_site":true,"id":"467f6eca-6276-4993-bfeb-53cbbbba6f78","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string"}],"auth_servers":[{"host":"string","port":1812,"secret":"string"}],"enabled":true,"server_selection":"ordered"},"radsec_tls":{"keypair":"string"},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","tunterm_ap_subnets":["string"],"tunterm_dhcpd_config":{"enabled":false,"property1":{"enabled":false,"servers":["string"],"type":"relay"},"property2":{"enabled":false,"servers":["string"],"type":"relay"},"servers":["string"],"type":"relay"},"tunterm_extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"tunterm_hosts":["string"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxClustersTestCreateOrgMxEdgeCluster tests the behavior of the OrgsMxClusters +func TestOrgsMxClustersTestCreateOrgMxEdgeCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Mxcluster + errBody := json.Unmarshal([]byte(`{"name":"string","radsec":{"enabled":true,"server_name":"string","servers":[{"host":"string","port":0}]},"tunterm_ap_subnets":["string"],"tunterm_hosts":["string"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxClusters.CreateOrgMxEdgeCluster(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"for_site":true,"id":"468f6eca-6276-4993-bfeb-53cbbbba6f68","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string"}],"auth_servers":[{"host":"string","port":1812,"secret":"string"}],"enabled":true,"server_selection":"ordered"},"radsec_tls":{"keypair":"string"},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","tunterm_ap_subnets":["string"],"tunterm_dhcpd_config":{"enabled":false,"property1":{"enabled":false,"servers":["string"],"type":"relay"},"property2":{"enabled":false,"servers":["string"],"type":"relay"},"servers":["string"],"type":"relay"},"tunterm_extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"tunterm_hosts":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxClustersTestDeleteOrgMxEdgeCluster tests the behavior of the OrgsMxClusters +func TestOrgsMxClustersTestDeleteOrgMxEdgeCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxclusterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxClusters.DeleteOrgMxEdgeCluster(ctx, orgId, mxclusterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxClustersTestGetOrgMxEdgeCluster tests the behavior of the OrgsMxClusters +func TestOrgsMxClustersTestGetOrgMxEdgeCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxclusterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsMxClusters.GetOrgMxEdgeCluster(ctx, orgId, mxclusterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"for_site":true,"id":"468f6eca-6276-4993-bfeb-53cbbbba6f68","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string"}],"auth_servers":[{"host":"string","port":1812,"secret":"string"}],"enabled":true,"server_selection":"ordered"},"radsec_tls":{"keypair":"string"},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","tunterm_ap_subnets":["string"],"tunterm_dhcpd_config":{"enabled":false,"property1":{"enabled":false,"servers":["string"],"type":"relay"},"property2":{"enabled":false,"servers":["string"],"type":"relay"},"servers":["string"],"type":"relay"},"tunterm_extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"tunterm_hosts":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxClustersTestUpdateOrgMxEdgeCluster tests the behavior of the OrgsMxClusters +func TestOrgsMxClustersTestUpdateOrgMxEdgeCluster(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxclusterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Mxcluster + errBody := json.Unmarshal([]byte(`{"name":"string","radsec":{"enabled":true,"server_name":"string","servers":[{"host":"string","port":0}]},"tunterm_ap_subnets":["string"],"tunterm_hosts":["string"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxClusters.UpdateOrgMxEdgeCluster(ctx, orgId, mxclusterId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"for_site":true,"id":"468f6eca-6276-4993-bfeb-53cbbbba6f68","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string"}],"auth_servers":[{"host":"string","port":1812,"secret":"string"}],"enabled":true,"server_selection":"ordered"},"radsec_tls":{"keypair":"string"},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","tunterm_ap_subnets":["string"],"tunterm_dhcpd_config":{"enabled":false,"property1":{"enabled":false,"servers":["string"],"type":"relay"},"property2":{"enabled":false,"servers":["string"],"type":"relay"},"servers":["string"],"type":"relay"},"tunterm_extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"tunterm_hosts":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_mx_edges_test.go b/mistapi/orgs_mx_edges_test.go new file mode 100644 index 00000000..e1887501 --- /dev/null +++ b/mistapi/orgs_mx_edges_test.go @@ -0,0 +1,426 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsMxEdgesTestListOrgMxEdges tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestListOrgMxEdges(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + forSites := models.MxedgeForSiteEnum("any") + limit := int(100) + page := int(1) + apiResponse, err := orgsMxEdges.ListOrgMxEdges(ctx, orgId, &forSites, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"cpu_stat":{"cpus":{"cpu0":{"idle":79,"interrupt":0,"system":4,"usage":20,"user":16},"cpu1":{"idle":93,"interrupt":0,"system":4,"usage":6,"user":1}},"idle":87,"interrupt":0,"system":5,"usage":12,"user":7},"ext_ip":"116.187.144.16","id":"387804a7-3474-85ce-15a2-f9a9684c9c90","ip_stat":{"ip":"172.16.5.3","ips":{"ens192":"172.16.5.3/24,fe81::20c:29ff:fef8:d18e/64"}},"lag_stat":{"lag0":{"active_ports":["0","1"]}},"last_seen":1547437078,"magic":"ExNpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","memory_stats":{"active":1061085184,"available":4124860416,"buffers":789495808,"cached":718016512,"free":2818838528,"inactive":458158080,"swap_cached":0,"swap_free":8161062912,"swap_total":8161062912,"total":7947616256,"usage":65},"model":"ME-S2019","mxagent_registered":false,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","name":"Guest","num_tunnels":31,"port_stat":{"eth0":{"full_duplex":true,"lldp_stats":{"mgmt_addr":"122.16.3.11","port_desc":"GigabitEthernet4/0/16","port_id":"\u0005Gi4/0/16","system_desc":"Cisco IOS Software","system_name":"ME-DC2-DIS-SW"},"rx_bytes":2056,"rx_errors":0,"rx_pkts":670,"speed":1000,"tx_bytes":2056,"tx_pkts":670,"up":true},"eth1":{"up":false},"module":{"up":false}},"status":"connected","tunterm_registered":false,"tunterm_stat":{"monitoring_failed":false},"uptime":884221,"version":"0.1.2","virtualization_type":"VirtualizationVMware"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestCreateOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestCreateOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Mxedge + errBody := json.Unmarshal([]byte(`{"model":"ME-100","mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{},"name":"Guest","ntp_servers":[],"oob_ip_config":{},"services":["tunterm"],"tunterm_ip_config":{"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"},"tunterm_port_config":{"downstream_ports":["0","1","2","3"],"separate_upstream_downstream":true,"upstream_port_vlan_id":1,"upstream_ports":["0","1","2","3"]},"tunterm_switch_config":{"0":{"port_vlan_id":1,"vlan_ids":[5,2,3]},"enabled":true}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxEdges.CreateOrgMxEdge(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"L-NpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","model":"ME-100","mxagent_registered":true,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"name":"Guest","ntp_servers":[],"oob_ip_config":{"dns":["8.8.8.8","4.4.4.4"],"gateway":"10.2.1.254","ip":"10.2.1.10","netmask":"255.255.255.0","type":"static"},"tunterm_dhcpd_config":{"2":{"enabled":true,"servers":["11.2.3.44"]},"enabled":false,"servers":["11.2.3.4"]},"tunterm_extra_routes":{"11.0.0.0/8":{"via":"10.3.3.1"}},"tunterm_ip_config":{"dns":["8.8.8.8"],"dns_suffix":[".mist.local"],"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestAssignOrgMxEdgeToSite tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestAssignOrgMxEdgeToSite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MxedgesAssign + errBody := json.Unmarshal([]byte(`{"mxedge_ids":["387804a7-3474-85ce-15a2-f9a9684c9c90"],"site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxEdges.AssignOrgMxEdgeToSite(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestClaimOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestClaimOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.CodeString + errBody := json.Unmarshal([]byte(`{"code":"135-546-673"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxEdges.ClaimOrgMxEdge(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"ExNpT5gi-ADR8WTFd4EiQPY3cP5WdSoD"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestCountOrgMxEdges tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestCountOrgMxEdges(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgMxedgeCountDistinctEnum("model") + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsMxEdges.CountOrgMxEdges(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestCountOrgSiteMxEdgeEvents tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestCountOrgSiteMxEdgeEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgMxedgeEventsCountDistinctEnum("mxedge_id") + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsMxEdges.CountOrgSiteMxEdgeEvents(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestSearchOrgMistEdgeEvents tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestSearchOrgMistEdgeEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsMxEdges.SearchOrgMistEdgeEvents(ctx, orgId, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1694708579,"limit":10,"page":3,"results":[{"mxcluster_id":"2815c917-58e7-472f-a190-bfd44fb58d05","mxedge_id":"00000000-0000-0000-1000-020000dc585c","org_id":"f2695c32-0e83-4936-b1b2-96fc88051213","service":"tunterm","timestamp":1694678225.927,"type":"ME_SERVICE_STOPPED"}],"start":1694622179}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestSearchOrgMxEdges tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestSearchOrgMxEdges(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsMxEdges.SearchOrgMxEdges(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1694708579,"limit":10,"results":[{"distro":"buster","last_seen":1695151551.833,"model":"ME-X5","mxedge_id":"00000000-0000-0000-1000-d420b0f0025d","org_id":"35d96b1a-1a13-4ba8-90f5-1e78dd2a10c5","tunterm_version":"0.1.2813","uptime":5662632}],"start":1694622179,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestUnassignOrgMxEdgeFromSite tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestUnassignOrgMxEdgeFromSite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MxedgesUnassign + errBody := json.Unmarshal([]byte(`{"mxedge_ids":["387804a7-3474-85ce-15a2-f9a9684c9c90"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxEdges.UnassignOrgMxEdgeFromSite(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"success":["5c5b350e0001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestGetOrgMxEdgeUpgradeInfo tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestGetOrgMxEdgeUpgradeInfo(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + channel := models.GetOrgMxedgeUpgradeInfoChannelEnum("stable") + apiResponse, err := orgsMxEdges.GetOrgMxEdgeUpgradeInfo(ctx, orgId, &channel) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"default":true,"package":"mxagent","version":"2.4.100"},{"package":"tunterm","version":"1.0.0"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestDeleteOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestDeleteOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxEdges.DeleteOrgMxEdge(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxEdgesTestGetOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestGetOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsMxEdges.GetOrgMxEdge(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"L-NpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","model":"ME-100","mxagent_registered":true,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"name":"Guest","ntp_servers":[],"oob_ip_config":{"dns":["8.8.8.8","4.4.4.4"],"gateway":"10.2.1.254","ip":"10.2.1.10","netmask":"255.255.255.0","type":"static"},"tunterm_dhcpd_config":{"2":{"enabled":true,"servers":["11.2.3.44"]},"enabled":false,"servers":["11.2.3.4"]},"tunterm_extra_routes":{"11.0.0.0/8":{"via":"10.3.3.1"}},"tunterm_ip_config":{"dns":["8.8.8.8"],"dns_suffix":[".mist.local"],"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestUpdateOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestUpdateOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Mxedge + errBody := json.Unmarshal([]byte(`{"model":"ME-X1","name":"string","ntp_servers":["string"],"services":["tunterm"],"tunterm_ip_config":{"dns":["string"],"dns_suffix":["string"],"gateway":"string","ip":"string","netmask":"string"},"tunterm_port_config":{"downstream_ports":["string"],"separate_upstream_downstream":true,"upstream_port_vlan_id":1,"upstream_ports":["string"]}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxEdges.UpdateOrgMxEdge(ctx, orgId, mxedgeId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"L-NpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","model":"ME-100","mxagent_registered":true,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"name":"Guest","ntp_servers":[],"oob_ip_config":{"dns":["8.8.8.8","4.4.4.4"],"gateway":"10.2.1.254","ip":"10.2.1.10","netmask":"255.255.255.0","type":"static"},"tunterm_dhcpd_config":{"2":{"enabled":true,"servers":["11.2.3.44"]},"enabled":false,"servers":["11.2.3.4"]},"tunterm_extra_routes":{"11.0.0.0/8":{"via":"10.3.3.1"}},"tunterm_ip_config":{"dns":["8.8.8.8"],"dns_suffix":[".mist.local"],"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxEdgesTestRestartOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestRestartOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxEdges.RestartOrgMxEdge(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxEdgesTestBounceOrgMxEdgeDataPorts tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestBounceOrgMxEdgeDataPorts(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsTuntermBouncePort + errBody := json.Unmarshal([]byte(`{"ports":["0","2"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsMxEdges.BounceOrgMxEdgeDataPorts(ctx, orgId, mxedgeId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxEdgesTestUploadOrgMxEdgeSupportFiles tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestUploadOrgMxEdgeSupportFiles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxEdges.UploadOrgMxEdgeSupportFiles(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxEdgesTestUnregisterOrgMxEdge tests the behavior of the OrgsMxEdges +func TestOrgsMxEdgesTestUnregisterOrgMxEdge(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxEdges.UnregisterOrgMxEdge(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_mx_tunnels_test.go b/mistapi/orgs_mx_tunnels_test.go new file mode 100644 index 00000000..278cafef --- /dev/null +++ b/mistapi/orgs_mx_tunnels_test.go @@ -0,0 +1,124 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsMxTunnelsTestListOrgMxTunnels tests the behavior of the OrgsMxTunnels +func TestOrgsMxTunnelsTestListOrgMxTunnels(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsMxTunnels.ListOrgMxTunnels(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"hello_interval":60,"hello_retries":3,"ipsec":{"dns_servers":["172.16.0.8"],"enabled":true,"extra_routes":[{"dest":"172.16.0.0/12","next_hop":"172.16.0.1"}],"split_tunnel":true},"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"name":"HQ","protocol":"udp","vlan_ids":[3,4,5]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxTunnelsTestCreateOrgMxTunnel tests the behavior of the OrgsMxTunnels +func TestOrgsMxTunnelsTestCreateOrgMxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Mxtunnel + errBody := json.Unmarshal([]byte(`{"cluster_ids":["string"],"hello_interval":60,"hello_retries":7,"ipsec":{"dns_servers":["string"],"enabled":true,"extra_routes":[{"dest":"string","next_hop":"192.168.0.1"}],"split_tunnel":true,"use_mxedge":true},"vlan_ids":[0]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsMxTunnels.CreateOrgMxTunnel(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cluster_ids":["string"],"created_time":0,"for_site":true,"hello_interval":60,"hello_retries":7,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"dns_servers":["string"],"enabled":true,"extra_routes":[{"dest":"string","next_hop":"192.168.0.1"}],"split_tunnel":true,"use_mxedge":true},"modified_time":0,"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vlan_ids":[0]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxTunnelsTestDeleteOrgMxTunnel tests the behavior of the OrgsMxTunnels +func TestOrgsMxTunnelsTestDeleteOrgMxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsMxTunnels.DeleteOrgMxTunnel(ctx, orgId, mxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsMxTunnelsTestGetOrgMxTunnel tests the behavior of the OrgsMxTunnels +func TestOrgsMxTunnelsTestGetOrgMxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsMxTunnels.GetOrgMxTunnel(ctx, orgId, mxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cluster_ids":["string"],"created_time":0,"for_site":true,"hello_interval":60,"hello_retries":7,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"dns_servers":["string"],"enabled":true,"extra_routes":[{"dest":"string","next_hop":"192.168.0.1"}],"split_tunnel":true,"use_mxedge":true},"modified_time":0,"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vlan_ids":[0]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsMxTunnelsTestUpdateOrgMxTunnel tests the behavior of the OrgsMxTunnels +func TestOrgsMxTunnelsTestUpdateOrgMxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsMxTunnels.UpdateOrgMxTunnel(ctx, orgId, mxtunnelId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cluster_ids":["string"],"created_time":0,"for_site":true,"hello_interval":60,"hello_retries":7,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"dns_servers":["string"],"enabled":true,"extra_routes":[{"dest":"string","next_hop":"192.168.0.1"}],"split_tunnel":true,"use_mxedge":true},"modified_time":0,"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vlan_ids":[0]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_nac_portals_test.go b/mistapi/orgs_nac_portals_test.go new file mode 100644 index 00000000..5c9c61fe --- /dev/null +++ b/mistapi/orgs_nac_portals_test.go @@ -0,0 +1,250 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsNACPortalsTestListOrgNacPortals tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestListOrgNacPortals(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsNacPortals.ListOrgNacPortals(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"access_type":"wireless","cert_expire_time":365,"enable_telemetry":true,"expiry_notification_time":2,"name":"get-wifi","notify_expiry":true,"ssid":"Corp","sso":{"idp_cert":"-----BEGIN CERTIFICATE-----\nMIIFZjCCA06gAwIBAgIIP61/1qm/uDowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----","idp_sign_algo":"sha256","idp_sso_url":"https://yourorg.onelogin.com/trust/saml2/http-post/sso/138130","issuer":"https://app.onelogin.com/saml/metadata/138130","nameid_format":"email","sso_role_matching":[{"assigned":"user","match":"Student"}],"use_sso_role_for_cert":true}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestCreateOrgNacPortal tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestCreateOrgNacPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsNacPortals.CreateOrgNacPortal(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"access_type":"wireless","cert_expire_time":365,"enable_telemetry":true,"expiry_notification_time":2,"name":"get-wifi","notify_expiry":true,"ssid":"Corp","sso":{"idp_cert":"-----BEGIN CERTIFICATE-----\nMIIFZjCCA06gAwIBAgIIP61/1qm/uDowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----","idp_sign_algo":"sha256","idp_sso_url":"https://yourorg.onelogin.com/trust/saml2/http-post/sso/138130","issuer":"https://app.onelogin.com/saml/metadata/138130","nameid_format":"email","sso_role_matching":[{"assigned":"user","match":"Student"}],"use_sso_role_for_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestDeleteOrgNacPortal tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestDeleteOrgNacPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNacPortals.DeleteOrgNacPortal(ctx, orgId, nacportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACPortalsTestGetOrgNacPortal tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestGetOrgNacPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNacPortals.GetOrgNacPortal(ctx, orgId, nacportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"access_type":"wireless","cert_expire_time":365,"enable_telemetry":true,"expiry_notification_time":2,"name":"get-wifi","notify_expiry":true,"ssid":"Corp","sso":{"idp_cert":"-----BEGIN CERTIFICATE-----\nMIIFZjCCA06gAwIBAgIIP61/1qm/uDowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----","idp_sign_algo":"sha256","idp_sso_url":"https://yourorg.onelogin.com/trust/saml2/http-post/sso/138130","issuer":"https://app.onelogin.com/saml/metadata/138130","nameid_format":"email","sso_role_matching":[{"assigned":"user","match":"Student"}],"use_sso_role_for_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestUpdateOrgNacPortal tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestUpdateOrgNacPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsNacPortals.UpdateOrgNacPortal(ctx, orgId, nacportalId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"access_type":"wireless","cert_expire_time":365,"enable_telemetry":true,"expiry_notification_time":2,"name":"get-wifi","notify_expiry":true,"ssid":"Corp","sso":{"idp_cert":"-----BEGIN CERTIFICATE-----\nMIIFZjCCA06gAwIBAgIIP61/1qm/uDowDQYJKoZIhvcNAQELBQE\n-----END CERTIFICATE-----","idp_sign_algo":"sha256","idp_sso_url":"https://yourorg.onelogin.com/trust/saml2/http-post/sso/138130","issuer":"https://app.onelogin.com/saml/metadata/138130","nameid_format":"email","sso_role_matching":[{"assigned":"user","match":"Student"}],"use_sso_role_for_cert":true}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestListOrgNacPortalSsoLatestFailures tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestListOrgNacPortalSsoLatestFailures(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsNacPortals.ListOrgNacPortalSsoLatestFailures(ctx, orgId, nacportalId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"detail":"string","saml_assertion_xml":"string","timestamp":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestDeleteOrgNacPortalImage tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestDeleteOrgNacPortalImage(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNacPortals.DeleteOrgNacPortalImage(ctx, orgId, nacportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACPortalsTestUploadOrgNacPortalImage tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestUploadOrgNacPortalImage(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + resp, err := orgsNacPortals.UploadOrgNacPortalImage(ctx, orgId, nacportalId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACPortalsTestUpdateOrgNacPortalTempalte tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestUpdateOrgNacPortalTempalte(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsNacPortals.UpdateOrgNacPortalTempalte(ctx, orgId, nacportalId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACPortalsTestGetOrgNacPortalSsoSamlMetadata tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestGetOrgNacPortalSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNacPortals.GetOrgNacPortalSsoSamlMetadata(ctx, orgId, nacportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"acs_url":"https://api.mist.com/api/v1/saml/llDfa13f/login","entity_id":"https://api.mist.com/api/v1/saml/llDfa13f/login","logout_url":"https://api.mist.com/api/v1/saml/llDfa13f/logout","metadata_xml":"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACPortalsTestDownloadOrgNacPortalSsoSamlMetadata tests the behavior of the OrgsNACPortals +func TestOrgsNACPortalsTestDownloadOrgNacPortalSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNacPortals.DownloadOrgNacPortalSsoSamlMetadata(ctx, orgId, nacportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_nac_rules_test.go b/mistapi/orgs_nac_rules_test.go new file mode 100644 index 00000000..09746034 --- /dev/null +++ b/mistapi/orgs_nac_rules_test.go @@ -0,0 +1,118 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsNACRulesTestListOrgNacRules tests the behavior of the OrgsNACRules +func TestOrgsNACRulesTestListOrgNacRules(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsNacRules.ListOrgNacRules(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","apply_tags":["string"],"created_time":0,"id":"455f6eca-6276-4993-bfeb-53cbbbba6208","matching":{"auth_type":"eap-tls","nactags":["string"],"port_types":["wireless"],"site_ids":["454f6eca-6276-4993-bfeb-53cbbbba6308"],"sitegroup_ids":["453f6eca-6276-4993-bfeb-53cbbbba6408"]},"modified_time":0,"name":"string","not_matching":{"auth_type":"eap-tls","nactags":["string"],"port_types":["wireless"],"site_ids":["452f6eca-6276-4993-bfeb-53cbbbba6508"],"sitegroup_ids":["451f6eca-6276-4993-bfeb-53cbbbba6608"]},"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACRulesTestCreateOrgNacRule tests the behavior of the OrgsNACRules +func TestOrgsNACRulesTestCreateOrgNacRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NacRule + errBody := json.Unmarshal([]byte(`{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5\""],"matching":{"auth_type":"eap-tls","nactags":["041d5d36-716c-4cfb-4988-3857c6aa14a2","a809a97f-d599-f812-eb8c-c3f84aabf6ba"],"port_types":["wired"],"site_ids":["bb19fc3e-4124-4b57-80d9-c3f6edce47c4","bb19fc3e-6564-4b57-80d9-c3f6edce47c1"],"sitegroup_ids":["bb19fc3e-4124-4b57-80d9-c3f6edce47c4","bb19fc3e-6564-4b57-80d9-c3f6edce47c1"]},"name":"name1","not_matching":{},"order":1}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNacRules.CreateOrgNacRule(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsNACRulesTestDeleteOrgNacRule tests the behavior of the OrgsNACRules +func TestOrgsNACRulesTestDeleteOrgNacRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNacRules.DeleteOrgNacRule(ctx, orgId, nacruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACRulesTestGetOrgNacRule tests the behavior of the OrgsNACRules +func TestOrgsNACRulesTestGetOrgNacRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNacRules.GetOrgNacRule(ctx, orgId, nacruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsNACRulesTestUpdateOrgNacRule tests the behavior of the OrgsNACRules +func TestOrgsNACRulesTestUpdateOrgNacRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nacruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsNacRules.UpdateOrgNacRule(ctx, orgId, nacruleId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_nac_tags_test.go b/mistapi/orgs_nac_tags_test.go new file mode 100644 index 00000000..a0fb54e5 --- /dev/null +++ b/mistapi/orgs_nac_tags_test.go @@ -0,0 +1,119 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsNACTagsTestListOrgNacTags tests the behavior of the OrgsNACTags +func TestOrgsNACTagsTestListOrgNacTags(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + limit := int(100) + page := int(1) + apiResponse, err := orgsNacTags.ListOrgNacTags(ctx, orgId, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsNACTagsTestCreateOrgNacTag tests the behavior of the OrgsNACTags +func TestOrgsNACTagsTestCreateOrgNacTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsNacTags.CreateOrgNacTag(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"match":"client_mac","name":"cameras","type":"match","values":["010203040506","abcdef*"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACTagsTestDeleteOrgNacTag tests the behavior of the OrgsNACTags +func TestOrgsNACTagsTestDeleteOrgNacTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nactagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNacTags.DeleteOrgNacTag(ctx, orgId, nactagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNACTagsTestGetOrgNacTag tests the behavior of the OrgsNACTags +func TestOrgsNACTagsTestGetOrgNacTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nactagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNacTags.GetOrgNacTag(ctx, orgId, nactagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"match":"client_mac","name":"cameras","type":"match","values":["010203040506","abcdef*"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNACTagsTestUpdateOrgNacTag tests the behavior of the OrgsNACTags +func TestOrgsNACTagsTestUpdateOrgNacTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + nactagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsNacTags.UpdateOrgNacTag(ctx, orgId, nactagId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"match":"client_mac","name":"cameras","type":"match","values":["010203040506","abcdef*"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_naccrl_test.go b/mistapi/orgs_naccrl_test.go new file mode 100644 index 00000000..501b62c1 --- /dev/null +++ b/mistapi/orgs_naccrl_test.go @@ -0,0 +1,46 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsNACCRLTestGetOrgNacCrl tests the behavior of the OrgsNACCRL +func TestOrgsNACCRLTestGetOrgNacCrl(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNaccrl.GetOrgNacCrl(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsNACCRLTestImportOrgNacCrl tests the behavior of the OrgsNACCRL +func TestOrgsNACCRLTestImportOrgNacCrl(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + apiResponse, err := orgsNaccrl.ImportOrgNacCrl(ctx, orgId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_nacidp_test.go b/mistapi/orgs_nacidp_test.go new file mode 100644 index 00000000..f530ad4a --- /dev/null +++ b/mistapi/orgs_nacidp_test.go @@ -0,0 +1,33 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsNACIDPTestValidateOrgIdpCredential tests the behavior of the OrgsNACIDP +func TestOrgsNACIDPTestValidateOrgIdpCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UsernamePassword + errBody := json.Unmarshal([]byte(`{"password":"xxxxxx","username":"suriyas@juniper.net"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNacidp.ValidateOrgIdpCredential(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_network_templates_test.go b/mistapi/orgs_network_templates_test.go new file mode 100644 index 00000000..b4c54c63 --- /dev/null +++ b/mistapi/orgs_network_templates_test.go @@ -0,0 +1,126 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsNetworkTemplatesTestListOrgNetworkTemplates tests the behavior of the OrgsNetworkTemplates +func TestOrgsNetworkTemplatesTestListOrgNetworkTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsNetworkTemplates.ListOrgNetworkTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"additional_config_cmds":["set snmp community public"],"created_time":0,"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["8.8.8.8","4.4.4.4"],"dns_suffix":[".mist.local",".mist.com"],"extra_routes":{"0.0.0.0/0":{"via":"1.2.3.4"}},"group_tags":{},"id":"497f6eca-6276-4993-bfeb-53cbbbba6808","import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"default"},"modified_time":0,"name":"template_name","networks":{"corp":{"vlan_id":600},"default":{"subnet":"192.168.1.0/24","vlan_id":1},"guest":{"vlan_id":700},"mgmt":{"vlan_id":500}},"ntp_servers":["192.168.1.10"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","port_usages":{"ap":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"WAP","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":false,"enable_qos":true,"mac_auth_only":false,"mac_limit":0,"mode":"trunk","mtu":9192,"networks":["guest","corp"],"persist_mac":false,"poe_disabled":false,"port_network":"default","rejected_network":null,"storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true},"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"iot":{"allow_dhcpd":true,"mode":"access","port_network":"default","stp_edge":true},"uplink":{"all_networks":true,"enable_qos":false,"mode":"trunk","port_network":"default","stp_edge":false}},"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"default"},"remote_syslog":{"archive":{"files":20,"size":"5m"},"console":{"contents":[{"facility":"config","severity":"warning"}]},"enabled":false,"files":[{"archive":{"files":10,"size":"5m"},"contents":[{"facility":"config","severity":"warning"}],"explicit_priority":true,"file":"file-name","match":"!alarm|ntp|errors.crc_error[chan]","structured_data":true}],"network":"default","send_to_all_servers":false,"servers":[{"facility":"config","host":"syslogd.internal","port":514,"protocol":"udp","severity":"info","tag":""}],"time_format":"millisecond","users":[{"contents":[{"facility":"config","severity":"warning"}],"match":"\"!alarm|ntp|errors.crc_error[chan]\"","user":"*"}]},"switch_matching":{"enable":true,"rules":[{"additional_config_cmds":["set snmp community public"],"match_model":"EX4300","match_name[0:3]":"abc","name":"match by name","port_config":{"ge-0/0/0":{"usage":"uplink"},"ge-0/0/8-16ge-1/0/0-47":{"usage":"ap"}}},{"additional_config_cmds":["set snmp community public2"],"match_role":"access","name":"match by role","port_config":{"ge-0/0/0":{"usage":"uplink"}}}]},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNetworkTemplatesTestCreateOrgNetworkTemplate tests the behavior of the OrgsNetworkTemplates +func TestOrgsNetworkTemplatesTestCreateOrgNetworkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NetworkTemplate + errBody := json.Unmarshal([]byte(`{"additional_config_cmds":["set snmp community public"],"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["string"],"dns_suffix":["string"],"import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"string"},"name":"string","networks":{"property1":{"subnet":"192.168.1.0/24","vlan_id":10},"property2":{"subnet":"192.168.1.0/24","vlan_id":10}},"ntp_servers":["string"],"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"192.0.2.10"},"property2":{"via":"198.51.100.1"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNetworkTemplates.CreateOrgNetworkTemplate(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"additional_config_cmds":["set snmp community public"],"created_time":0,"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["string"],"dns_suffix":["string"],"extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"group_tags":{},"id":"497f6eca-6276-4993-bfeb-53cbbbba6708","import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"string"},"modified_time":0,"name":"string","networks":{"property1":{"subnet":"192.168.1.0/24","vlan_id":10},"property2":{"subnet":"192.168.1.0/24","vlan_id":10}},"ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNetworkTemplatesTestDeleteOrgNetworkTemplate tests the behavior of the OrgsNetworkTemplates +func TestOrgsNetworkTemplatesTestDeleteOrgNetworkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNetworkTemplates.DeleteOrgNetworkTemplate(ctx, orgId, networktemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNetworkTemplatesTestGetOrgNetworkTemplate tests the behavior of the OrgsNetworkTemplates +func TestOrgsNetworkTemplatesTestGetOrgNetworkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNetworkTemplates.GetOrgNetworkTemplate(ctx, orgId, networktemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsNetworkTemplatesTestUpdateOrgNetworkTemplates tests the behavior of the OrgsNetworkTemplates +func TestOrgsNetworkTemplatesTestUpdateOrgNetworkTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NetworkTemplate + errBody := json.Unmarshal([]byte(`{"additional_config_cmds":["set snmp community public"],"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["string"],"dns_suffix":["string"],"extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"group_tags":{},"import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"string"},"name":"string","networks":{"property1":{"subnet":"192.168.1.0/24","vlan_id":10},"property2":{"subnet":"192.168.1.0/24","vlan_id":10}},"ntp_servers":["string"],"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.2"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.2"}},"networks":["string"]}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNetworkTemplates.UpdateOrgNetworkTemplates(ctx, orgId, networktemplateId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"additional_config_cmds":["set snmp community public"],"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["string"],"dns_suffix":["string"],"extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"string"},"name":"string","networks":{"property1":{"subnet":"192.168.1.0/24","vlan_id":10},"property2":{"subnet":"192.168.1.0/24","vlan_id":10}},"ntp_servers":["string"],"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.2"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.2"}},"networks":["string"]}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_networks_test.go b/mistapi/orgs_networks_test.go new file mode 100644 index 00000000..c51821c0 --- /dev/null +++ b/mistapi/orgs_networks_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsNetworksTestListOrgNetworks tests the behavior of the OrgsNetworks +func TestOrgsNetworksTestListOrgNetworks(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsNetworks.ListOrgNetworks(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f13","internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.45"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNetworksTestCreateOrgNetwork tests the behavior of the OrgsNetworks +func TestOrgsNetworksTestCreateOrgNetwork(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Network + errBody := json.Unmarshal([]byte(`{"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"name":"string","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10."]},"property2":{"addresses":["10.10.10.52"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNetworks.CreateOrgNetwork(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f12","internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.52"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNetworksTestDeleteOrgNetwork tests the behavior of the OrgsNetworks +func TestOrgsNetworksTestDeleteOrgNetwork(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networkId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsNetworks.DeleteOrgNetwork(ctx, orgId, networkId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsNetworksTestGetOrgNetwork tests the behavior of the OrgsNetworks +func TestOrgsNetworksTestGetOrgNetwork(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networkId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsNetworks.GetOrgNetwork(ctx, orgId, networkId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f12","internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.52"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsNetworksTestUpdateOrgNetwork tests the behavior of the OrgsNetworks +func TestOrgsNetworksTestUpdateOrgNetwork(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + networkId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Network + errBody := json.Unmarshal([]byte(`{"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"name":"string","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.52"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsNetworks.UpdateOrgNetwork(ctx, orgId, networkId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f12","internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.52"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_premium_analytics_test.go b/mistapi/orgs_premium_analytics_test.go new file mode 100644 index 00000000..db8c7f25 --- /dev/null +++ b/mistapi/orgs_premium_analytics_test.go @@ -0,0 +1,30 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsPremiumAnalyticsTestListOrgPmaDashboards tests the behavior of the OrgsPremiumAnalytics +func TestOrgsPremiumAnalyticsTestListOrgPmaDashboards(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsPremiumAnalytics.ListOrgPmaDashboards(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"name":"dashboard_1","url":"https://mist.looker.com/login/embed/%2Fembed%2Fdashboards%2F1?group_ids=%5B3%5D&last_name=%22%22&models=%5B%22generic%22%5D&....."}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_psk_portals_test.go b/mistapi/orgs_psk_portals_test.go new file mode 100644 index 00000000..a2aa7da2 --- /dev/null +++ b/mistapi/orgs_psk_portals_test.go @@ -0,0 +1,260 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsPskPortalsTestListOrgPskPortals tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestListOrgPskPortals(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsPskPortals.ListOrgPskPortals(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPskPortalsTestCreateOrgPskPortal tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestCreateOrgPskPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.PskPortal + errBody := json.Unmarshal([]byte(`{"auth":"sso","expire":0,"max_usage":0,"name":"string","required_fields":["string"],"role":"string","ssid":"string","sso":{"default_role":"string","forced_role":"string","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","issuer":"string","nameid_format":"string"},"sso_required_role":"string","template_url":"string","type":"byod","vlan_id":10}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsPskPortals.CreateOrgPskPortal(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPskPortalsTestListOrgPskPortalLogs tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestListOrgPskPortalLogs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsPskPortals.ListOrgPskPortalLogs(ctx, orgId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"results":[{"id":"8a3dcaa7-80e3-4bb0-a75b-7bc6322cfd09","message":"Rotate PSK test@mist.com","name_id":"test@mist.com","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","psk_id":"608fe603-f9f0-4ce9-9473-04ef6c6ea749","psk_name":"test@mist.com","pskportal_id":"c1742c09-af35-4161-96ef-7dc65c6d5674","timestamp":1686346104.096}],"start":1428939600,"total":135}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPskPortalsTestCountOrgPskPortalLogs tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestCountOrgPskPortalLogs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgPskPortalLogsCountDistinctEnum("pskportal_id") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsPskPortals.CountOrgPskPortalLogs(ctx, orgId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPskPortalsTestSearchOrgPskPortalLogs tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestSearchOrgPskPortalLogs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + + + + + + + + apiResponse, err := orgsPskPortals.SearchOrgPskPortalLogs(ctx, orgId, nil, nil, &duration, &limit, &page, nil, nil, nil, nil, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"results":[{"id":"8a3dcaa7-80e3-4bb0-a75b-7bc6322cfd09","message":"Rotate PSK test@mist.com","name_id":"test@mist.com","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","psk_id":"608fe603-f9f0-4ce9-9473-04ef6c6ea749","psk_name":"test@mist.com","pskportal_id":"c1742c09-af35-4161-96ef-7dc65c6d5674","timestamp":1686346104.096}],"start":1428939600,"total":135}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPskPortalsTestDeleteOrgPskPortal tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestDeleteOrgPskPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsPskPortals.DeleteOrgPskPortal(ctx, orgId, pskportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsPskPortalsTestGetOrgPskPortal tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestGetOrgPskPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsPskPortals.GetOrgPskPortal(ctx, orgId, pskportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPskPortalsTestUpdateOrgPskPortal tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestUpdateOrgPskPortal(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.PskPortal + errBody := json.Unmarshal([]byte(`{"auth":"sso","expire":0,"max_usage":0,"name":"string","required_fields":["string"],"role":"string","ssid":"string","sso":{"default_role":"string","forced_role":"string","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","issuer":"string","nameid_format":"string"},"sso_required_role":"string","template_url":"string","type":"byod","vlan_id":10}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsPskPortals.UpdateOrgPskPortal(ctx, orgId, pskportalId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPskPortalsTestDeleteOrgPskPortalImage tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestDeleteOrgPskPortalImage(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsPskPortals.DeleteOrgPskPortalImage(ctx, orgId, pskportalId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsPskPortalsTestUploadOrgPskPortalImage tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestUploadOrgPskPortalImage(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + resp, err := orgsPskPortals.UploadOrgPskPortalImage(ctx, orgId, pskportalId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsPskPortalsTestUpdateOrgPskPortalTemplate tests the behavior of the OrgsPskPortals +func TestOrgsPskPortalsTestUpdateOrgPskPortalTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskportalId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsPskPortals.UpdateOrgPskPortalTemplate(ctx, orgId, pskportalId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_psks_test.go b/mistapi/orgs_psks_test.go new file mode 100644 index 00000000..6efe5cb0 --- /dev/null +++ b/mistapi/orgs_psks_test.go @@ -0,0 +1,201 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsPsksTestListOrgPsks tests the behavior of the OrgsPsks +func TestOrgsPsksTestListOrgPsks(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + name := "psk_name" + + + limit := int(100) + page := int(1) + apiResponse, err := orgsPsks.ListOrgPsks(ctx, orgId, &name, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPsksTestCreateOrgPsk tests the behavior of the OrgsPsks +func TestOrgsPsksTestCreateOrgPsk(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + apiResponse, err := orgsPsks.CreateOrgPsk(ctx, orgId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPsksTestUpdateOrgMultiplePsks tests the behavior of the OrgsPsks +func TestOrgsPsksTestUpdateOrgMultiplePsks(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body []models.Psk + errBody := json.Unmarshal([]byte(`[{"expire_time":1614990263,"mac":"string","max_usage":0,"name":"string","passphrase":"stringst","ssid":"string","usage":"multi","vlan_id":10}]`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsPsks.UpdateOrgMultiplePsks(ctx, orgId, body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPsksTestDeleteOrgPskList tests the behavior of the OrgsPsks +func TestOrgsPsksTestDeleteOrgPskList(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsPsks.DeleteOrgPskList(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsPsksTestImportOrgPsks tests the behavior of the OrgsPsks +func TestOrgsPsksTestImportOrgPsks(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsPsks.ImportOrgPsks(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsPsksTestDeleteOrgPsk tests the behavior of the OrgsPsks +func TestOrgsPsksTestDeleteOrgPsk(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsPsks.DeleteOrgPsk(ctx, orgId, pskId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsPsksTestGetOrgPsk tests the behavior of the OrgsPsks +func TestOrgsPsksTestGetOrgPsk(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsPsks.GetOrgPsk(ctx, orgId, pskId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPsksTestUpdateOrgPsk tests the behavior of the OrgsPsks +func TestOrgsPsksTestUpdateOrgPsk(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsPsks.UpdateOrgPsk(ctx, orgId, pskId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsPsksTestDeleteOrgPskOldPassphrase tests the behavior of the OrgsPsks +func TestOrgsPsksTestDeleteOrgPskOldPassphrase(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsPsks.DeleteOrgPskOldPassphrase(ctx, orgId, pskId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_rf_templates_test.go b/mistapi/orgs_rf_templates_test.go new file mode 100644 index 00000000..49300497 --- /dev/null +++ b/mistapi/orgs_rf_templates_test.go @@ -0,0 +1,118 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsRFTemplatesTestListOrgRfTemplates tests the behavior of the OrgsRFTemplates +func TestOrgsRFTemplatesTestListOrgRfTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsRfTemplates.ListOrgRfTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"ant_gain":0,"bandwidth":20,"channels":[1,6,11],"disabled":false,"power_max":11,"power_min":3,"preamble":"short"},"band_24_usage":"auto","band_5":{"allow_rrm_disable":false,"ant_gain":0,"bandwidth":80,"channels":[36,40,44,48,52,56,60,64,100,104,149,153,157,161],"disabled":false,"power_max":16,"power_min":9,"preamble":"short"},"country_code":"FR","created_time":1594743723,"id":"b3f20330-f76a-49f1-bc65-0d8727140b1d","model_specific":{},"modified_time":1613582192,"name":"Lab","org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsRFTemplatesTestCreateOrgRfTemplate tests the behavior of the OrgsRFTemplates +func TestOrgsRFTemplatesTestCreateOrgRfTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsRfTemplates.CreateOrgRfTemplate(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"ant_gain":0,"bandwidth":20,"channels":[1,6,11],"disabled":false,"power_max":11,"power_min":3,"preamble":"short"},"band_24_usage":"auto","band_5":{"allow_rrm_disable":false,"ant_gain":0,"bandwidth":80,"channels":[36,40,44,48,52,56,60,64,100,104,149,153,157,161],"disabled":false,"power_max":16,"power_min":9,"preamble":"short"},"country_code":"FR","created_time":1594743723,"id":"b3f20330-f76a-49f1-bc65-0d8727140b1d","model_specific":{},"modified_time":1613582192,"name":"Lab","org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsRFTemplatesTestDeleteOrgRfTemplate tests the behavior of the OrgsRFTemplates +func TestOrgsRFTemplatesTestDeleteOrgRfTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rftemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsRfTemplates.DeleteOrgRfTemplate(ctx, orgId, rftemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsRFTemplatesTestGetOrgRfTemplate tests the behavior of the OrgsRFTemplates +func TestOrgsRFTemplatesTestGetOrgRfTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rftemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsRfTemplates.GetOrgRfTemplate(ctx, orgId, rftemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"ant_gain":0,"bandwidth":20,"channels":[1,6,11],"disabled":false,"power_max":11,"power_min":3,"preamble":"short"},"band_24_usage":"auto","band_5":{"allow_rrm_disable":false,"ant_gain":0,"bandwidth":80,"channels":[36,40,44,48,52,56,60,64,100,104,149,153,157,161],"disabled":false,"power_max":16,"power_min":9,"preamble":"short"},"country_code":"FR","created_time":1594743723,"id":"b3f20330-f76a-49f1-bc65-0d8727140b1d","model_specific":{},"modified_time":1613582192,"name":"Lab","org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsRFTemplatesTestUpdateOrgRfTemplate tests the behavior of the OrgsRFTemplates +func TestOrgsRFTemplatesTestUpdateOrgRfTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rftemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsRfTemplates.UpdateOrgRfTemplate(ctx, orgId, rftemplateId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"ant_gain":0,"bandwidth":20,"channels":[1,6,11],"disabled":false,"power_max":11,"power_min":3,"preamble":"short"},"band_24_usage":"auto","band_5":{"allow_rrm_disable":false,"ant_gain":0,"bandwidth":80,"channels":[36,40,44,48,52,56,60,64,100,104,149,153,157,161],"disabled":false,"power_max":16,"power_min":9,"preamble":"short"},"country_code":"FR","created_time":1594743723,"id":"b3f20330-f76a-49f1-bc65-0d8727140b1d","model_specific":{},"modified_time":1613582192,"name":"Lab","org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_scep_test.go b/mistapi/orgs_scep_test.go new file mode 100644 index 00000000..5dafd400 --- /dev/null +++ b/mistapi/orgs_scep_test.go @@ -0,0 +1,117 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSCEPTestDisableOrgMistScep tests the behavior of the OrgsSCEP +func TestOrgsSCEPTestDisableOrgMistScep(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsScep.DisableOrgMistScep(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"enabled":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSCEPTestGetOrgMistScep tests the behavior of the OrgsSCEP +func TestOrgsSCEPTestGetOrgMistScep(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsScep.GetOrgMistScep(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"enabled":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSCEPTestUpdateOrgMistScep tests the behavior of the OrgsSCEP +func TestOrgsSCEPTestUpdateOrgMistScep(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OrgSettingScep + errBody := json.Unmarshal([]byte(`{"enabled":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsScep.UpdateOrgMistScep(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"enabled":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSCEPTestGetOrgIssuedClientCertificates tests the behavior of the OrgsSCEP +func TestOrgsSCEPTestGetOrgIssuedClientCertificates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + apiResponse, err := orgsScep.GetOrgIssuedClientCertificates(ctx, orgId, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"created_time":1431382121,"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","expire_time":1718921115,"serial_number":"13 00 13 03 23 EE D5 84 01","sso_name_id":"john@corp.com"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSCEPTestRevokeOrgIssuedClientCertificates tests the behavior of the OrgsSCEP +func TestOrgsSCEPTestRevokeOrgIssuedClientCertificates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.ClientCertSerialNumbers + errBody := json.Unmarshal([]byte(`{"serial_numbers":["13 00 13 03 23 EE D5 84 01"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsScep.RevokeOrgIssuedClientCertificates(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_sdk_invites_test.go b/mistapi/orgs_sdk_invites_test.go new file mode 100644 index 00000000..fe7f5606 --- /dev/null +++ b/mistapi/orgs_sdk_invites_test.go @@ -0,0 +1,190 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSDKInvitesTestListSdkInvites tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestListSdkInvites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSdkInvites.ListSdkInvites(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1428954000,"enabled":true,"expire_time":1428954000,"id":"5034b980-b49e-501c-66e0-9de4c38f18a2","name":"Macy's","quota":-1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKInvitesTestCreateSdkInvite tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestCreateSdkInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Sdkinvite + errBody := json.Unmarshal([]byte(`{"enabled":true,"name":"string","quota":0,"quota_limited":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSdkInvites.CreateSdkInvite(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1428954000,"enabled":true,"expire_time":1428954000,"id":"5034b980-b49e-501c-66e0-9de4c38f18a2","name":"Macy's","quota":-1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKInvitesTestRevokeSdkInvite tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestRevokeSdkInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSdkInvites.RevokeSdkInvite(ctx, orgId, sdkinviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSDKInvitesTestGetSdkInvite tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestGetSdkInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSdkInvites.GetSdkInvite(ctx, orgId, sdkinviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1428954000,"enabled":true,"expire_time":1428954000,"id":"5034b980-b49e-501c-66e0-9de4c38f18a2","name":"Macy's","quota":-1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKInvitesTestUpdateSdkInvite tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestUpdateSdkInvite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSdkInvites.UpdateSdkInvite(ctx, orgId, sdkinviteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1428954000,"enabled":true,"expire_time":1428954000,"id":"5034b980-b49e-501c-66e0-9de4c38f18a2","name":"Macy's","quota":-1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKInvitesTestSendSdkInviteEmail tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestSendSdkInviteEmail(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.EmailString + errBody := json.Unmarshal([]byte(`{"email":"test@abc.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsSdkInvites.SendSdkInviteEmail(ctx, orgId, sdkinviteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSDKInvitesTestGetSdkInviteQrCode tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestGetSdkInviteQrCode(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSdkInvites.GetSdkInviteQrCode(ctx, orgId, sdkinviteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsSDKInvitesTestSendSdkInviteSms tests the behavior of the OrgsSDKInvites +func TestOrgsSDKInvitesTestSendSdkInviteSms(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkinviteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SdkInviteSms + errBody := json.Unmarshal([]byte(`{"number":"14081234567"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsSdkInvites.SendSdkInviteSms(ctx, orgId, sdkinviteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_sdk_templates_test.go b/mistapi/orgs_sdk_templates_test.go new file mode 100644 index 00000000..28966515 --- /dev/null +++ b/mistapi/orgs_sdk_templates_test.go @@ -0,0 +1,116 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsSDKTemplatesTestListSdkTemplates tests the behavior of the OrgsSDKTemplates +func TestOrgsSDKTemplatesTestListSdkTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSdkTemplates.ListSdkTemplates(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"bg_image":"http://p.imgci.com/db/PICTURES/CMS/227700/227791.4.jpg","btn_flr_bgcolor":"#282828","default":true,"header_txt":"Mist","name":"default","search_txtcolor":"#282828","welcome_msg":"Welcome to Mist"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKTemplatesTestCreateSdkTemplate tests the behavior of the OrgsSDKTemplates +func TestOrgsSDKTemplatesTestCreateSdkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSdkTemplates.CreateSdkTemplate(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"bg_image":"http://p.imgci.com/db/PICTURES/CMS/227700/227791.4.jpg","btn_flr_bgcolor":"#282828","default":true,"header_txt":"Mist","name":"default","search_txtcolor":"#282828","welcome_msg":"Welcome to Mist"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKTemplatesTestDeleteSdkTemplate tests the behavior of the OrgsSDKTemplates +func TestOrgsSDKTemplatesTestDeleteSdkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSdkTemplates.DeleteSdkTemplate(ctx, orgId, sdktemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSDKTemplatesTestGetSdkTemplate tests the behavior of the OrgsSDKTemplates +func TestOrgsSDKTemplatesTestGetSdkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSdkTemplates.GetSdkTemplate(ctx, orgId, sdktemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"bg_image":"http://p.imgci.com/db/PICTURES/CMS/227700/227791.4.jpg","btn_flr_bgcolor":"#282828","default":true,"header_txt":"Mist","name":"default","search_txtcolor":"#282828","welcome_msg":"Welcome to Mist"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSDKTemplatesTestUpdateSdkTemplate tests the behavior of the OrgsSDKTemplates +func TestOrgsSDKTemplatesTestUpdateSdkTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdktemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSdkTemplates.UpdateSdkTemplate(ctx, orgId, sdktemplateId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"bg_image":"http://p.imgci.com/db/PICTURES/CMS/227700/227791.4.jpg","btn_flr_bgcolor":"#282828","default":true,"header_txt":"Mist","name":"default","search_txtcolor":"#282828","welcome_msg":"Welcome to Mist"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_sec_policies_test.go b/mistapi/orgs_sec_policies_test.go new file mode 100644 index 00000000..7acda275 --- /dev/null +++ b/mistapi/orgs_sec_policies_test.go @@ -0,0 +1,124 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSecPoliciesTestListOrgSecPolicies tests the behavior of the OrgsSecPolicies +func TestOrgsSecPoliciesTestListOrgSecPolicies(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSecPolicies.ListOrgSecPolicies(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"name":"corporate only","wlans":[{"auth":{"pairwise":["wpa1-tkip","wpa2-tkip"],"type":"psk"},"band":"both","ssid":"office"},{"auth":{"type":"open"},"band":"5","ssid":"office-guest"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSecPoliciesTestCreateOrgSecPolicies tests the behavior of the OrgsSecPolicies +func TestOrgsSecPoliciesTestCreateOrgSecPolicies(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Secpolicy + errBody := json.Unmarshal([]byte(`{"name":"string","wlans":[{"acct_immediate_update":false,"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"airwatch":{"api_key":"aHhlbGxvYXNkZmFzZGZhc2Rmc2RmCg==\"","console_url":"https://hs1.airwatchportals.com","enabled":true,"password":"user1","username":"test123"},"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"ap_ids":["497f6eca-6276-4993-bfeb-53e2bbba6f08"],"app_limit":{"apps":{"dropbox":300,"netflix":60},"enabled":false,"wxtag_ids":{"f99862d9-2726-931f-7559-3dfdf5d070d3":30}},"app_qos":{"apps":{"skype-business-video":{"dscp":32,"dst_subnet":"10.2.0.0/16","src_subnet":"10.2.0.0/16"}},"enabled":true,"others":[{"dscp":32,"dst_subnet":"10.2.0.0/16","port_ranges":"80,1024-6553","protocol":"udp","src_subnet":"10.2.0.0/16"}]},"apply_to":"site","arp_filter":false,"auth":{"anticlog_threshold":16,"eap_reauth":false,"enable_mac_auth":false,"key_idx":1,"keys":["string"],"multi_psk_only":false,"pairwise":["wpa2-ccmp"],"private_wlan":true,"psk":"foryoureyesonly","type":"psk","wep_as_secondary_auth":true},"auth_server_selection":"ordered","auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_nas_id":"5c5b350e0101-nas","auth_servers_nas_ip":"15.3.1.5","auth_servers_retries":5,"auth_servers_timeout":5,"band":"string","band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10,20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"cisco_cwa":{"allowed_hostnames":["snapchat.com"],"allowed_subnets":["63.5.3.0/24"],"blocked_subnets":["192.168.0.0/16"],"enabled":false},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"coa_servers":[{"disable_event_timestamp_check":false,"enabled":false,"ip":"1.2.3.4","port":3799,"secret":"testing456"}],"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dns_server_rewrite":{"enabled":false,"radius_groups":{"contractor":"172.1.1.1","guest":"8.8.8.8"}},"dtim":2,"dynamic_psk":{"default_psk":"foryoureyesonly","default_vlan_id":999,"enabled":false,"source":"cloud_psks","vlan_ids":[1]},"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"hotspot20":{"domain_name":["mist.com"],"enabled":true,"nai_realms":["string"],"operators":["google","att"],"rcoi":["5A03BA0000"],"venue_name":"some_name"},"interface":"all","isolation":false,"l2_isolation":false,"legacy_overds":false,"limit_bcast":false,"limit_probe_response":true,"max_idletime":1800,"mist_nac":{"enabled":false},"no_static_dns":false,"no_static_ip":false,"portal":{"amazon_client_id":"string","amazon_client_secret":"string","amazon_email_domains":["string"],"amazon_enabled":false,"auth":"none","azure_client_id":"string","azure_client_secret":"string","azure_enabled":false,"azure_tenant_id":"string","broadnet_password":"password","broadnet_sid":"MIST","broadnet_user_id":"juniper","bypass_when_cloud_down":false,"clickatell_api_key":"string","cross_site":false,"email_enabled":true,"enabled":false,"expire":1440,"external_portal_url":"string","facebook_client_id":"string","facebook_client_secret":"string","facebook_email_domains":["string"],"facebook_enabled":false,"forward":false,"forward_url":"http://abc.com/promotions","google_client_id":"string","google_client_secret":"string","google_email_domains":["mydomain.edu","mydomain.org"],"google_enabled":false,"gupshup_password":"string","gupshup_userid":"string","microsoft_client_id":"string","microsoft_client_secret":"string","microsoft_email_domains":["string"],"microsoft_enabled":false,"passphrase_enabled":false,"password":"let me in","portal_api_secret":"string","portal_image":"https://url/to/image.png","predefined_sponsors_enabled":true,"privacy":true,"puzzel_password":"string","puzzel_service_id":"string","puzzel_username":"string","smsMessageFormat":"string","sms_enabled":false,"sms_provider":"twilio","sponsor_auto_approve":false,"sponsor_email_domains":["reserved.net","reserved.org"],"sponsor_enabled":false,"sponsor_link_validity_duration":"30","sponsor_notify_all":false,"sponsor_status_notify":false,"sponsors":{"sponsor1@company.com":"FirstName1 LastName1","sponsor2@company.com":"FirstName2 LastName2"},"sso_default_role":"string","sso_forced_role":"string","sso_idp_cert":"string","sso_idp_sign_algo":"string","sso_idp_sso_url":"string","sso_issuer":"string","sso_nameid_format":"email","telstra_client_id":"string","telstra_client_secret":"string","thumbnail":"string","twilio_auth_token":"af9dac44c344a875ab5d31cb7abcdefg","twilio_phone_number":"+18548888888","twilio_sid":"AC72ec6ba0ec5af30e6731c5e47abcdefgh"},"portal_allowed_hostnames":["snapchat.com","ibm.com"],"portal_allowed_subnets":["63.5.3.0/24"],"portal_api_secret":"EIfPMOykI3lMlDdNPub2WcbqT6dNOtWwmYHAd6bY","portal_denied_hostnames":["msg.snapchat.com"],"portal_image":"http://example.com","portal_template_url":"string","qos":{"class":"best_effort","overwrite":false},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"rateset":{"24":{"ht":"00ff00ff00ff","legacy":["6","9","12","18","24b","36","48","54"],"min_rssi":-70,"template":"string","vht":"03ff03ff03ff01ff"},"5":{"ht":"00ff00ff00ff","legacy":["6","9","12","18","24b","36","48","54"],"min_rssi":-70,"template":"string","vht":"03ff03ff03ff01ff"}},"roam_mode":"NONE","schedule":{"enabled":false,"hours":{"fri":"09:00-17:00","mon":"09:00-17:00"}},"sle_excluded":false,"ssid":"corporate","template_id":"c6d67e98-83ea-49f0-8812-e4abae2b68bc","thumbnail":"http://example.com","use_eapol_v1":false,"vlan_enabled":false,"vlan_id":1,"vlan_ids":[3,4,5],"vlan_pooling":false,"wlan_limit_down":0,"wlan_limit_down_enabled":false,"wlan_limit_up":0,"wlan_limit_up_enabled":false,"wxtag_ids":["497f6eca-6276-4993-bfeb-53e4bbba6f08"],"wxtunnel_id":"string","wxtunnel_remote_id":"string"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSecPolicies.CreateOrgSecPolicies(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"name":"corporate only","wlans":[{"auth":{"pairwise":["wpa1-tkip","wpa2-tkip"],"type":"psk"},"band":"both","ssid":"office"},{"auth":{"type":"open"},"band":"5","ssid":"office-guest"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSecPoliciesTestDeleteOrgSecPolicy tests the behavior of the OrgsSecPolicies +func TestOrgsSecPoliciesTestDeleteOrgSecPolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + secpolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSecPolicies.DeleteOrgSecPolicy(ctx, orgId, secpolicyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSecPoliciesTestGetOrgSecPolicy tests the behavior of the OrgsSecPolicies +func TestOrgsSecPoliciesTestGetOrgSecPolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + secpolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSecPolicies.GetOrgSecPolicy(ctx, orgId, secpolicyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"name":"corporate only","wlans":[{"auth":{"pairwise":["wpa1-tkip","wpa2-tkip"],"type":"psk"},"band":"both","ssid":"office"},{"auth":{"type":"open"},"band":"5","ssid":"office-guest"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSecPoliciesTestUpdateOrgSecPolicies tests the behavior of the OrgsSecPolicies +func TestOrgsSecPoliciesTestUpdateOrgSecPolicies(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + secpolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSecPolicies.UpdateOrgSecPolicies(ctx, orgId, secpolicyId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"name":"corporate only","wlans":[{"auth":{"pairwise":["wpa1-tkip","wpa2-tkip"],"type":"psk"},"band":"both","ssid":"office"},{"auth":{"type":"open"},"band":"5","ssid":"office-guest"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_service_policies_test.go b/mistapi/orgs_service_policies_test.go new file mode 100644 index 00000000..691075f1 --- /dev/null +++ b/mistapi/orgs_service_policies_test.go @@ -0,0 +1,122 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsServicePoliciesTestListOrgServicePolicies tests the behavior of the OrgsServicePolicies +func TestOrgsServicePoliciesTestListOrgServicePolicies(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsServicePolicies.ListOrgServicePolicies(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","created_time":0,"id":"string","modified_time":0,"name":"string","org_id":"string","services":["string"],"tenants":["string"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsServicePoliciesTestCreateOrgServicePolicy tests the behavior of the OrgsServicePolicies +func TestOrgsServicePoliciesTestCreateOrgServicePolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OrgServicePolicy + errBody := json.Unmarshal([]byte(`{"action":"allow","name":"string","services":["string"],"tenants":["string"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsServicePolicies.CreateOrgServicePolicy(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsServicePoliciesTestDeleteOrgServicePolicy tests the behavior of the OrgsServicePolicies +func TestOrgsServicePoliciesTestDeleteOrgServicePolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + servicepolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsServicePolicies.DeleteOrgServicePolicy(ctx, orgId, servicepolicyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsServicePoliciesTestGetOrgServicePolicy tests the behavior of the OrgsServicePolicies +func TestOrgsServicePoliciesTestGetOrgServicePolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + servicepolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsServicePolicies.GetOrgServicePolicy(ctx, orgId, servicepolicyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsServicePoliciesTestUpdateOrgServicePolicy tests the behavior of the OrgsServicePolicies +func TestOrgsServicePoliciesTestUpdateOrgServicePolicy(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + servicepolicyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.OrgServicePolicy + errBody := json.Unmarshal([]byte(`{"action":"allow","name":"string","services":["string"],"tenants":["string"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsServicePolicies.UpdateOrgServicePolicy(ctx, orgId, servicepolicyId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_services_test.go b/mistapi/orgs_services_test.go new file mode 100644 index 00000000..0b714759 --- /dev/null +++ b/mistapi/orgs_services_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsServicesTestListOrgServices tests the behavior of the OrgsServices +func TestOrgsServicesTestListOrgServices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsServices.ListOrgServices(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"addresses":["string"],"apps":["string"],"dscp":8,"hostnames":["string"],"max_jitter":0,"max_latency":0,"max_loss":0,"name":"string","specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"default","type":"custom"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsServicesTestCreateOrgService tests the behavior of the OrgsServices +func TestOrgsServicesTestCreateOrgService(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Service + errBody := json.Unmarshal([]byte(`{"app_key":"string","name":"string","network_id":"d6797cf4-42b9-4cad-8591-9dd91c3f0fc3","specs":[{"address":"string","port":0,"protocol":"any"}],"subnet":"string","type":"custom"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsServices.CreateOrgService(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"addresses":["string"],"app_categories":["string"],"apps":["string"],"created_time":0,"dscp":0,"failover_policy":"revertable","hostnames":["string"],"id":"497f6eca-6276-5004-bfeb-53cbbbba6f16","max_jitter":0,"max_latency":0,"max_loss":0,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","sle_enabled":false,"specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"data_best_effort","type":"custom","vpn_name":"addresses"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsServicesTestDeleteOrgService tests the behavior of the OrgsServices +func TestOrgsServicesTestDeleteOrgService(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + serviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsServices.DeleteOrgService(ctx, orgId, serviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsServicesTestGetOrgService tests the behavior of the OrgsServices +func TestOrgsServicesTestGetOrgService(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + serviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsServices.GetOrgService(ctx, orgId, serviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"addresses":["string"],"app_categories":["string"],"apps":["string"],"created_time":0,"dscp":0,"failover_policy":"revertable","hostnames":["string"],"id":"497f6eca-6276-5004-bfeb-53cbbbba6f16","max_jitter":0,"max_latency":0,"max_loss":0,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","sle_enabled":false,"specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"data_best_effort","type":"custom","vpn_name":"addresses"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsServicesTestUpdateOrgService tests the behavior of the OrgsServices +func TestOrgsServicesTestUpdateOrgService(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + serviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Service + errBody := json.Unmarshal([]byte(`{"addresses":["string"],"app_categories":["string"],"apps":["string"],"dscp":0,"failover_policy":"revertable","hostnames":["string"],"max_jitter":0,"max_latency":0,"max_loss":0,"name":"string","sle_enabled":false,"specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"data_best_effort","type":"custom","vpn_name":"addresses"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsServices.UpdateOrgService(ctx, orgId, serviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"addresses":["string"],"app_categories":["string"],"apps":["string"],"created_time":0,"dscp":0,"failover_policy":"revertable","hostnames":["string"],"id":"497f6eca-6276-5004-bfeb-53cbbbba6f16","max_jitter":0,"max_latency":0,"max_loss":0,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","sle_enabled":false,"specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"data_best_effort","type":"custom","vpn_name":"addresses"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_setting_test.go b/mistapi/orgs_setting_test.go new file mode 100644 index 00000000..e5083e6f --- /dev/null +++ b/mistapi/orgs_setting_test.go @@ -0,0 +1,134 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSettingTestGetOrgSettings tests the behavior of the OrgsSetting +func TestOrgsSettingTestGetOrgSettings(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSetting.GetOrgSettings(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_device_naming":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"auto_deviceprofile_assignment":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"auto_site_assignment":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"cacerts":["string"],"cloudshark":{"apitoken":"string","url":"string"},"created_time":0,"device_cert":{"cert":"string","key":"string"},"device_updown_threshold":0,"disable_pcap":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","installer":{"allow_all_sites":true,"extra_site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"grace_period":0},"mgmt":{"mxtunnel_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"use_mxtunnel":true,"use_wxtunnel":true},"modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","password_policy":{"enabled":true,"freshness":0,"min_length":8,"requires_special_char":true,"requires_two_factor_auth":true},"pcap":{"bucket":"string","max_pkt_len":0},"pcap_bucket_verified":true,"remote_syslog":{"enabled":true,"send_to_all_servers":true,"servers":[{"facility":"conflict-log","host":"string","port":0,"protocol":"udp","severity":"any","tag":"string"}]},"security":{"disable_local_ssh":true,"fips_zeroize_password":"string","limit_ssh_access":true},"tags":["string"],"ui_idle_timeout":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSettingTestUpdateOrgSettings tests the behavior of the OrgsSetting +func TestOrgsSettingTestUpdateOrgSettings(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSetting.UpdateOrgSettings(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_device_naming":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"auto_deviceprofile_assignment":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"auto_site_assignment":{"enable":true,"rules":[{"expression":"string","model":"string","prefix":"string","src":"name","subnet":"string","suffix":"string","value":"string"}]},"cacerts":["string"],"cloudshark":{"apitoken":"string","url":"string"},"device_cert":{"cert":"string","key":"string"},"disable_pcap":true,"installer":{"allow_all_sites":true,"extra_site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"grace_period":0},"mgmt":{"mxtunnel_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"use_mxtunnel":true,"use_wxtunnel":true},"modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","password_policy":{"enabled":true,"freshness":0,"min_length":8,"requires_special_char":true,"requires_two_factor_auth":true},"pcap":{"bucket":"string","max_pkt_len":0},"pcap_bucket_verified":true,"remote_syslog":{"enabled":true,"send_to_all_servers":true,"servers":[{"facility":"change-log","host":"string","port":0,"protocol":"udp","severity":"critical","tag":"string"}]},"security":{"disable_local_ssh":true,"fips_zeroize_password":"string","limit_ssh_access":true},"tags":["string"],"ui_idle_timeout":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSettingTestDeleteOrgWirelessClientsBlocklist tests the behavior of the OrgsSetting +func TestOrgsSettingTestDeleteOrgWirelessClientsBlocklist(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSetting.DeleteOrgWirelessClientsBlocklist(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSettingTestCreateOrgWirelessClientsBlocklist tests the behavior of the OrgsSetting +func TestOrgsSettingTestCreateOrgWirelessClientsBlocklist(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSetting.CreateOrgWirelessClientsBlocklist(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSettingTestSetOrgCustomBucket tests the behavior of the OrgsSetting +func TestOrgsSettingTestSetOrgCustomBucket(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.PcapBucket + errBody := json.Unmarshal([]byte(`{"bucket":"company-private-pcap"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSetting.SetOrgCustomBucket(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"bucket":"company-private-pcap","detail":"failed to write bucket - 403 AccessDenied"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSettingTestVerifyOrgCustomBucket tests the behavior of the OrgsSetting +func TestOrgsSettingTestVerifyOrgCustomBucket(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.PcapBucketVerify + errBody := json.Unmarshal([]byte(`{"bucket":"company-private-pcap","verify_token":"eyJhbGciOiJIUzI1J9.eyJzdWIiOiIxMjM0joiMjgxOG5MDIyfQ.2rzcRvMA3Eg09NnjCAC-1EWMRtxAnFDM"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsSetting.VerifyOrgCustomBucket(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_setting_zscaler_test.go b/mistapi/orgs_setting_zscaler_test.go new file mode 100644 index 00000000..43b47e05 --- /dev/null +++ b/mistapi/orgs_setting_zscaler_test.go @@ -0,0 +1,63 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSettingZscalerTestDeleteOrgZscalerCredential tests the behavior of the OrgsSettingZscaler +func TestOrgsSettingZscalerTestDeleteOrgZscalerCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSettingZscaler.DeleteOrgZscalerCredential(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSettingZscalerTestGetOrgZscalerCredential tests the behavior of the OrgsSettingZscaler +func TestOrgsSettingZscalerTestGetOrgZscalerCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSettingZscaler.GetOrgZscalerCredential(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cloud_name":"zscalerbeta.net","partner_key":"K35vrZcK3JvrZc","username":"john@nmo.com"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSettingZscalerTestSetupOrgZscalerCredential tests the behavior of the OrgsSettingZscaler +func TestOrgsSettingZscalerTestSetupOrgZscalerCredential(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.AccountZscalerConfig + errBody := json.Unmarshal([]byte(`{"cloud_name":"zscalerbeta.net","partner_key":"K35vrZcK3JvrZc","password":"password","username":"john@nmo.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := orgsSettingZscaler.SetupOrgZscalerCredential(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_site_templates_test.go b/mistapi/orgs_site_templates_test.go new file mode 100644 index 00000000..a0942937 --- /dev/null +++ b/mistapi/orgs_site_templates_test.go @@ -0,0 +1,118 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsSiteTemplatesTestListOrgSiteTemplates tests the behavior of the OrgsSiteTemplates +func TestOrgsSiteTemplatesTestListOrgSiteTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSiteTemplates.ListOrgSiteTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"auto_upgrade":{"day_of_week":"mon","enabled":true,"time_of_day":"string","version":"string"},"name":"string","vars":{"SSID_STR":"string","VLAN_ID":"string"}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSiteTemplatesTestCreateOrgSiteTemplates tests the behavior of the OrgsSiteTemplates +func TestOrgsSiteTemplatesTestCreateOrgSiteTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSiteTemplates.CreateOrgSiteTemplates(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_upgrade":{"day_of_week":"mon","enabled":true,"time_of_day":"string","version":"string"},"name":"string","vars":{"SSID_STR":"string","VLAN_ID":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSiteTemplatesTestDeleteOrgSiteTemplate tests the behavior of the OrgsSiteTemplates +func TestOrgsSiteTemplatesTestDeleteOrgSiteTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitetemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSiteTemplates.DeleteOrgSiteTemplate(ctx, orgId, sitetemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSiteTemplatesTestGetOrgSiteTemplate tests the behavior of the OrgsSiteTemplates +func TestOrgsSiteTemplatesTestGetOrgSiteTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitetemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSiteTemplates.GetOrgSiteTemplate(ctx, orgId, sitetemplateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_upgrade":{"day_of_week":"mon","enabled":true,"time_of_day":"string","version":"string"},"name":"string","vars":{"SSID_STR":"string","VLAN_ID":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSiteTemplatesTestUpdateOrgSiteTemplate tests the behavior of the OrgsSiteTemplates +func TestOrgsSiteTemplatesTestUpdateOrgSiteTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitetemplateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSiteTemplates.UpdateOrgSiteTemplate(ctx, orgId, sitetemplateId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_upgrade":{"day_of_week":"mon","enabled":true,"time_of_day":"string","version":"string"},"name":"string","vars":{"SSID_STR":"string","VLAN_ID":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_sitegroups_test.go b/mistapi/orgs_sitegroups_test.go new file mode 100644 index 00000000..9f0ef6f2 --- /dev/null +++ b/mistapi/orgs_sitegroups_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSitegroupsTestListOrgSiteGroups tests the behavior of the OrgsSitegroups +func TestOrgsSitegroupsTestListOrgSiteGroups(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSitegroups.ListOrgSiteGroups(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitegroupsTestCreateOrgSiteGroup tests the behavior of the OrgsSitegroups +func TestOrgsSitegroupsTestCreateOrgSiteGroup(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Sitegroup + errBody := json.Unmarshal([]byte(`{"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSitegroups.CreateOrgSiteGroup(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitegroupsTestDeleteOrgSiteGroup tests the behavior of the OrgsSitegroups +func TestOrgsSitegroupsTestDeleteOrgSiteGroup(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitegroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSitegroups.DeleteOrgSiteGroup(ctx, orgId, sitegroupId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSitegroupsTestGetOrgSiteGroup tests the behavior of the OrgsSitegroups +func TestOrgsSitegroupsTestGetOrgSiteGroup(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitegroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSitegroups.GetOrgSiteGroup(ctx, orgId, sitegroupId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitegroupsTestUpdateOrgSiteGroup tests the behavior of the OrgsSitegroups +func TestOrgsSitegroupsTestUpdateOrgSiteGroup(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sitegroupId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NameString + errBody := json.Unmarshal([]byte(`{"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSitegroups.UpdateOrgSiteGroup(ctx, orgId, sitegroupId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_sites_test.go b/mistapi/orgs_sites_test.go new file mode 100644 index 00000000..869ea5c2 --- /dev/null +++ b/mistapi/orgs_sites_test.go @@ -0,0 +1,123 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSitesTestListOrgSites tests the behavior of the OrgsSites +func TestOrgsSitesTestListOrgSites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSites.ListOrgSites(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","alarmtemplate_id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","apporttemplate_id":"string","aptemplate_id":"16bdf952-ade2-4491-80b0-85ce506c760b","country_code":"US","created_time":0,"gatewaytemplate_id":"6f9b2e75-9b2f-b5ae-81e3-e14c76f1a90f","id":"497f6eca-6276-5007-bfeb-53cbbbba6f19","latlng":{"lat":37.295833,"lng":-122.032946},"modified_time":0,"name":"Mist Office","networktemplate_id":"12ae9bd2-e0ab-107b-72e8-a7a005565ec2","notes":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rftemplate_id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","secpolicy_id":"3bcd0beb-5d0a-4cbd-92c1-14aea91e98ef","sitegroup_ids":["497f6eca-6276-5008-bfeb-53cbbbba6f1a"],"timezone":"America/Los_Angeles"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitesTestCreateOrgSite tests the behavior of the OrgsSites +func TestOrgsSitesTestCreateOrgSite(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Site + errBody := json.Unmarshal([]byte(`{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","alarmtemplate_id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","apporttemplate_id":"string","aptemplate_id":"16bdf952-ade2-4491-80b0-85ce506c760b","country_code":"US","gatewaytemplate_id":"6f9b2e75-9b2f-b5ae-81e3-e14c76f1a90f","latlng":{"lat":37.295833,"lng":-122.032946},"name":"Mist Office","networktemplate_id":"12ae9bd2-e0ab-107b-72e8-a7a005565ec2","notes":"string","rftemplate_id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","secpolicy_id":"3bcd0beb-5d0a-4cbd-92c1-14aea91e98ef","sitegroup_ids":["497f6eca-6276-4997-bfeb-53cbbbba6f3b"],"timezone":"America/Los_Angeles"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSites.CreateOrgSite(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","alarmtemplate_id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","apporttemplate_id":"string","aptemplate_id":"16bdf952-ade2-4491-80b0-85ce506c760b","country_code":"US","created_time":0,"gatewaytemplate_id":"6f9b2e75-9b2f-b5ae-81e3-e14c76f1a90f","id":"497f6eca-6276-5005-bfeb-53cbbbba6f17","latlng":{"lat":37.295833,"lng":-122.032946},"modified_time":0,"name":"Mist Office","networktemplate_id":"12ae9bd2-e0ab-107b-72e8-a7a005565ec2","notes":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rftemplate_id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","secpolicy_id":"3bcd0beb-5d0a-4cbd-92c1-14aea91e98ef","sitegroup_ids":["497f6eca-6276-5006-bfeb-53cbbbba6f18"],"timezone":"America/Los_Angeles"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitesTestCountOrgSites tests the behavior of the OrgsSites +func TestOrgsSitesTestCountOrgSites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgSitesCountDistinctEnum("id") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsSites.CountOrgSites(ctx, orgId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSitesTestSearchOrgSites tests the behavior of the OrgsSites +func TestOrgsSitesTestSearchOrgSites(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsSites.SearchOrgSites(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"auto_upgrade_enabled":true,"auto_upgrade_version":"string","country_code":"string","honeypot_enabled":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","timestamp":0,"timezone":"string","vna_enabled":true,"wifi_enabled":true}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_sso_roles_test.go b/mistapi/orgs_sso_roles_test.go new file mode 100644 index 00000000..f4d11938 --- /dev/null +++ b/mistapi/orgs_sso_roles_test.go @@ -0,0 +1,126 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSSORolesTestListOrgSsoRoles tests the behavior of the OrgsSSORoles +func TestOrgsSSORolesTestListOrgSsoRoles(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSsoRoles.ListOrgSsoRoles(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsSSORolesTestCreateOrgSsoRole tests the behavior of the OrgsSSORoles +func TestOrgsSSORolesTestCreateOrgSsoRole(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SsoRoleOrg + errBody := json.Unmarshal([]byte(`{"name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSsoRoles.CreateOrgSsoRole(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","privileges":[{"role":"admin","scope":"sitegroup","sitegroup_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSORolesTestDeleteOrgSsoRole tests the behavior of the OrgsSSORoles +func TestOrgsSSORolesTestDeleteOrgSsoRole(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoroleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSsoRoles.DeleteOrgSsoRole(ctx, orgId, ssoroleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSSORolesTestGetOrgSsoRole tests the behavior of the OrgsSSORoles +func TestOrgsSSORolesTestGetOrgSsoRole(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoroleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSsoRoles.GetOrgSsoRole(ctx, orgId, ssoroleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","privileges":[{"role":"admin","scope":"sitegroup","sitegroup_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSORolesTestUpdateOrgSsoRole tests the behavior of the OrgsSSORoles +func TestOrgsSSORolesTestUpdateOrgSsoRole(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoroleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SsoRoleOrg + errBody := json.Unmarshal([]byte(`{"name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSsoRoles.UpdateOrgSsoRole(ctx, orgId, ssoroleId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","privileges":[{"role":"admin","scope":"sitegroup","sitegroup_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_sso_test.go b/mistapi/orgs_sso_test.go new file mode 100644 index 00000000..e48ccbfb --- /dev/null +++ b/mistapi/orgs_sso_test.go @@ -0,0 +1,199 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsSSOTestListOrgSsos tests the behavior of the OrgsSSO +func TestOrgsSSOTestListOrgSsos(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsSso.ListOrgSsos(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestCreateOrgSso tests the behavior of the OrgsSSO +func TestOrgsSSOTestCreateOrgSso(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Sso + errBody := json.Unmarshal([]byte(`{"custom_logout_url":"string","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","name":"string","nameid_format":"email"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsSso.CreateOrgSso(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestDeleteOrgSso tests the behavior of the OrgsSSO +func TestOrgsSSOTestDeleteOrgSso(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSso.DeleteOrgSso(ctx, orgId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSSOTestGetOrgSso tests the behavior of the OrgsSSO +func TestOrgsSSOTestGetOrgSso(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSso.GetOrgSso(ctx, orgId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestUpdateOrgSso tests the behavior of the OrgsSSO +func TestOrgsSSOTestUpdateOrgSso(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsSso.UpdateOrgSso(ctx, orgId, ssoId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"custom_logout_url":"string","default_role":"string","domain":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","idp_cert":"string","idp_sign_algo":"string","idp_sso_url":"string","ignore_unmatched_roles":true,"issuer":"string","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nameid_format":"email","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestListOrgSsoLatestFailures tests the behavior of the OrgsSSO +func TestOrgsSSOTestListOrgSsoLatestFailures(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsSso.ListOrgSsoLatestFailures(ctx, orgId, ssoId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"results":[{"detail":"string","saml_assertion_xml":"string","timestamp":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestGetOrgSsoSamlMetadata tests the behavior of the OrgsSSO +func TestOrgsSSOTestGetOrgSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSso.GetOrgSsoSamlMetadata(ctx, orgId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"acs_url":"https://api.mist.com/api/v1/saml/llDfa13f/login","entity_id":"https://api.mist.com/api/v1/saml/llDfa13f/login","logout_url":"https://api.mist.com/api/v1/saml/llDfa13f/logout","metadata_xml":"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsSSOTestDownloadOrgSsoSamlMetadata tests the behavior of the OrgsSSO +func TestOrgsSSOTestDownloadOrgSsoSamlMetadata(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ssoId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsSso.DownloadOrgSsoSamlMetadata(ctx, orgId, ssoId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_stats_assets_test.go b/mistapi/orgs_stats_assets_test.go new file mode 100644 index 00000000..b7bdbfaa --- /dev/null +++ b/mistapi/orgs_stats_assets_test.go @@ -0,0 +1,92 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsAssetsTestListOrgAssetsStats tests the behavior of the OrgsStatsAssets +func TestOrgsStatsAssetsTestListOrgAssetsStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsStatsAssets.ListOrgAssetsStats(ctx, orgId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","last_seen":0,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","rssizones":[{"id":"478f6eca-6276-4993-bfeb-5bcbbbbacf08","since":0}],"x":0,"y":0,"zones":[{"id":"477f6eca-6276-4993-bfeb-5ccbbbbadf08","since":0}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsStatsAssetsTestCountOrgAssetsByDistanceField tests the behavior of the OrgsStatsAssets +func TestOrgsStatsAssetsTestCountOrgAssetsByDistanceField(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsStatsAssets.CountOrgAssetsByDistanceField(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsStatsAssetsTestSearchOrgAssets tests the behavior of the OrgsStatsAssets +func TestOrgsStatsAssetsTestSearchOrgAssets(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsStatsAssets.SearchOrgAssets(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","last_seen":0,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","rssizones":[{"id":"476f6eca-6276-4993-bfeb-5dcbbbbaef08","since":0}],"x":0,"y":0,"zones":[{"id":"475f6eca-6276-4993-bfeb-5ecbbbbf6f08","since":0}]}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_bgp_peers_test.go b/mistapi/orgs_stats_bgp_peers_test.go new file mode 100644 index 00000000..5d482311 --- /dev/null +++ b/mistapi/orgs_stats_bgp_peers_test.go @@ -0,0 +1,48 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsBGPPeersTestCountOrgBgpStats tests the behavior of the OrgsStatsBGPPeers +func TestOrgsStatsBGPPeersTestCountOrgBgpStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsStatsBgpPeers.CountOrgBgpStats(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsStatsBGPPeersTestSearchOrgBgpStats tests the behavior of the OrgsStatsBGPPeers +func TestOrgsStatsBGPPeersTestSearchOrgBgpStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsStatsBgpPeers.SearchOrgBgpStats(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"evpn_overlay":true,"for_overlay":true,"local_as":65000,"mac":"020001c04668","neighbor":"15.8.3.5","neighbor_as":65000,"neighbor_mac":"020001c04600","node":"node0","org_id":"0c160b7f-1027-4cd1-923b-744534c4b070","rx_pkts":63366,"rx_routes":60,"site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","state":"established","timestamp":1666251056.07,"tx_pkts":1735,"tx_routes":60,"up":true,"uptime":31355,"vrf_name":"default"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_mx_edges_test.go b/mistapi/orgs_stats_mx_edges_test.go new file mode 100644 index 00000000..c25a49a8 --- /dev/null +++ b/mistapi/orgs_stats_mx_edges_test.go @@ -0,0 +1,58 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsMxEdgesTestListOrgMxEdgesStats tests the behavior of the OrgsStatsMxEdges +func TestOrgsStatsMxEdgesTestListOrgMxEdgesStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + forSite := bool(false) + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsStatsMxEdges.ListOrgMxEdgesStats(ctx, orgId, &forSite, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"cpu_stat":{"cpus":{"property1":{"idle":0,"interrupt":0,"system":0,"usage":0,"user":0},"property2":{"idle":0,"interrupt":0,"system":0,"usage":0,"user":0}},"idle":0,"interrupt":0,"system":0,"usage":0,"user":0},"ext_ip":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ip_stat":{"ip":"string","ips":{"property1":"string","property2":"string"}},"lag_stat":{"property1":{"active_ports":["string"]},"property2":{"active_ports":["string"]}},"last_seen":0,"magic":"string","memory_stats":{"active":0,"available":0,"buffers":0,"cached":0,"free":0,"inactive":0,"swap_cached":0,"swap_free":0,"swap_total":0,"total":0,"usage":0},"model":"string","mxagent_registered":true,"mxcluster_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","num_tunnels":0,"port_stat":{"property1":{"full_duplex":true,"lldp_stats":{"mgmt_addr":"string","port_desc":"string","port_id":"string","system_desc":"string","system_name":"string"},"rx_bytes":0,"rx_errors":0,"rx_pkts":0,"speed":0,"tx_bytes":0,"tx_pkts":0,"up":true},"property2":{"full_duplex":true,"lldp_stats":{"mgmt_addr":"string","port_desc":"string","port_id":"string","system_desc":"string","system_name":"string"},"rx_bytes":0,"rx_errors":0,"rx_pkts":0,"speed":0,"tx_bytes":0,"tx_pkts":0,"up":true}},"status":"string","tunterm_registered":true,"tunterm_stat":{"monitoring_failed":true},"uptime":0,"version":"string","virtualization_type":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsStatsMxEdgesTestGetOrgMxEdgeStats tests the behavior of the OrgsStatsMxEdges +func TestOrgsStatsMxEdgesTestGetOrgMxEdgeStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsStatsMxEdges.GetOrgMxEdgeStats(ctx, orgId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cpu_stat":{"cpus":{"cpu0":{"idle":89,"interrupt":0,"system":8,"usage":10,"user":1},"cpu1":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu2":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu3":{"idle":2,"interrupt":0,"system":50,"usage":97,"user":46}},"idle":62,"interrupt":0,"system":17,"usage":37,"user":19},"created_time":1632684398,"for_site":false,"id":"00000000-0000-0000-1000-020000a80cb4","ip_stat":{"ip":"192.168.1.244","ips":{"ens18":"192.168.1.244/24,fe80::104c:ffff:fee0:caf8/64"},"macs":{"ens18":"e4434b217044"}},"lag_stat":{"lacp0":{"active_ports":["port0","port1"]}},"last_seen":1633721215,"mac":"020000a80cb4","memory_stat":{"active":394936320,"available":4699291648,"buffers":107646976,"cached":478060544,"free":4330659840,"inactive":211980288,"swap_cached":0,"swap_free":1022357504,"swap_total":1022357504,"total":8365957120,"usage":48},"model":"ME-VM","modified_time":1633643629,"mxagent_registered":true,"mxcluster_id":"678bc339-7635-4556-bbc0-e77ad493ef8b","name":"me-vm-1","num_tunnels":0,"oob_ip_config":{"dns":["8.8.8.8","1.1.1.1"],"gateway":"10.0.0.1","ip":"10.0.0.10","netmask":"255.255.255.0","type":"static"},"org_id":"11b08247-b1ee-4152-9b25-312b323ce480","port_stat":{"port0":{"full_duplex":true,"mac":"9e294e49091d","rx_bytes":646898375700,"rx_errors":0,"rx_pkts":8784449574,"speed":10000,"state":"forwarding","tx_bytes":647200748038,"tx_errors":0,"tx_pkts":8788647466,"up":true},"port1":{"full_duplex":true,"mac":"a270fe53437e","rx_bytes":647200437652,"rx_errors":0,"rx_pkts":8788644886,"speed":10000,"state":"forwarding","tx_bytes":646898681650,"tx_errors":0,"tx_pkts":8784452092,"up":true}},"sensor_stat":{},"serial":"string","service_stat":{"mxagent":{"ext_ip":"99.0.86.164","last_seen":1633721215,"package_state":"Installed","package_version":"3.1.1037-1","running_state":"Running","uptime":21240},"tunterm":{"ext_ip":"99.0.86.164","last_seen":1633721203,"package_state":"Installed","package_version":"0.1.2449+deb10","running_state":"Running","uptime":76261}},"services":["tunterm"],"site_id":"00000000-0000-0000-0000-000000000000","status":"connected","tunterm_ip_config":{"gateway":"192.168.11.1","ip":"192.168.11.91","netmask":"255.255.255.0"},"tunterm_port_config":{"downstream_ports":["0","1"],"separate_upstream_downstream":false,"upstream_ports":["0","1"]},"tunterm_registered":true,"tunterm_stat":{"monitoring_failed":false},"uptime":76281,"virtualization_type":"KVM"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_other_devices_test.go b/mistapi/orgs_stats_other_devices_test.go new file mode 100644 index 00000000..b141ebf1 --- /dev/null +++ b/mistapi/orgs_stats_other_devices_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsOtherDevicesTestGetOrgOtherDeviceStats tests the behavior of the OrgsStatsOtherDevices +func TestOrgsStatsOtherDevicesTestGetOrgOtherDeviceStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + apiResponse, err := orgsStatsOtherDevices.GetOrgOtherDeviceStats(ctx, orgId, deviceMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"config_status":"synced","last_config":1675392788,"last_seen":1675843629,"mac":"5c5b35000018","status":"online","uptime":20296,"vendor":"cradlepoint","vendor_specific":{"ports":{"mdm-4d0e073b":{"bytes_in":33004879,"bytes_out":41103393,"health_category":"","health_score":0,"id":"101027967","mode":"wan","model":"Internal 5GB (SIM1)","state":"READY","type":"5G","uptime":252371.34149021498}},"router_id":null,"target_version":"7.23.40"},"version":"7.22.70"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_ports_test.go b/mistapi/orgs_stats_ports_test.go new file mode 100644 index 00000000..b29fd25c --- /dev/null +++ b/mistapi/orgs_stats_ports_test.go @@ -0,0 +1,111 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsStatsPortsTestSearchOrgSwOrGwPorts tests the behavior of the OrgsStatsPorts +func TestOrgsStatsPortsTestSearchOrgSwOrGwPorts(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := orgsStatsPorts.SearchOrgSwOrGwPorts(ctx, orgId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsStatsPortsTestCountOrgSwitchPorts tests the behavior of the OrgsStatsPorts +func TestOrgsStatsPortsTestCountOrgSwitchPorts(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgSwitchPortCountDistinctEnum("mac") + + + + + + + + + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsStatsPorts.CountOrgSwitchPorts(ctx, orgId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_test.go b/mistapi/orgs_stats_test.go new file mode 100644 index 00000000..2547ae38 --- /dev/null +++ b/mistapi/orgs_stats_test.go @@ -0,0 +1,33 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsTestGetOrgStats tests the behavior of the OrgsStats +func TestOrgsStatsTestGetOrgStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsStats.GetOrgStats(ctx, orgId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","num_devices":0,"num_devices_connected":0,"num_devices_disconnected":0,"num_inventory":0,"num_sites":0,"orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":0,"sle":[{"path":"string","user_minutes":{"ok":0,"total":0}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_tunnels_test.go b/mistapi/orgs_stats_tunnels_test.go new file mode 100644 index 00000000..174af321 --- /dev/null +++ b/mistapi/orgs_stats_tunnels_test.go @@ -0,0 +1,31 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsStatsTunnelsTestCountOrgTunnelsStats tests the behavior of the OrgsStatsTunnels +func TestOrgsStatsTunnelsTestCountOrgTunnelsStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgTunnelCountDistinctEnum("wxtunnel_id") + mType := models.OrgTunnelTypeCountEnum("wxtunnel") + apiResponse, err := orgsStatsTunnels.CountOrgTunnelsStats(ctx, orgId, &distinct, &mType) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_stats_vpn_peers_test.go b/mistapi/orgs_stats_vpn_peers_test.go new file mode 100644 index 00000000..e878a66c --- /dev/null +++ b/mistapi/orgs_stats_vpn_peers_test.go @@ -0,0 +1,58 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsStatsVPNPeersTestCountOrgPeerPathStats tests the behavior of the OrgsStatsVPNPeers +func TestOrgsStatsVPNPeersTestCountOrgPeerPathStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := orgsStatsVpnPeers.CountOrgPeerPathStats(ctx, orgId, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsStatsVPNPeersTestSearchOrgPeerPathStats tests the behavior of the OrgsStatsVPNPeers +func TestOrgsStatsVPNPeersTestSearchOrgPeerPathStats(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsStatsVpnPeers.SearchOrgPeerPathStats(ctx, orgId, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1619518989.4989712,"limit":10,"results":[{"auth_algo":"hmac-sha1-96","enc_algo":"aes-cbc-128","ike_version":"1","is_active":true,"last_seen":1619518709.222,"mac":"020001c04668","org_id":"0c160b7f-1027-4cd1-923b-744534c4b070","peer_mac":"020001367edd","peer_port_id":"DC_Internet","peer_site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","port_id":"Lte","site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","type":"svr","up":true,"uptime":1527128046},{"is_active":true,"last_seen":1619518709.222,"latency":91,"mac":"020001c04668","mos":436,"mtu":1500,"org_id":"0c160b7f-1027-4cd1-923b-744534c4b070","peer_mac":"020001367edd","peer_port_id":"DC_Internet","peer_router_name":"RIDCBBP1","peer_site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","port_id":"Lte","router_name":"RIST01544AP1","site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","type":"svr","up":true,"uptime":1527128046}],"start":1619518689.4989705,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_subscriptions_test.go b/mistapi/orgs_subscriptions_test.go new file mode 100644 index 00000000..3b0a364c --- /dev/null +++ b/mistapi/orgs_subscriptions_test.go @@ -0,0 +1,36 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsSubscriptionsTestUnsubscribeOrgAlarmsReports tests the behavior of the OrgsSubscriptions +func TestOrgsSubscriptionsTestUnsubscribeOrgAlarmsReports(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSubscriptions.UnsubscribeOrgAlarmsReports(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsSubscriptionsTestSubscribeOrgAlarmsReports tests the behavior of the OrgsSubscriptions +func TestOrgsSubscriptionsTestSubscribeOrgAlarmsReports(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsSubscriptions.SubscribeOrgAlarmsReports(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_test.go b/mistapi/orgs_test.go new file mode 100644 index 00000000..c3e9f85d --- /dev/null +++ b/mistapi/orgs_test.go @@ -0,0 +1,138 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsTestCreateOrg tests the behavior of the Orgs +func TestOrgsTestCreateOrg(t *testing.T) { + ctx := context.Background() + var body models.Org + errBody := json.Unmarshal([]byte(`{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"name":"string","session_expiry":1440}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgs.CreateOrg(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTestDeleteOrg tests the behavior of the Orgs +func TestOrgsTestDeleteOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgs.DeleteOrg(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsTestGetOrg tests the behavior of the Orgs +func TestOrgsTestGetOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgs.GetOrg(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTestUpdateOrg tests the behavior of the Orgs +func TestOrgsTestUpdateOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Org + errBody := json.Unmarshal([]byte(`{"alarmtemplate_id":"1984805d-2be2-4aec-a8d4-3ddf67fab0df","allow_mist":true,"name":"string","orggroup_ids":[],"session_expiry":1440}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgs.UpdateOrg(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTestCloneOrg tests the behavior of the Orgs +func TestOrgsTestCloneOrg(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NameString + errBody := json.Unmarshal([]byte(`{"name":"New Org"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgs.CloneOrg(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","allow_mist":true,"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"session_expiry":1440}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTestSearchOrgEvents tests the behavior of the Orgs +func TestOrgsTestSearchOrgEvents(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + duration := "1d" + limit := int(100) + apiResponse, err := orgs.SearchOrgEvents(ctx, orgId, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_tickets_test.go b/mistapi/orgs_tickets_test.go new file mode 100644 index 00000000..99d40879 --- /dev/null +++ b/mistapi/orgs_tickets_test.go @@ -0,0 +1,211 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsTicketsTestListOrgTickets tests the behavior of the OrgsTickets +func TestOrgsTicketsTestListOrgTickets(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := orgsTickets.ListOrgTickets(ctx, orgId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestCreateOrgTicket tests the behavior of the OrgsTickets +func TestOrgsTicketsTestCreateOrgTicket(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Ticket + errBody := json.Unmarshal([]byte(`{"comment":"string","subject":"string","type":"question"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsTickets.CreateOrgTicket(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestCountOrgTickets tests the behavior of the OrgsTickets +func TestOrgsTicketsTestCountOrgTickets(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.OrgTicketsCountDistinctEnum("status") + apiResponse, err := orgsTickets.CountOrgTickets(ctx, orgId, &distinct) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestGetOrgTicket tests the behavior of the OrgsTickets +func TestOrgsTicketsTestGetOrgTicket(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ticketId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := orgsTickets.GetOrgTicket(ctx, orgId, ticketId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestUpdateOrgTicket tests the behavior of the OrgsTickets +func TestOrgsTicketsTestUpdateOrgTicket(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ticketId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Ticket + errBody := json.Unmarshal([]byte(`{"comment":"string","subject":"string","type":"question"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsTickets.UpdateOrgTicket(ctx, orgId, ticketId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestUploadrgTicketAttachment tests the behavior of the OrgsTickets +func TestOrgsTicketsTestUploadrgTicketAttachment(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ticketId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := orgsTickets.UploadrgTicketAttachment(ctx, orgId, ticketId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsTicketsTestGetOrgTicketAttachment tests the behavior of the OrgsTickets +func TestOrgsTicketsTestGetOrgTicketAttachment(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ticketId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + attachmentId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := orgsTickets.GetOrgTicketAttachment(ctx, orgId, ticketId, attachmentId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"content_url":"https://api.mist.com/api/v1/forward/download?jwt=..."}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsTicketsTestAddOrgTicketComment tests the behavior of the OrgsTickets +func TestOrgsTicketsTestAddOrgTicketComment(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + ticketId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + comment := "this is urgent" + + apiResponse, err := orgsTickets.AddOrgTicketComment(ctx, orgId, ticketId, &comment, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"comments":[{"attachments":[{"content_type":"string","content_url":"string","size":0}],"author":"string","comment":"string","created_at":0}],"created_at":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","requester":"string","status":"open","subject":"string","type":"string","updated_at":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_user_ma_cs_test.go b/mistapi/orgs_user_ma_cs_test.go new file mode 100644 index 00000000..3004ed0c --- /dev/null +++ b/mistapi/orgs_user_ma_cs_test.go @@ -0,0 +1,120 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsUserMACsTestCreateOrgUserMacs tests the behavior of the OrgsUserMACs +func TestOrgsUserMACsTestCreateOrgUserMacs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsUserMaCs.CreateOrgUserMacs(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"added":["921b638445cd"],"errors":["921b638445ce - mac invalid","921b638445cf - mac already provided"],"updated":["721b638445ef","721b638445ee"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsUserMACsTestSearchOrgUserMacs tests the behavior of the OrgsUserMACs +func TestOrgsUserMACsTestSearchOrgUserMacs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + limit := int(100) + page := int(1) + apiResponse, err := orgsUserMaCs.SearchOrgUserMacs(ctx, orgId, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"limit":100,"page":1,"results":[{"id":"111cafd2-ba1b-5169-bfcb-9cdf1d473ddb","labels":["flor1","bld4"],"mac":"921b638445cd","notes":"mac address refers to Canon printers","vlan":"30"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsUserMACsTestDeleteOrgUserMac tests the behavior of the OrgsUserMACs +func TestOrgsUserMACsTestDeleteOrgUserMac(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + usermacId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsUserMaCs.DeleteOrgUserMac(ctx, orgId, usermacId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsUserMACsTestGetOrgUserMac tests the behavior of the OrgsUserMACs +func TestOrgsUserMACsTestGetOrgUserMac(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + usermacId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsUserMaCs.GetOrgUserMac(ctx, orgId, usermacId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"111cafd2-ba1b-5169-bfcb-9cdf1d473ddb","labels":["flor1","bld4"],"mac":"921b638445cd","notes":"mac address refers to Canon printers","vlan":"30"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsUserMACsTestUpdateOrgUserMac tests the behavior of the OrgsUserMACs +func TestOrgsUserMACsTestUpdateOrgUserMac(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + usermacId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsUserMaCs.UpdateOrgUserMac(ctx, orgId, usermacId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"111cafd2-ba1b-5169-bfcb-9cdf1d473ddb","labels":["flor1","bld4"],"mac":"921b638445cd","notes":"mac address refers to Canon printers","vlan":"30"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_vars_test.go b/mistapi/orgs_vars_test.go new file mode 100644 index 00000000..1013918b --- /dev/null +++ b/mistapi/orgs_vars_test.go @@ -0,0 +1,33 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsVarsTestSearchOrgVars tests the behavior of the OrgsVars +func TestOrgsVarsTestSearchOrgVars(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + limit := int(100) + page := int(1) + apiResponse, err := orgsVars.SearchOrgVars(ctx, orgId, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1693952979,"limit":10,"results":[{"created_time":1618457655.3848579,"modified_time":1693610886.4778049,"org_id":"0c160b7f-1027-4cd1-923b-744534c4b070","site_id":"1519f016-4e41-47c0-a396-cce4d04bac0b","src":"site","var":"mvp"}],"start":1693949379,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_vp_ns_test.go b/mistapi/orgs_vp_ns_test.go new file mode 100644 index 00000000..dd0210d7 --- /dev/null +++ b/mistapi/orgs_vp_ns_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsVPNsTestListOrgsVpns tests the behavior of the OrgsVPNs +func TestOrgsVPNsTestListOrgsVpns(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsVpNs.ListOrgsVpns(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"name":"string","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"lte","ip":"string"}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsVPNsTestCreateOrgVpns tests the behavior of the OrgsVPNs +func TestOrgsVPNsTestCreateOrgVpns(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Vpn + errBody := json.Unmarshal([]byte(`{"name":"string","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"lte","ip":"string"}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsVpNs.CreateOrgVpns(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"497f6eca-6276-5009-bfeb-53cbbbba6f1b","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"broadband","ip":"string"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsVPNsTestDeleteOrgVpn tests the behavior of the OrgsVPNs +func TestOrgsVPNsTestDeleteOrgVpn(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vpnId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsVpNs.DeleteOrgVpn(ctx, orgId, vpnId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsVPNsTestGetOrgVpn tests the behavior of the OrgsVPNs +func TestOrgsVPNsTestGetOrgVpn(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vpnId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsVpNs.GetOrgVpn(ctx, orgId, vpnId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"497f6eca-6276-5009-bfeb-53cbbbba6f1b","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"broadband","ip":"string"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsVPNsTestUpdateOrgVpn tests the behavior of the OrgsVPNs +func TestOrgsVPNsTestUpdateOrgVpn(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vpnId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Vpn + errBody := json.Unmarshal([]byte(`{"name":"string","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"broadband","ip":"string"}}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsVpNs.UpdateOrgVpn(ctx, orgId, vpnId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"497f6eca-6276-5009-bfeb-53cbbbba6f1b","modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"broadband","ip":"string"}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_webhooks_test.go b/mistapi/orgs_webhooks_test.go new file mode 100644 index 00000000..166eb16b --- /dev/null +++ b/mistapi/orgs_webhooks_test.go @@ -0,0 +1,202 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsWebhooksTestListOrgWebhooks tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestListOrgWebhooks(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWebhooks.ListOrgWebhooks(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestCreateOrgWebhook tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestCreateOrgWebhook(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWebhooks.CreateOrgWebhook(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestDeleteOrgWebhook tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestDeleteOrgWebhook(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWebhooks.DeleteOrgWebhook(ctx, orgId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWebhooksTestGetOrgWebhook tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestGetOrgWebhook(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWebhooks.GetOrgWebhook(ctx, orgId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestUpdateOrgWebhook tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestUpdateOrgWebhook(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWebhooks.UpdateOrgWebhook(ctx, orgId, webhookId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestCountOrgWebhooksDeliveries tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestCountOrgWebhooksDeliveries(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + status := models.WebhookDeliveryStatusEnum("failure") + topic := models.WebhookDeliveryTopicEnum("audits") + distinct := models.WebhookDeliveryDistinctEnum("webhook_id") + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsWebhooks.CountOrgWebhooksDeliveries(ctx, orgId, webhookId, nil, nil, &status, &topic, &distinct, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestSearchOrgWebhooksDeliveries tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestSearchOrgWebhooksDeliveries(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + status := models.WebhookDeliveryStatusEnum("failure") + topic := models.WebhookDeliveryTopicEnum("audits") + + + duration := "1d" + limit := int(100) + apiResponse, err := orgsWebhooks.SearchOrgWebhooksDeliveries(ctx, orgId, webhookId, nil, nil, &status, &topic, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1688035193,"limit":10,"results":[{"error":"string","id":"55b0f02f-ebf6-4ad2-8b10-200508a97581","org_id":"fc7e2967-e7ef-41e6-b007-1217713de05a","req_headers":"{\\\"Content-Type\\\":[\\\"application/json\\\"],\\\"User-Agent\\\":[\\\"Mist-webhook\\\"]}","req_payload":"{\\\"topic\\\":\\\"audits\\\",\\\"events\\\":[{\\\"admin_name\\\":\\\"John Doe john.doe@juniper.net\\\",\\\"after\\\":\\\"{\\\\\"radio_config\\\\\": {\\\\\"band_24\\\\\": {\\\\\"disabled\\\\\": false, \\\\\"allow_rrm_disable\\\\\": false, \\\\\"power_min\\\\\": null, \\\\\"power_max\\\\\": null, \\\\\"power\\\\\": 10, \\\\\"preamble\\\\\": \\\\\"short\\\\\", \\\\\"channels\\\\\": [1, 10], \\\\\"bandwidth\\\\\": 20}}}\\\",\\\"before\\\":\\\"{\\\\\"radio_config\\\\\": {\\\\\"band_24\\\\\": {\\\\\"disabled\\\\\": false, \\\\\"allow_rrm_disable\\\\\": false, \\\\\"power_min\\\\\": 8, \\\\\"power_max\\\\\": 18, \\\\\"power\\\\\": null, \\\\\"preamble\\\\\": \\\\\"long\\\\\", \\\\\"channels\\\\\": [1, 10], \\\\\"bandwidth\\\\\": 20}}}\\\",\\\"id\\\":\\\"737909a2-04ff-4aeb-b9da-cc924e74a4dd\\\",\\\"message\\\":\\\"Update Site Settings\\\",\\\"org_id\\\":\\\"fc7e2967-e7ef-41e6-b007-1217713de05a\\\",\\\"site_id\\\":\\\"256c3a35-9cb7-436e-bc6d-314972645d95\\\",\\\"site_name\\\":\\\"Test Site\\\",\\\"src_ip\\\":\\\"1.2.3.4\\\",\\\"timestamp\\\":1685956576.923601,\\\"user_agent\\\":\\\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36\\\"}]}","req_url":"http://example.com","resp_body":"Ok","resp_headers":"string","site_id":"256c3a35-9cb7-436e-bc6d-314972645d95","status":"success","status_code":200,"timestamp":1687962508.5836561,"topic":"audits","webhook_id":"7a11b901-f719-4c91-8aef-deb8699a6364"}],"start":1687948793,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWebhooksTestPingOrgWebhook tests the behavior of the OrgsWebhooks +func TestOrgsWebhooksTestPingOrgWebhook(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWebhooks.PingOrgWebhook(ctx, orgId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_wlan_templates_test.go b/mistapi/orgs_wlan_templates_test.go new file mode 100644 index 00000000..2bb10dcd --- /dev/null +++ b/mistapi/orgs_wlan_templates_test.go @@ -0,0 +1,149 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsWLANTemplatesTestListOrgTemplates tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestListOrgTemplates(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWlanTemplates.ListOrgTemplates(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"applies":{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"created_time":0,"deviceprofile_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"exceptions":{"site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"filter_by_deviceprofile":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWLANTemplatesTestCreateOrgTemplate tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestCreateOrgTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWlanTemplates.CreateOrgTemplate(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"applies":{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"created_time":0,"deviceprofile_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"exceptions":{"site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"filter_by_deviceprofile":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWLANTemplatesTestDeleteOrgTemplate tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestDeleteOrgTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + templateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWlanTemplates.DeleteOrgTemplate(ctx, orgId, templateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWLANTemplatesTestGetOrgTemplate tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestGetOrgTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + templateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWlanTemplates.GetOrgTemplate(ctx, orgId, templateId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"applies":{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"created_time":0,"deviceprofile_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"exceptions":{"site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"filter_by_deviceprofile":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWLANTemplatesTestUpdateOrgTemplate tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestUpdateOrgTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + templateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWlanTemplates.UpdateOrgTemplate(ctx, orgId, templateId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"applies":{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"created_time":0,"deviceprofile_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"exceptions":{"site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"filter_by_deviceprofile":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWLANTemplatesTestCloneOrgTemplate tests the behavior of the OrgsWLANTemplates +func TestOrgsWLANTemplatesTestCloneOrgTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + templateId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NameString + errBody := json.Unmarshal([]byte(`{"name":"Cloned"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsWlanTemplates.CloneOrgTemplate(ctx, orgId, templateId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"applies":{"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"created_time":0,"deviceprofile_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"exceptions":{"site_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"]},"filter_by_deviceprofile":true,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_wlans.go b/mistapi/orgs_wlans.go index f7847064..c5006313 100644 --- a/mistapi/orgs_wlans.go +++ b/mistapi/orgs_wlans.go @@ -401,3 +401,44 @@ func (o *OrgsWlans) UpdateOrgWlanPortalTemplate( result, err = utilities.DecodeResults[models.WlanPortalTemplate](decoder) return models.NewApiResponse(result, resp), err } + +// SiteOrgWlanPortalImage takes context, siteId, wlanId as parameters and +// returns an models.ApiResponse with data and +// an error if there was an issue with the request or response. +// Delete Site WLAN Portal Image +func (o *OrgsWlans) SiteOrgWlanPortalImage( + ctx context.Context, + siteId uuid.UUID, + wlanId uuid.UUID) ( + *http.Response, + error) { + req := o.prepareRequest( + ctx, + "DELETE", + fmt.Sprintf("/api/v1/sites/%v/wlans/%v/portal_image", siteId, wlanId), + ) + req.Authenticate( + NewOrAuth( + NewAuth("apiToken"), + NewAuth("basicAuth"), + NewAndAuth( + NewAuth("basicAuth"), + NewAuth("csrfToken"), + ), + + ), + ) + req.AppendErrors(map[string]https.ErrorBuilder[error]{ + "400": {Message: "Bad Syntax", Unmarshaller: errors.NewResponseHttp400}, + "401": {Message: "Unauthorized", Unmarshaller: errors.NewResponseHttp401Error}, + "403": {Message: "Permission Denied", Unmarshaller: errors.NewResponseHttp403Error}, + "404": {Message: "Not found. The API endpoint doesn’t exist or resource doesn’ t exist", Unmarshaller: errors.NewResponseHttp404}, + "429": {Message: "Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold", Unmarshaller: errors.NewResponseHttp429Error}, + }) + + context, err := req.Call() + if err != nil { + return context.Response, err + } + return context.Response, err +} diff --git a/mistapi/orgs_wlans_test.go b/mistapi/orgs_wlans_test.go new file mode 100644 index 00000000..a33a7824 --- /dev/null +++ b/mistapi/orgs_wlans_test.go @@ -0,0 +1,183 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsWlansTestListOrgWlans tests the behavior of the OrgsWlans +func TestOrgsWlansTestListOrgWlans(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWlans.ListOrgWlans(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestOrgsWlansTestCreateOrgWlan tests the behavior of the OrgsWlans +func TestOrgsWlansTestCreateOrgWlan(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWlans.CreateOrgWlan(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWlansTestDeleteOrgWlan tests the behavior of the OrgsWlans +func TestOrgsWlansTestDeleteOrgWlan(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWlans.DeleteOrgWlan(ctx, orgId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWlansTestGetOrgWLAN tests the behavior of the OrgsWlans +func TestOrgsWlansTestGetOrgWLAN(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWlans.GetOrgWLAN(ctx, orgId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWlansTestUpdateOrgWlan tests the behavior of the OrgsWlans +func TestOrgsWlansTestUpdateOrgWlan(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Wlan + errBody := json.Unmarshal([]byte(`{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10,20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsWlans.UpdateOrgWlan(ctx, orgId, wlanId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWlansTestDeleteOrgWlanPortalImage tests the behavior of the OrgsWlans +func TestOrgsWlansTestDeleteOrgWlanPortalImage(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWlans.DeleteOrgWlanPortalImage(ctx, orgId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWlansTestUpdateOrgWlanPortalTemplate tests the behavior of the OrgsWlans +func TestOrgsWlansTestUpdateOrgWlanPortalTemplate(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWlans.UpdateOrgWlanPortalTemplate(ctx, orgId, wlanId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"portal_template":{"accessCodeAlternateEmail":"string","alignment":"left","authButtonAmazon":"string","authButtonAzure":"string","authButtonEmail":"string","authButtonFacebook":"string","authButtonGoogle":"string","authButtonMicrosoft":"string","authButtonPassphrase":"string","authButtonSms":"string","authButtonSponsor":"string","authLabel":"string","backLink":"string","color":"string","colorDark":"string","colorLight":"string","company":true,"companyError":"string","companyLabel":"string","email":true,"emailAccessDomainError":"string","emailCancel":"string","emailCodeError":"string","emailError":"string","emailFieldLabel":"string","emailLabel":"string","emailMessage":"string","emailSubmit":"string","emailTitle":"string","field1":true,"field1Error":"string","field1Label":"string","field1Required":true,"field2":true,"field2Error":"string","field2Label":"string","field2Required":true,"field3":true,"field3Error":"string","field3Label":"string","field3Required":true,"field4":true,"field4Error":"string","field4Label":"string","field4Required":true,"message":"string","name":true,"nameError":"string","nameLabel":"string","optout":true,"optoutLabel":"string","pageTitle":"string","passphraseCancel":"string","passphraseError":"string","passphraseLabel":"string","passphraseMessage":"string","passphraseSubmit":"string","passphraseTitle":"string","poweredBy":true,"requiredFieldLabel":"string","signInLabel":"string","smsCarrierDefault":"string","smsCarrierError":"string","smsCarrierFieldLabel":"string","smsCodeCancel":"string","smsCodeError":"string","smsCodeFieldLabel":"string","smsCodeMessage":"string","smsCodeSubmit":"string","smsCodeTitle":"string","smsCountryFieldLabel":"string","smsCountryFormat":"string","smsHaveAccessCode":"string","smsMessageFormat":"string","smsNumberCancel":"string","smsNumberError":"string","smsNumberFieldLabel":"string","smsNumberFormat":"string","smsNumberMessage":"string","smsNumberSubmit":"string","smsNumberTitle":"string","smsUsernameFormat":"string","smsValidityDuration":5,"sponsorBackLink":"string","sponsorCancel":"string","sponsorEmail":"string","sponsorEmailError":"string","sponsorEmailTemplate":"string","sponsorInfoApproved":"string","sponsorInfoDenied":"string","sponsorInfoPending":"string","sponsorName":"string","sponsorNameError":"string","sponsorNotePending":"string","sponsorStatusApproved":"string","sponsorStatusDenied":"string","sponsorStatusPending":"string","sponsorSubmit":"string","tos":true,"tosAcceptLabel":"string","tosError":"string","tosLink":"string","tosText":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWlansTestSiteOrgWlanPortalImage tests the behavior of the OrgsWlans +func TestOrgsWlansTestSiteOrgWlanPortalImage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWlans.SiteOrgWlanPortalImage(ctx, siteId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/orgs_wx_rules_test.go b/mistapi/orgs_wx_rules_test.go new file mode 100644 index 00000000..a7b0c056 --- /dev/null +++ b/mistapi/orgs_wx_rules_test.go @@ -0,0 +1,148 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsWxRulesTestListOrgWxRules tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestListOrgWxRules(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWxRules.ListOrgWxRules(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53ebbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxRulesTestCreateOrgWxRule tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestCreateOrgWxRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanRule + errBody := json.Unmarshal([]byte(`{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"order":1,"src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsWxRules.CreateOrgWxRule(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxRulesTestGetOrgWxRulesDerived tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestGetOrgWxRulesDerived(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxRules.GetOrgWxRulesDerived(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53ebbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxRulesTestDeleteOrgWxRule tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestDeleteOrgWxRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWxRules.DeleteOrgWxRule(ctx, orgId, wxruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWxRulesTestGetOrgWxRule tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestGetOrgWxRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxRules.GetOrgWxRule(ctx, orgId, wxruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxRulesTestUpdateOrgWxRule tests the behavior of the OrgsWxRules +func TestOrgsWxRulesTestUpdateOrgWxRule(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanRule + errBody := json.Unmarshal([]byte(`{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"order":1,"src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsWxRules.UpdateOrgWxRule(ctx, orgId, wxruleId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/orgs_wx_tags_test.go b/mistapi/orgs_wx_tags_test.go new file mode 100644 index 00000000..c6036fcc --- /dev/null +++ b/mistapi/orgs_wx_tags_test.go @@ -0,0 +1,166 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestOrgsWxTagsTestListOrgWxTags tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestListOrgWxTags(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWxTags.ListOrgWxTags(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTagsTestCreateOrgWxTag tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestCreateOrgWxTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanTag + errBody := json.Unmarshal([]byte(`{"match":"app","name":"match app","type":"match","values":["gmail","dropbox"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := orgsWxTags.CreateOrgWxTag(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTagsTestGetOrgApplicationList tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestGetOrgApplicationList(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxTags.GetOrgApplicationList(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"group":"Emails","key":"gmail","name":"Gmail - web/app"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTagsTestDeleteOrgWxTag tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestDeleteOrgWxTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWxTags.DeleteOrgWxTag(ctx, orgId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWxTagsTestGetOrgWxTag tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestGetOrgWxTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxTags.GetOrgWxTag(ctx, orgId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTagsTestUpdateOrgWxTag tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestUpdateOrgWxTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWxTags.UpdateOrgWxTag(ctx, orgId, wxtagId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTagsTestGetOrgCurrentMatchingClientsOfAWxTag tests the behavior of the OrgsWxTags +func TestOrgsWxTagsTestGetOrgCurrentMatchingClientsOfAWxTag(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxTags.GetOrgCurrentMatchingClientsOfAWxTag(ctx, orgId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/orgs_wx_tunnels_test.go b/mistapi/orgs_wx_tunnels_test.go new file mode 100644 index 00000000..86844db7 --- /dev/null +++ b/mistapi/orgs_wx_tunnels_test.go @@ -0,0 +1,118 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestOrgsWxTunnelsTestListOrgWxTunnels tests the behavior of the OrgsWxTunnels +func TestOrgsWxTunnelsTestListOrgWxTunnels(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := orgsWxTunnels.ListOrgWxTunnels(ctx, orgId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":1500,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTunnelsTestCreateOrgWxTunnel tests the behavior of the OrgsWxTunnels +func TestOrgsWxTunnelsTestCreateOrgWxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWxTunnels.CreateOrgWxTunnel(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTunnelsTestDeleteOrgWxTunnel tests the behavior of the OrgsWxTunnels +func TestOrgsWxTunnelsTestDeleteOrgWxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := orgsWxTunnels.DeleteOrgWxTunnel(ctx, orgId, wxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestOrgsWxTunnelsTestGetOrgWxTunnel tests the behavior of the OrgsWxTunnels +func TestOrgsWxTunnelsTestGetOrgWxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := orgsWxTunnels.GetOrgWxTunnel(ctx, orgId, wxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestOrgsWxTunnelsTestUpdateOrgWxTunnel tests the behavior of the OrgsWxTunnels +func TestOrgsWxTunnelsTestUpdateOrgWxTunnel(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := orgsWxTunnels.UpdateOrgWxTunnel(ctx, orgId, wxtunnelId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/samples_webhooks_test.go b/mistapi/samples_webhooks_test.go new file mode 100644 index 00000000..90003eee --- /dev/null +++ b/mistapi/samples_webhooks_test.go @@ -0,0 +1,354 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSamplesWebhooksTestAlarms tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestAlarms(t *testing.T) { + ctx := context.Background() + var body models.WebhookAlarms + errBody := json.Unmarshal([]byte(`{"events":[{"aps":["string"],"bssids":["string"],"count":0,"event_id":"a7a26ff2-e851-45b6-9634-d595f45458b7","for_site":true,"id":"489f6eca-6276-4993-bfeb-c3cbbbba1f08","last_seen":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","ssids":["string"],"timestamp":0,"type":"string","update":true}],"topic":"alarms"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.Alarms(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestAssetRaw tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestAssetRaw(t *testing.T) { + ctx := context.Background() + var body models.WebhookAssetRaw + errBody := json.Unmarshal([]byte(`{"events":[{"asset_id":"b4695157-0d1d-4da0-8f9e-5c53149389e4","beam":0,"device_id":"3bafab7b-4400-4bcf-8e6e-09f954699940","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","mfg_company_id":0,"mfg_data":"string","rssi":0,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","timestamp":0}],"topic":"asset-raw"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.AssetRaw(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestAudits tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestAudits(t *testing.T) { + ctx := context.Background() + var body models.WebhookAudits + errBody := json.Unmarshal([]byte(`{"events":[{"admin_name":"admin_name8","device_id":"00000380-0000-0000-0000-000000000000","id":"0000122a-0000-0000-0000-000000000000","message":"message0","org_id":"00001302-0000-0000-0000-000000000000","site_id":"00000290-0000-0000-0000-000000000000","src_ip":"src_ip6","timestamp":157.68}],"topic":"audits"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.Audits(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestClientInfo tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestClientInfo(t *testing.T) { + ctx := context.Background() + var body models.WebhookClientInfo + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"string","ap_name":"string","band":"string","bssid":"string","connect":0,"connect_float":0,"mac":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rssi":0,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string","ssid":"string","timestamp":0,"version":0,"wlan_id":"5028e92b-fc59-4056-91d1-ea4b4ca1617a"}],"topic":"client-info"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.ClientInfo(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestClientJoin tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestClientJoin(t *testing.T) { + ctx := context.Background() + var body models.WebhookClientJoin + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"string","ap_name":"string","band":"string","bssid":"string","connect":0,"connect_float":0,"mac":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rssi":0,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string","ssid":"string","timestamp":0,"version":0,"wlan_id":"5028e92b-fc59-4056-91d1-ea4b4ca1617a"}],"topic":"client-join"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.ClientJoin(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestClientLatency tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestClientLatency(t *testing.T) { + ctx := context.Background() + var body models.WebhookClientLatency + errBody := json.Unmarshal([]byte(`{"events":[{"avg_auth":0.17170219,"avg_dhcp":0.017828934,"avg_dns":0.024532124,"max_auth":0.18170219,"max_dhcp":0.027828934,"max_dns":0.029532124,"min_auth":0.16050219,"min_dhcp":0.015828934,"min_dns":0.022532124,"org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1696401600}],"topic":"client-latency"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.ClientLatency(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestClientSessions tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestClientSessions(t *testing.T) { + ctx := context.Background() + var body models.WebhookClientSessions + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"string","ap_name":"string","band":"string","bssid":"string","client_family":"string","client_manufacture":"string","client_model":"string","client_os":"string","connect":0,"connect_float":0,"disconnect":0,"disconnect_float":0,"duration":0,"mac":"string","next_ap":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rssi":0,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string","ssid":"string","termination_reason":0,"timestamp":0,"version":0,"wlan_id":"5028e92b-fc59-4056-91d1-ea4b4ca1617a"}],"topic":"client-sessions"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.ClientSessions(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestDeviceEvents tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestDeviceEvents(t *testing.T) { + ctx := context.Background() + var body models.WebhookDeviceEvents + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"string","ap_name":"string","audit_id":"78c04fa6-cfb4-46a0-9aa5-3681ba4f3897","device_name":"string","device_type":"ap","ev_type":"notice","mac":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","reason":"string","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string","text":"string","timestamp":0,"type":"string"}],"topic":"device_events"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.DeviceEvents(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestDeviceUpDown tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestDeviceUpDown(t *testing.T) { + ctx := context.Background() + var body models.WebhookDeviceUpdowns + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"string","ap_name":"string","for_site":true,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string","timestamp":0,"type":"string"}],"topic":"device-updowns"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.DeviceUpDown(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestDiscoveredRawRssi tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestDiscoveredRawRssi(t *testing.T) { + ctx := context.Background() + var body models.WebhookDiscoveredRawRssi + errBody := json.Unmarshal([]byte(`{"events":[{"ap_loc":[0],"beam":0,"device_id":"3bafab7b-4400-4bcf-8e6e-09f954699940","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","is_asset":true,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","mfg_company_id":"string","mfg_data":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rssi":0,"service_packets":[{"service_data":"string","service_uuid":"7138cc00-c611-4dec-a05e-5c4b1cae13c0"}],"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","timestamp":0}],"topic":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.DiscoveredRawRssi(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocation tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocation(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocation + errBody := json.Unmarshal([]byte(`{"events":[{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","id":"487f6eca-6276-4993-bfeb-e3cbbbba3f08","mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","mfg_company_id":0,"mfg_data":"string","name":"string","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","timestamp":0,"type":"string","x":0,"y":0}],"topic":"location"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.Location(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocationAsset tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocationAsset(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocationAsset + errBody := json.Unmarshal([]byte(`{"events":[{"battery_voltage":3370,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_url":"https://www.abc.com","ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","mac":"7fc2936fd243","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","mfg_company_id":935,"mfg_data":"648520a1020000","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1461220784,"type":"asset","x":13.5,"y":3.2}],"topic":"location_asset"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.LocationAsset(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocationCentrak tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocationCentrak(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocationCentrak + errBody := json.Unmarshal([]byte(`{"events":[{"mac":"5684dae9ac8b","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1461220784,"type":"wifi","wifi_beacon_extended_info":[{"frame_ctrl":776,"payload":"............","seq_ctrl":772}],"x":13.5,"y":3.2}],"topic":"location_centrak"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.LocationCentrak(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocationClient tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocationClient(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocationClient + errBody := json.Unmarshal([]byte(`{"events":[{"mac":"5684dae9ac8b","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1461220784,"type":"wifi","wifi_beacon_extended_info":[{"frame_ctrl":776,"payload":"............","seq_ctrl":772}],"x":13.5,"y":3.2}],"topic":"location_client"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.LocationClient(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocationSdk tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocationSdk(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocationSdk + errBody := json.Unmarshal([]byte(`{"events":[{"id":"de87bf9d-183f-e383-cc68-6ba43947d403","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","name":"optional","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1461220784,"type":"sdk","x":13.5,"y":3.2}],"topic":"location_sdk"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.LocationSdk(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestLocationUnclient tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestLocationUnclient(t *testing.T) { + ctx := context.Background() + var body models.WebhookLocationUnclient + errBody := json.Unmarshal([]byte(`{"events":[{"mac":"5684dae9ac8b","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1461220784,"type":"wifi","wifi_beacon_extended_info":[{"frame_ctrl":776,"payload":"............","seq_ctrl":772}],"x":13.5,"y":3.2}],"topic":"location_unclient"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.LocationUnclient(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestNacAccounting tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestNacAccounting(t *testing.T) { + ctx := context.Background() + var body models.WebhookNacAccounting + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"5c5b355005be","auth_type":"eap-tls","bssid":"5c5b35546bb4","client_ip":"172.16.87.4","client_type":"wireless","mac":"6e795836d5f9","nas_vendor":"juniper-mist","org_id":"625aba64-fe72-4b14-8985-cbf31ec3d78a","rx_pkts":9523,"site_id":"ec9d1e85-af24-43f9-8d65-d620580e8631","ssid":"Test-CMR SSID","timestamp":1547235620.89,"tx_pkts":5233,"type":"NAC_ACCOUNTING_STOP","username":"hi"}],"topic":"nac-accounting"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.NacAccounting(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestNacEvents tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestNacEvents(t *testing.T) { + ctx := context.Background() + var body models.WebhookNacEvents + errBody := json.Unmarshal([]byte(`{"events":[{"ap":"5c5b35513227","auth_type":"802.1X","bssid":"5c5b355fafcc","dryrun_nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264012","dryrun_nacrule_matched":true,"idp_id":"912ef72e-2239-4996-b81e-469e87a27cd6","idp_role":["itsuperusers","vip"],"mac":"ac3eb179e535","nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264c62","nacrule_matched":true,"nas_vendor":"juniper-mist","org_id":"27547ac2-d114-4e04-beb1-f3f1e6e81ec6","random_mac":true,"resp_attrs":["Tunnel-Type=VLAN","Tunnel-Medium-Type=IEEE-802","Tunnel-Private-Group-Id=750","User-Name=anonymous"],"site_id":"441a1214-6928-442a-8e92-e1d34b8ec6a6","ssid":"##mist_nac","timestamp":1691512031.3581879,"type":"NAC_CLIENT_PERMIT","username":"user@deaflyz.net","vlan":"750"}],"topic":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.NacEvents(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestOccupancyAlerts tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestOccupancyAlerts(t *testing.T) { + ctx := context.Background() + var body models.WebhookOccupancyAlerts + errBody := json.Unmarshal([]byte(`{"events":[{"alert_events":[{"current_occupancy":0,"map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","occupancy_limit":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","timestamp":0,"type":"COMPLIANCE-VIOLATION","zone_id":"4495020a-236f-46e0-9453-e3f9cc6476f4","zone_name":"string"}],"for_site":true,"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","site_name":"string"}],"topic":"occupancy-alerts"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.OccupancyAlerts(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestPing tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestPing(t *testing.T) { + ctx := context.Background() + var body models.WebhookPing + errBody := json.Unmarshal([]byte(`{"events":[{"id":"487f6eca-6276-4993-bfeb-f3cbbbba4f08","name":"string","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","timestamp":0}],"topic":"ping"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.Ping(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestSdkclientScanData tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestSdkclientScanData(t *testing.T) { + ctx := context.Background() + var body models.WebhookSdkclientScanData + errBody := json.Unmarshal([]byte(`{"events":[{"connection_ap":"5c5b352f587e","connection_band":"2.4","connection_bssid":"5c5b352b51b4","connection_channel":11,"connection_rssi":-87,"last_seen":1592333828,"mac":"70ef0071535f","scan_data":[{"ap":"5c5b352f587e","band":"2.4","bssid":"5c5b352b51b4","channel":11,"rssi":-87,"ssid":"mist-wifi","timestamp":1592333828},{"ap":"5c5b352f587e","band":"5","bssid":"5c5b352b51b8","channel":36,"rssi":-75,"ssid":"mist-wifi","timestamp":1592333828}],"site_id":"93986f10-773b-42be-9438-8d3e6d127f1a"}],"topic":"sdkclient_scan_data"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.SdkclientScanData(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestSiteSle tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestSiteSle(t *testing.T) { + ctx := context.Background() + var body models.WebhookSiteSle + errBody := json.Unmarshal([]byte(`{"events":[{"org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","sle":{"ap-availability":0.6,"successful-connect":0.7,"time-to-connect":0.9},"timestamp":1694620800}],"topic":"site_sle"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.SiteSle(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSamplesWebhooksTestZone tests the behavior of the SamplesWebhooks +func TestSamplesWebhooksTestZone(t *testing.T) { + ctx := context.Background() + var body models.WebhookZone + errBody := json.Unmarshal([]byte(`{"events":[{"asset_id":"b4695157-0d1d-4da0-8f9e-5c53149389e4","id":"485f6eca-6276-4993-bfeb-54cbbbba5f08","mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","timestamp":0,"trigger":"enter","type":"string","zone_id":"4495020a-236f-46e0-9453-e3f9cc6476f4"}],"topic":"zone"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := samplesWebhooks.Zone(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/self_account_test.go b/mistapi/self_account_test.go new file mode 100644 index 00000000..70c91362 --- /dev/null +++ b/mistapi/self_account_test.go @@ -0,0 +1,71 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSelfAccountTestDeleteSelf tests the behavior of the SelfAccount +func TestSelfAccountTestDeleteSelf(t *testing.T) { + ctx := context.Background() + resp, err := selfAccount.DeleteSelf(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSelfAccountTestGetSelf tests the behavior of the SelfAccount +func TestSelfAccountTestGetSelf(t *testing.T) { + ctx := context.Background() + apiResponse, err := selfAccount.GetSelf(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfAccountTestUpdateSelf tests the behavior of the SelfAccount +func TestSelfAccountTestUpdateSelf(t *testing.T) { + ctx := context.Background() + var body models.Admin + errBody := json.Unmarshal([]byte(`{"email":"john.smith@mycorp.net","first_name":"John","last_name":"Smith","persona":"security","phone":"14081112222","phone2":"14083334444"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := selfAccount.UpdateSelf(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"admin_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","email":"user@example.com","first_name":"string","last_name":"string","privileges":[{"msp_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","msp_name":"string","name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","org_name":"string","orggroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"role":"admin","scope":"org","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfAccountTestUpdateSelfEmail tests the behavior of the SelfAccount +func TestSelfAccountTestUpdateSelfEmail(t *testing.T) { + ctx := context.Background() + var body models.EmailString + errBody := json.Unmarshal([]byte(`{"email":"new@mistsys.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := selfAccount.UpdateSelfEmail(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/self_alarms_test.go b/mistapi/self_alarms_test.go new file mode 100644 index 00000000..27015681 --- /dev/null +++ b/mistapi/self_alarms_test.go @@ -0,0 +1,21 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestSelfAlarmsTestListAlarmSubscriptions tests the behavior of the SelfAlarms +func TestSelfAlarmsTestListAlarmSubscriptions(t *testing.T) { + ctx := context.Background() + apiResponse, err := selfAlarms.ListAlarmSubscriptions(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/self_api_token_test.go b/mistapi/self_api_token_test.go new file mode 100644 index 00000000..3a3dce90 --- /dev/null +++ b/mistapi/self_api_token_test.go @@ -0,0 +1,106 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSelfAPITokenTestListApiTokens tests the behavior of the SelfAPIToken +func TestSelfAPITokenTestListApiTokens(t *testing.T) { + ctx := context.Background() + apiResponse, err := selfApiToken.ListApiTokens(ctx) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1626875902,"id":"864f351a-1377-4ad9-83f8-72f3fe6199ba","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfAPITokenTestCreateApiToken tests the behavior of the SelfAPIToken +func TestSelfAPITokenTestCreateApiToken(t *testing.T) { + ctx := context.Background() + var body models.UserApitoken + errBody := json.Unmarshal([]byte(`{"name":"org_token_xyz"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := selfApiToken.CreateApiToken(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1626875902,"id":"864f351a-1377-4ad9-83f8-72f3fe6199ba","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfAPITokenTestDeleteApiToken tests the behavior of the SelfAPIToken +func TestSelfAPITokenTestDeleteApiToken(t *testing.T) { + ctx := context.Background() + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := selfApiToken.DeleteApiToken(ctx, apitokenId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSelfAPITokenTestGetApiToken tests the behavior of the SelfAPIToken +func TestSelfAPITokenTestGetApiToken(t *testing.T) { + ctx := context.Background() + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := selfApiToken.GetApiToken(ctx, apitokenId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1626875902,"id":"864f351a-1377-4ad9-83f8-72f3fe6199ba","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfAPITokenTestUpdateApiToken tests the behavior of the SelfAPIToken +func TestSelfAPITokenTestUpdateApiToken(t *testing.T) { + ctx := context.Background() + apitokenId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UserApitoken + errBody := json.Unmarshal([]byte(`{"name":"org_token_xyz"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := selfApiToken.UpdateApiToken(ctx, apitokenId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1626875902,"id":"864f351a-1377-4ad9-83f8-72f3fe6199ba","key":"1qkb...QQCL","last_used":1690115110,"name":"org_token_xyz"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/self_audit_logs_test.go b/mistapi/self_audit_logs_test.go new file mode 100644 index 00000000..5bd7d1df --- /dev/null +++ b/mistapi/self_audit_logs_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "testing" +) + +// TestSelfAuditLogsTestListSelfAuditLogs tests the behavior of the SelfAuditLogs +func TestSelfAuditLogsTestListSelfAuditLogs(t *testing.T) { + ctx := context.Background() + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := selfAuditLogs.ListSelfAuditLogs(ctx, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"page":1,"results":[{"admin_id":"72bfa2bd-e58a-4670-9d20-a1468f7a6f58","admin_name":"test@mistsys.com","after":{"auth":{"type":"open"}},"before":{"auth":{"type":"psk"}},"id":"c6f9347b-b0a4-4a23-b927-fa9249f2ffb2","message":"Update WLAN \"Corporate\"","org_id":"423f6eca-6276-4994-bfeb-53cbbbba6f04","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","timestamp":1431382121}],"start":1428939600,"total":135}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/self_mfa_test.go b/mistapi/self_mfa_test.go new file mode 100644 index 00000000..8cbe1a2c --- /dev/null +++ b/mistapi/self_mfa_test.go @@ -0,0 +1,51 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSelfMFATestGenerateSecretFor2faVerification tests the behavior of the SelfMFA +func TestSelfMFATestGenerateSecretFor2faVerification(t *testing.T) { + ctx := context.Background() + by := models.MfaSecretTypeEnum("qrcode") + apiResponse, err := selfMfa.GenerateSecretFor2faVerification(ctx, &by) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"two_factor_secret":"NRMTSTRWNBVECY3GJVYEY3DDJFRGSNCZGJUDO4RVN5FDM3DUMJSA"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSelfMFATestGenerateSecretFor2faVerification1 tests the behavior of the SelfMFA +func TestSelfMFATestGenerateSecretFor2faVerification1(t *testing.T) { + ctx := context.Background() + by := models.MfaSecretTypeEnum("qrcode") + apiResponse, err := selfMfa.GenerateSecretFor2faVerification(ctx, &by) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/octet-stream"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSelfMFATestVerifyTwoFactor tests the behavior of the SelfMFA +func TestSelfMFATestVerifyTwoFactor(t *testing.T) { + ctx := context.Background() + + resp, err := selfMfa.VerifyTwoFactor(ctx, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_alarms_test.go b/mistapi/sites_alarms_test.go new file mode 100644 index 00000000..6304907c --- /dev/null +++ b/mistapi/sites_alarms_test.go @@ -0,0 +1,198 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesAlarmsTestAckSiteMultipleAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestAckSiteMultipleAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesAlarms.AckSiteMultipleAlarms(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestAckSiteAllAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestAckSiteAllAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesAlarms.AckSiteAllAlarms(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestCountSiteAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestCountSiteAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.AlarmCountDisctinctEnum("type") + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesAlarms.CountSiteAlarms(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesAlarmsTestSearchSiteAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestSearchSiteAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesAlarms.SearchSiteAlarms(ctx, siteId, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesAlarmsTestUnackSiteMultipleAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestUnackSiteMultipleAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesAlarms.UnackSiteMultipleAlarms(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestUnackSiteAllArlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestUnackSiteAllArlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.NoteString + errBody := json.Unmarshal([]byte(`{"note":"maintenance window"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := sitesAlarms.UnackSiteAllArlarms(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestAckSiteAlarm tests the behavior of the SitesAlarms +func TestSitesAlarmsTestAckSiteAlarm(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesAlarms.AckSiteAlarm(ctx, siteId, alarmId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestUnackSiteAlarm tests the behavior of the SitesAlarms +func TestSitesAlarmsTestUnackSiteAlarm(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + alarmId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesAlarms.UnackSiteAlarm(ctx, siteId, alarmId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestUnsubscribeSiteAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestUnsubscribeSiteAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesAlarms.UnsubscribeSiteAlarms(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAlarmsTestSubscribeSiteAlarms tests the behavior of the SitesAlarms +func TestSitesAlarmsTestSubscribeSiteAlarms(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesAlarms.SubscribeSiteAlarms(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_ap_templates_test.go b/mistapi/sites_ap_templates_test.go new file mode 100644 index 00000000..8cc780cf --- /dev/null +++ b/mistapi/sites_ap_templates_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesAPTemplatesTestGetSiteApTemplateDerived tests the behavior of the SitesAPTemplates +func TestSitesAPTemplatesTestGetSiteApTemplateDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesApTemplates.GetSiteApTemplateDerived(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ap_matching":{"enabled":true,"rules":[{"match_model":"string","name":"string","port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}}}]},"created_time":0,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53cbbbba8f08","modified_time":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":true,"enable_arp_spoof":true,"enable_shared_radio_scanning":false,"enabled":true,"locate_connected":false,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":true,"mesh_enabled":true,"proxy_arp":false}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_applications_test.go b/mistapi/sites_applications_test.go new file mode 100644 index 00000000..9562a006 --- /dev/null +++ b/mistapi/sites_applications_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesApplicationsTestListSiteApps tests the behavior of the SitesApplications +func TestSitesApplicationsTestListSiteApps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesApplications.ListSiteApps(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"group":"string","key":"string","name":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_asset_filters_test.go b/mistapi/sites_asset_filters_test.go new file mode 100644 index 00000000..d16b99ea --- /dev/null +++ b/mistapi/sites_asset_filters_test.go @@ -0,0 +1,116 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesAssetFiltersTestListSiteAssetFilters tests the behavior of the SitesAssetFilters +func TestSitesAssetFiltersTestListSiteAssetFilters(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesAssetFilters.ListSiteAssetFilters(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesAssetFiltersTestCreateSiteAssetFilters tests the behavior of the SitesAssetFilters +func TestSitesAssetFiltersTestCreateSiteAssetFilters(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesAssetFilters.CreateSiteAssetFilters(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesAssetFiltersTestDeleteSiteAssetFilter tests the behavior of the SitesAssetFilters +func TestSitesAssetFiltersTestDeleteSiteAssetFilter(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesAssetFilters.DeleteSiteAssetFilter(ctx, siteId, assetfilterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAssetFiltersTestGetSiteAssetFilter tests the behavior of the SitesAssetFilters +func TestSitesAssetFiltersTestGetSiteAssetFilter(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesAssetFilters.GetSiteAssetFilter(ctx, siteId, assetfilterId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesAssetFiltersTestUpdateSiteAssetFilter tests the behavior of the SitesAssetFilters +func TestSitesAssetFiltersTestUpdateSiteAssetFilter(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetfilterId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesAssetFilters.UpdateSiteAssetFilter(ctx, siteId, assetfilterId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"disasbled":true,"eddystone_uid_namespace":"string","eddystone_url":"string","for_site":true,"ibeacon_major":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mfg_company_id":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_assets_test.go b/mistapi/sites_assets_test.go new file mode 100644 index 00000000..55867720 --- /dev/null +++ b/mistapi/sites_assets_test.go @@ -0,0 +1,151 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesAssetsTestListSiteAssets tests the behavior of the SitesAssets +func TestSitesAssetsTestListSiteAssets(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesAssets.ListSiteAssets(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesAssetsTestCreateSiteAsset tests the behavior of the SitesAssets +func TestSitesAssetsTestCreateSiteAsset(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesAssets.CreateSiteAsset(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesAssetsTestImportSiteAssets tests the behavior of the SitesAssets +func TestSitesAssetsTestImportSiteAssets(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upsert := models.ImportSiteAssetsUpsertEnum("False") + + resp, err := sitesAssets.ImportSiteAssets(ctx, siteId, &upsert, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAssetsTestDeleteSiteAsset tests the behavior of the SitesAssets +func TestSitesAssetsTestDeleteSiteAsset(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesAssets.DeleteSiteAsset(ctx, siteId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesAssetsTestDeleteSiteAsset1 tests the behavior of the SitesAssets +func TestSitesAssetsTestDeleteSiteAsset1(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesAssets.DeleteSiteAsset(ctx, siteId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 201) +} + +// TestSitesAssetsTestGetSiteAsset tests the behavior of the SitesAssets +func TestSitesAssetsTestGetSiteAsset(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesAssets.GetSiteAsset(ctx, siteId, assetId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesAssetsTestUpdateSiteAsset tests the behavior of the SitesAssets +func TestSitesAssetsTestUpdateSiteAsset(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + assetId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesAssets.UpdateSiteAsset(ctx, siteId, assetId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","tag_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_beacons_test.go b/mistapi/sites_beacons_test.go new file mode 100644 index 00000000..371e39cd --- /dev/null +++ b/mistapi/sites_beacons_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesBeaconsTestListSiteBeacons tests the behavior of the SitesBeacons +func TestSitesBeaconsTestListSiteBeacons(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesBeacons.ListSiteBeacons(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":0,"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"eddystone-uid","x":0,"y":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesBeaconsTestCreateSiteBeacon tests the behavior of the SitesBeacons +func TestSitesBeaconsTestCreateSiteBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Beacon + errBody := json.Unmarshal([]byte(`{"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","name":"string","power":0,"type":"eddystone-uid","x":0,"y":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesBeacons.CreateSiteBeacon(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":0,"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"eddystone-uid","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesBeaconsTestDeleteSiteBeacons tests the behavior of the SitesBeacons +func TestSitesBeaconsTestDeleteSiteBeacons(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + beaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesBeacons.DeleteSiteBeacons(ctx, siteId, beaconId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesBeaconsTestGetSiteBeacon tests the behavior of the SitesBeacons +func TestSitesBeaconsTestGetSiteBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + beaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesBeacons.GetSiteBeacon(ctx, siteId, beaconId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":0,"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"eddystone-uid","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesBeaconsTestUpdateSiteBeacons tests the behavior of the SitesBeacons +func TestSitesBeaconsTestUpdateSiteBeacons(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + beaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Beacon + errBody := json.Unmarshal([]byte(`{"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","name":"string","power":0,"type":"eddystone-uid","x":0,"y":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesBeacons.UpdateSiteBeacons(ctx, siteId, beaconId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"eddystone_instance":"string","eddystone_namespace":"string","eddystone_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":0,"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","type":"eddystone-uid","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_clients_nac_test.go b/mistapi/sites_clients_nac_test.go new file mode 100644 index 00000000..4da70730 --- /dev/null +++ b/mistapi/sites_clients_nac_test.go @@ -0,0 +1,164 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesClientsNACTestCountSiteNacClients tests the behavior of the SitesClientsNAC +func TestSitesClientsNACTestCountSiteNacClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteNacClientsCountDistinctEnum("type") + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsNac.CountSiteNacClients(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsNACTestCountSiteNacClientEvents tests the behavior of the SitesClientsNAC +func TestSitesClientsNACTestCountSiteNacClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesClientsNac.CountSiteNacClientEvents(ctx, siteId, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsNACTestSearchSiteNacClientEvents tests the behavior of the SitesClientsNAC +func TestSitesClientsNACTestSearchSiteNacClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesClientsNac.SearchSiteNacClientEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513176951,"limit":10,"results":[{"ap":"5c5b35513227","auth_type":"eap-ttls","bssid":"5c5b355fafcc","dryrun_nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264012","dryrun_nacrule_matched":true,"idp_id":"912ef72e-2239-4996-b81e-469e87a27cd6","idp_role":["itsuperusers","vip"],"mac":"ac3eb179e535","nacrule_id":"32f27e7d-ff26-4a9b-b3d1-ff9bcb264c62","nacrule_matched":true,"nas_vendor":"juniper-mist","org_id":"27547ac2-d114-4e04-beb1-f3f1e6e81ec6","random_mac":false,"resp_attrs":["Tunnel-Type=VLAN","Tunnel-Medium-Type=IEEE-802","Tunnel-Private-Group-Id=750","User-Name=anonymous"],"site_id":"441a1214-6928-442a-8e92-e1d34b8ec6a6","ssid":"mist_nac","timestamp":1691512031.3581879,"type":"NAC_CLIENT_PERMIT","username":"user@deaflyz.net","vlan":"750"}],"start":1512572151,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsNACTestSearchSiteNacClients tests the behavior of the SitesClientsNAC +func TestSitesClientsNACTestSearchSiteNacClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsNac.SearchSiteNacClients(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513362753,"limit":3,"results":[{"ap":["5c5b35bf16bb","d4dc090041b4"],"auth_type":"eap-tls","cert_cn":["string"],"cert_issuer":["string"],"idp_id":"string","idp_role":["string"],"last_ap":"string","last_cert_cn":"string","last_cert_expiry":0,"last_cert_issuer":"string","last_nacrule_id":"string","last_nacrule_name":"string","last_nas_vendor":"string","last_ssid":"string","last_status":"string","mac":"string","nacrule_id":["string"],"nacrule_matched":true,"nacrule_name":["string"],"nas_vendor":["string"],"org_id":"31f27122-68a9-47a4-b526-8fb8a62a8acb","random_mac":true,"site_id":"832b1d74-9531-409b-ae37-4d7f3edbde92","ssid":["string"],"timestamp":1694689718.612,"type":"wireless"}],"start":1513276353,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_clients_wan_test.go b/mistapi/sites_clients_wan_test.go new file mode 100644 index 00000000..c714002e --- /dev/null +++ b/mistapi/sites_clients_wan_test.go @@ -0,0 +1,120 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesClientsWanTestCountSiteWanClientEvents tests the behavior of the SitesClientsWan +func TestSitesClientsWanTestCountSiteWanClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteWanClientEventsDistinctEnum("type") + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesClientsWan.CountSiteWanClientEvents(ctx, siteId, &distinct, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWanTestCountSiteWanClients tests the behavior of the SitesClientsWan +func TestSitesClientsWanTestCountSiteWanClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteWanClientsCountDistinctEnum("mac") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWan.CountSiteWanClients(ctx, siteId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWanTestSearchSiteWanClientEvents tests the behavior of the SitesClientsWan +func TestSitesClientsWanTestSearchSiteWanClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesClientsWan.SearchSiteWanClientEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":{"When":"2022-12-31 23:59:59.293000+00:00","ev_type":"CLIENT_IP_ASSIGNED","metadata":{},"org_id":"b0b9f142-aaba-11e6-aafc-0242ac110002","random_mac":true,"site_id":"fc656275-b157-43fd-b922-5f4f341c19bf","text":"DHCP Ack IP 192.168.88.216","wcid":"62bbfb75-10d8-49d1-dec7-d2df91624287"},"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWanTestSearchSiteWanClients tests the behavior of the SitesClientsWan +func TestSitesClientsWanTestSearchSiteWanClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWan.SearchSiteWanClients(ctx, siteId, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"When":"2022-12-31T23:59:43.497+0000","hostname":["sonoszp"],"ip":["192.168.1.139"],"last_hostname":"sonoszp","last_ip":"192.168.1.139","mfg":"Sonos","org_id":"b4e16c72-d50e-4c03-a952-a3217e231e2c","site_id":"f688779c-e335-4f88-8d7c-9c5e9964528b","wcid":"8bbe7389-212b-c65d-2208-00fab2017936"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_clients_wired_test.go b/mistapi/sites_clients_wired_test.go new file mode 100644 index 00000000..6b2d5a61 --- /dev/null +++ b/mistapi/sites_clients_wired_test.go @@ -0,0 +1,71 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesClientsWiredTestCountSiteWiredClients tests the behavior of the SitesClientsWired +func TestSitesClientsWiredTestCountSiteWiredClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteWiredClientsCountDistinctEnum("mac") + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWired.CountSiteWiredClients(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWiredTestSearchSiteWiredClients tests the behavior of the SitesClientsWired +func TestSitesClientsWiredTestSearchSiteWiredClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesClientsWired.SearchSiteWiredClients(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1648529800.8221116,"limit":1000,"results":[{"device_mac":["001122334455"],"device_mac_port":[{"device_mac":"001122334455","ip":"","port_id":"et-0/0/1","port_parent":"","start":"2020-12-10T00:07:36.262+0000","vlan":1,"when":"2022-03-29T04:56:05.172+0000"}],"ip":["11.216.202.61"],"mac":"112233445566","org_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","port_id":["et-0/0/1"],"site_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","timestamp":1571174567.807,"vlan":[0,1001]}],"start":1648443400.8221116,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_clients_wireless_test.go b/mistapi/sites_clients_wireless_test.go new file mode 100644 index 00000000..b9bce64a --- /dev/null +++ b/mistapi/sites_clients_wireless_test.go @@ -0,0 +1,242 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesClientsWirelessTestCountSiteWirelessClients tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestCountSiteWirelessClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteClientsCountDistinctEnum("device") + + + ipAddress := "192.168.1.1" + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWireless.CountSiteWirelessClients(ctx, siteId, &distinct, nil, nil, &ipAddress, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestCountSiteWirelessClientEvents tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestCountSiteWirelessClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteClientEventsCountDistinctEnum("type") + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesClientsWireless.CountSiteWirelessClientEvents(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestSearchSiteWirelessClientEvents tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestSearchSiteWirelessClientEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesClientsWireless.SearchSiteWirelessClientEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"ap":"string","band":"24","bssid":"string","channel":0,"proto":"a","ssid":"string","text":"string","timestamp":0,"type":"string","type_code":0,"wlan_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestSearchSiteWirelessClients tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestSearchSiteWirelessClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + ipAddress := "192.168.1.1" + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesClientsWireless.SearchSiteWirelessClients(ctx, siteId, nil, &ipAddress, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":17141231418.812,"limit":118,"next":"next8","results":[{"ap":["a83a79a947ee","003e73170b4c"],"app_version":["0.100.3"],"band":"5","device":["Mac"],"ftc":false,"hardware":"Apple Wi-Fi adapter","hostname":["hostname-a","hostname-b"],"ip":["10.5.23.43","192.168.0.2"],"last_ap":"a83a79a947ee","last_devuce":"Mac","last_firmware":"wl0: Jan 20 2024 04:08:41 version 20.103.12.0.8.7.171 FWID 01-e09d2675","last_hostname":"hostname-a","last_ip":"10.5.23.43","last_model":"MBP 16\\\" M1 2021","last_os":"Sonoma","last_os_version":"14.4.1 (Build 23E224)","last_psk_id":"abf7dc5c-bb51-4bb7-93b6-5547400ffe11","last_psk_name":"iot","last_ssid":"IoT SSID","last_username":"user@corp.com","last_vlan":10,"last_wlan_id":"e5d67b07-aae8-494b-8584-cbc20c8110aa","mac":"bcd074000000","mfg":"Apple","model":"MBP 16\\\" M1 2021","org_id":"1abff1aa-4571-4c1f-a409-153a1e7a7a24","os":["Sonoma"],"os_version":["14.4.1 (Build 23E224)"],"protocol":"ax","psk_id":["abf7dc5c-bb51-4bb7-93b6-5547400ffe11"],"psk_name":["iot"],"sdk_version":["0.100.3"],"site_id":"25ff5219-9be7-4db9-907d-0c9b60445147","site_ids":["25ff5219-9be7-4db9-907d-0c9b60445147"],"ssid":["IoT SSID"],"timestamp":1714124722.113,"username":["user@corp.com"],"vlan":[10]}],"start":10,"total":44}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestCountSiteWirelessClientSessions tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestCountSiteWirelessClientSessions(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteClientSessionsCountDistinctEnum("mac") + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWireless.CountSiteWirelessClientSessions(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestSearchSiteWirelessClientSessions tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestSearchSiteWirelessClientSessions(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + pskId := "000000ab-00ab-00ab-00ab-0000000000ab" + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesClientsWireless.SearchSiteWirelessClientSessions(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, &pskId, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513177200,"limit":10,"results":[{"ap":"5c5b350e0262","band":"5","client_manufacture":"Apple","connect":1565208388,"disconnect":1565208448,"duration":60.09423865,"mac":"b019c66c8348","org_id":"3139f2c2-fac6-11e5-8156-0242ac110006","site_id":"70e0f468-fc13-11e5-85ad-0242ac110008","ssid":"Dummy WLAN 2","tags":["disassociate"],"timestamp":1565208448.662,"wlan_id":"99bb4c74-f954-4f36-b844-6b030faffabc"}],"start":1511967600,"total":100}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesClientsWirelessTestGetSiteEventsForClient tests the behavior of the SitesClientsWireless +func TestSitesClientsWirelessTestGetSiteEventsForClient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesClientsWireless.GetSiteEventsForClient(ctx, siteId, clientMac, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513176951,"limit":10,"results":[{"ap":"5c5b350eb31b","band":"5","bssid":"5c5b350918f1","channel":149,"proto":"ac","ssid":"Guest","text":"Status code 0 \"Successful\"","timestamp":1513358874.667,"type":"CLIENT_DNS_OK","type_code":15,"wlan_id":"be22bba7-8e22-e1cf-5185-b880816fe2cf"}],"start":1512572151,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_device_profiles_test.go b/mistapi/sites_device_profiles_test.go new file mode 100644 index 00000000..6ca2d9e8 --- /dev/null +++ b/mistapi/sites_device_profiles_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesDeviceProfilesTestListSiteDeviceProfilesDerived tests the behavior of the SitesDeviceProfiles +func TestSitesDeviceProfilesTestListSiteDeviceProfilesDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + apiResponse, err := sitesDeviceProfiles.ListSiteDeviceProfilesDerived(ctx, siteId, &resolve) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"aeroscout":{"enabled":false,"host":"aero.pvt.net","locate_connected":true},"ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"created_time":0,"disable_eth1":false,"disable_eth2":false,"disable_eth3":false,"disable_module":false,"for_site":true,"height":0,"id":"497f6eca-6276-4993-bfeb-53cbbbba6108","ip_config":{"dns":["8.8.8.8","4.4.4.4"],"dns_suffix":[".mist.local",".mist.com"],"gateway":"10.2.1.254","gateway6":"2607:f8b0:4005:808::1","ip":"10.2.1.1","ip6":"2607:f8b0:4005:808::2004","mtu":0,"netmask":"255.255.255.0","netmask6":"/32","type":"static","type6":"static","vlan_id":1},"led":{"brightness":255,"enabled":true},"map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","mesh":{"enabled":false,"group":1,"role":"base"},"modified_time":0,"name":"string","notes":"string","ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","orientation":0,"orientation_overwrite":true,"poe_passthrough":false,"port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}},"pwr_config":{"base":0},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","type":"ap","x":0,"y":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_devices_others_test.go b/mistapi/sites_devices_others_test.go new file mode 100644 index 00000000..7e666d35 --- /dev/null +++ b/mistapi/sites_devices_others_test.go @@ -0,0 +1,90 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesDevicesOthersTestListSiteOtherDevices tests the behavior of the SitesDevicesOthers +func TestSitesDevicesOthersTestListSiteOtherDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + limit := int(100) + page := int(1) + apiResponse, err := sitesDevicesOthers.ListSiteOtherDevices(ctx, siteId, nil, nil, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1676983730,"device_mac":"001122334455","id":"ae9dee49-69e7-4710-a114-5b827a777738","mac":"5c5b35000018","model":"AP41","modified_time":1676983730,"name":"hallway","org_id":"2818e386-8dec-2562-9ede-5b8a0fbbdc71","serial":"FXLH2015150025","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","vendor":"cradlepoint"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesOthersTestCountSiteOtherDeviceEvents tests the behavior of the SitesDevicesOthers +func TestSitesDevicesOthersTestCountSiteOtherDeviceEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteOtherDeviceEventsCountDistinctEnum("mac") + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesDevicesOthers.CountSiteOtherDeviceEvents(ctx, siteId, &distinct, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesOthersTestSearchSiteOtherDeviceEvents tests the behavior of the SitesDevicesOthers +func TestSitesDevicesOthersTestSearchSiteOtherDeviceEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesDevicesOthers.SearchSiteOtherDeviceEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":{"device_mac":"string","mac":"5c5b351e13b5","org_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862a","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","text":"Plugged: The Internal 5GB (SIM1) has been inserted into Internal 1.","timestamp":547235620.89,"type":"CELLULAR_EDGE_MODEM_WAN_PLUGGED","vendor":"cradlepoint"},"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_devices_test.go b/mistapi/sites_devices_test.go new file mode 100644 index 00000000..f6802a98 --- /dev/null +++ b/mistapi/sites_devices_test.go @@ -0,0 +1,320 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesDevicesTestListSiteDevices tests the behavior of the SitesDevices +func TestSitesDevicesTestListSiteDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeWithAllEnum("ap") + + limit := int(100) + page := int(1) + apiResponse, err := sitesDevices.ListSiteDevices(ctx, siteId, &mType, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesDevicesTestCountSiteDeviceConfigHistory tests the behavior of the SitesDevices +func TestSitesDevicesTestCountSiteDeviceConfigHistory(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesDevices.CountSiteDeviceConfigHistory(ctx, siteId, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestSearchSiteDeviceConfigHistory tests the behavior of the SitesDevices +func TestSitesDevicesTestSearchSiteDeviceConfigHistory(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesDevices.SearchSiteDeviceConfigHistory(ctx, siteId, &mType, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":10,"results":[{"channel_24":11,"channel_5":100,"radio_macs":["5c5b352e000a","5c5b352e000b","5c5b352e000c"],"radios":[{"band":"24","channel":11},{"band":"5","channel":100}],"secpolicy_violated":false,"ssids":["test24","test5"],"ssids_24":["test24"],"ssids_5":["test5"],"timestamp":1531855856.643369,"version":"apfw-0.2.14754-cersei-75c8","wlans":[{"auth":"psk","bands":["24"],"id":"be22bba7-8e22-e1cf-5185-b880816fe2cf","ssid":"test24","vlan_ids":["1"]},{"auth":"psk","bands":["5"],"id":"f8c18724-4118-3487-811a-f98964988604","ssid":"test5","vlan_ids":["1"]}]}],"start":1531776183,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestCountSiteDevices tests the behavior of the SitesDevices +func TestSitesDevicesTestCountSiteDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteDevicesCountDistinctEnum("model") + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesDevices.CountSiteDevices(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestCountSiteDeviceEvents tests the behavior of the SitesDevices +func TestSitesDevicesTestCountSiteDeviceEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteDeviceEventsCountDistinctEnum("model") + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesDevices.CountSiteDeviceEvents(ctx, siteId, &distinct, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestSearchSiteDeviceEvents tests the behavior of the SitesDevices +func TestSitesDevicesTestSearchSiteDeviceEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + lastBy := "port_id" + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesDevices.SearchSiteDeviceEvents(ctx, siteId, nil, nil, nil, nil, nil, &lastBy, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":2,"next":"/api/v1/sites/8aaba0aa-09cc-44bd-9709-33b98040550c/devices/events/search?ap=5c5b350e0001&end=1531855849.000&limit=2&start=1531776183.0","results":[{"last_reboot_time":1531854327,"text":"Success","timestamp":1531855849.226722,"type":"AP_CONNECT_STATUS","type_code":2002},{"timestamp":1531854326,"type":"AP_CONFIGURED"}],"start":1531776183,"total":14}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestExportSiteDevices tests the behavior of the SitesDevices +func TestSitesDevicesTestExportSiteDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesDevices.ExportSiteDevices(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesDevicesTestCountSiteDeviceLastConfig tests the behavior of the SitesDevices +func TestSitesDevicesTestCountSiteDeviceLastConfig(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteDeviceLastConfigCountDistinctEnum("mac") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesDevices.CountSiteDeviceLastConfig(ctx, siteId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestSearchSiteDeviceLastConfigs tests the behavior of the SitesDevices +func TestSitesDevicesTestSearchSiteDeviceLastConfigs(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesDevices.SearchSiteDeviceLastConfigs(ctx, siteId, &mType, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":10,"results":[{"channel_24":11,"channel_5":100,"radio_macs":["5c5b352e000a","5c5b352e000b","5c5b352e000c"],"radios":[{"band":"24","channel":11},{"band":"5","channel":100}],"secpolicy_violated":false,"ssids":["test24","test5"],"ssids_24":["test24"],"ssids_5":["test5"],"timestamp":1531855856.643369,"version":"apfw-0.2.14754-cersei-75c8","wlans":[{"auth":"psk","bands":["24"],"id":"be22bba7-8e22-e1cf-5185-b880816fe2cf","ssid":"test24","vlan_ids":["1"]},{"auth":"psk","bands":["5"],"id":"f8c18724-4118-3487-811a-f98964988604","ssid":"test5","vlan_ids":["1"]}]}],"start":1531776183,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestRestartSiteMultipleDevices tests the behavior of the SitesDevices +func TestSitesDevicesTestRestartSiteMultipleDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsDevicesRestartMulti + errBody := json.Unmarshal([]byte(`{"device_ids":["00000000-0000-0000-1000-5c5b35584a6f","00000000-0000-0000-1000-5c5b350ea3b3"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := sitesDevices.RestartSiteMultipleDevices(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesDevicesTestGetSiteDevice tests the behavior of the SitesDevices +func TestSitesDevicesTestGetSiteDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesDevices.GetSiteDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aeroscout":{"enabled":false,"host":"aero.pvt.net","locate_connected":true},"ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"centrak":{"enabled":false},"client_bridge":{"auth":{"psk":"foryoureyesonly","type":"psk"},"enabled":false,"ssid":"Uplink-SSID"},"created_time":0,"deviceprofile_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","disable_eth1":false,"disable_eth2":false,"disable_eth3":false,"disable_module":false,"esl_config":{"cacert":"string","channel":3,"enabled":false,"host":"1.1.1.1","port":0,"type":"imagotag","verify_cert":true,"vlan_id":1},"for_site":true,"height":2.75,"id":"497f6eca-6276-4993-bfeb-53cbbbba6008","image1_url":"string","image2_url":"string","image3_url":"string","iot_config":{"A1":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A2":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A3":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A4":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"DI1":{"enabled":false,"name":"string","pullup":"internal"},"DI2":{"enabled":false,"name":"string","pullup":"internal"},"DO":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0}},"ip_config":{"dns":["8.8.8.8","4.4.4.4"],"dns_suffix":[".mist.local",".mist.com"],"gateway":"10.2.1.254","gateway6":"2607:f8b0:4005:808::1","ip":"10.2.1.1","ip6":"2607:f8b0:4005:808::2004","mtu":0,"netmask":"255.255.255.0","netmask6":"/32","type":"static","type6":"static","vlan_id":1},"led":{"brightness":255,"enabled":true},"locked":true,"map_id":"63eda950-c6da-11e4-a628-60f81dd250cc","mesh":{"enabled":false,"group":1,"role":"base"},"modified_time":0,"name":"conference room","notes":"slightly off center","ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","orientation":45,"poe_passthrough":false,"port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}},"pwr_config":{"base":2000,"prefer_usb_over_wifi":false},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","type":"ap","uplink_port_config":{"dot1x":false,"keep_wlans_up_if_down":false},"usb_config":{"cacert":"string","channel":3,"enabled":true,"host":"1.1.1.1","port":0,"type":"imagotag","verify_cert":true,"vlan_id":1},"vars":{"RADIUS_IP1":"172.31.2.5","RADIUS_SECRET":"11s64632d"},"x":53.5,"y":173.1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesTestUpdateSiteDevice tests the behavior of the SitesDevices +func TestSitesDevicesTestUpdateSiteDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesDevices.UpdateSiteDevice(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aeroscout":{"enabled":false,"host":"aero.pvt.net","locate_connected":true},"ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"centrak":{"enabled":false},"client_bridge":{"auth":{"psk":"foryoureyesonly","type":"psk"},"enabled":false,"ssid":"Uplink-SSID"},"created_time":0,"deviceprofile_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","disable_eth1":false,"disable_eth2":false,"disable_eth3":false,"disable_module":false,"esl_config":{"cacert":"string","channel":3,"enabled":false,"host":"1.1.1.1","port":0,"type":"imagotag","verify_cert":true,"vlan_id":1},"for_site":true,"height":2.75,"id":"497f6eca-6276-4993-bfeb-53cbbbba6008","image1_url":"string","image2_url":"string","image3_url":"string","iot_config":{"A1":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A2":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A3":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"A4":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0},"DI1":{"enabled":false,"name":"string","pullup":"internal"},"DI2":{"enabled":false,"name":"string","pullup":"internal"},"DO":{"enabled":false,"name":"motion","output":true,"pullup":"internal","value":0}},"ip_config":{"dns":["8.8.8.8","4.4.4.4"],"dns_suffix":[".mist.local",".mist.com"],"gateway":"10.2.1.254","gateway6":"2607:f8b0:4005:808::1","ip":"10.2.1.1","ip6":"2607:f8b0:4005:808::2004","mtu":0,"netmask":"255.255.255.0","netmask6":"/32","type":"static","type6":"static","vlan_id":1},"led":{"brightness":255,"enabled":true},"locked":true,"map_id":"63eda950-c6da-11e4-a628-60f81dd250cc","mesh":{"enabled":false,"group":1,"role":"base"},"modified_time":0,"name":"conference room","notes":"slightly off center","ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","orientation":45,"poe_passthrough":false,"port_config":{"property1":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"},"property2":{"additional_vlan_ids":[55,66],"authentication_protocol":"pap","disabled":true,"dynamic_vlan":{"default_vlan_id":999,"enabled":true,"type":"string","vlans":{"1-10":null,"user":null}},"enable_mac_auth":false,"forwarding":"all","mx_tunnel_id":"08cd7499-5841-51c8-e663-fb16b6f3b45e","mxtunnel_name":"string","port_auth":"none","port_vlan_id":1,"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"radsec":{"enabled":true,"idle_timeout":60,"mxcluster_ids":["572586b7-f97b-a22b-526c-8b97a3f609c4"],"proxy_hosts":["mxedge1.local"],"server_name":"radsec.abc.com","servers":[{"host":"1.1.1.1","port":1812}],"use_mxedge":true,"use_site_mxedge":false},"vlan_id":9,"vland_ids":[1,10,50],"wxtunnel_id":"7dae216d-7c98-a51b-e068-dd7d477b7216","wxtunnel_remote_id":"wifiguest"}},"pwr_config":{"base":2000,"prefer_usb_over_wifi":false},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","type":"ap","uplink_port_config":{"dot1x":false,"keep_wlans_up_if_down":false},"usb_config":{"cacert":"string","channel":3,"enabled":true,"host":"1.1.1.1","port":0,"type":"imagotag","verify_cert":true,"vlan_id":1},"vars":{"RADIUS_IP1":"172.31.2.5","RADIUS_SECRET":"11s64632d"},"x":53.5,"y":173.1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_devices_wan_cluster_test.go b/mistapi/sites_devices_wan_cluster_test.go new file mode 100644 index 00000000..65a527d4 --- /dev/null +++ b/mistapi/sites_devices_wan_cluster_test.go @@ -0,0 +1,81 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesDevicesWANClusterTestDeleteSiteDeviceHaCluster tests the behavior of the SitesDevicesWANCluster +func TestSitesDevicesWANClusterTestDeleteSiteDeviceHaCluster(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesDevicesWanCluster.DeleteSiteDeviceHaCluster(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesDevicesWANClusterTestGetSiteDeviceHaClusterNode tests the behavior of the SitesDevicesWANCluster +func TestSitesDevicesWANClusterTestGetSiteDeviceHaClusterNode(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesDevicesWanCluster.GetSiteDeviceHaClusterNode(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"nodes":[{"mac":"aff827549235"},{"mac":"8396cd006c8c"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesWANClusterTestCreateSiteDeviceHaCluster tests the behavior of the SitesDevicesWANCluster +func TestSitesDevicesWANClusterTestCreateSiteDeviceHaCluster(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.GatewayCluster + errBody := json.Unmarshal([]byte(`{"nodes":[{"mac":"aff827549235"},{"mac":"8396cd006c8c"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesDevicesWanCluster.CreateSiteDeviceHaCluster(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"nodes":[{"mac":"aff827549235"},{"mac":"8396cd006c8c"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_devices_wired_test.go b/mistapi/sites_devices_wired_test.go new file mode 100644 index 00000000..89bc75e7 --- /dev/null +++ b/mistapi/sites_devices_wired_test.go @@ -0,0 +1,51 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesDevicesWiredTestDeleteSiteLocalSwitchPortConfig tests the behavior of the SitesDevicesWired +func TestSitesDevicesWiredTestDeleteSiteLocalSwitchPortConfig(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesDevicesWired.DeleteSiteLocalSwitchPortConfig(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesDevicesWiredTestUpdateSiteLocalSwitchPortConfig tests the behavior of the SitesDevicesWired +func TestSitesDevicesWiredTestUpdateSiteLocalSwitchPortConfig(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.JunosPortConfig + errBody := json.Unmarshal([]byte(`{"ae_disable_lacp":true,"ae_idx":0,"aggregated":false,"description":"string","disable_autoneg":true,"duplex":"auto","dynamic_usage":"string","esilag":true,"poe_disabled":true,"speed":"auto","usage":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := sitesDevicesWired.UpdateSiteLocalSwitchPortConfig(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_devices_wired_virtual_chassis_test.go b/mistapi/sites_devices_wired_virtual_chassis_test.go new file mode 100644 index 00000000..0da0649b --- /dev/null +++ b/mistapi/sites_devices_wired_virtual_chassis_test.go @@ -0,0 +1,133 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesDevicesWiredVirtualChassisTestDeleteSiteVirtualChassis tests the behavior of the SitesDevicesWiredVirtualChassis +func TestSitesDevicesWiredVirtualChassisTestDeleteSiteVirtualChassis(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesDevicesWiredVirtualChassis.DeleteSiteVirtualChassis(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesDevicesWiredVirtualChassisTestGetSiteDeviceVirtualChassis tests the behavior of the SitesDevicesWiredVirtualChassis +func TestSitesDevicesWiredVirtualChassisTestGetSiteDeviceVirtualChassis(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesDevicesWiredVirtualChassis.GetSiteDeviceVirtualChassis(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":{"members":[{"mac":"string","member":0,"vc_ports":["string"],"vc_role":"master"}],"op":"add"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesWiredVirtualChassisTestCreateSiteVirtualChassis tests the behavior of the SitesDevicesWiredVirtualChassis +func TestSitesDevicesWiredVirtualChassisTestCreateSiteVirtualChassis(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.VirtualChassisConfig + errBody := json.Unmarshal([]byte(`{"members":[{"mac":"aff827549235","vc_ports":["xe-0/1/0"],"vc_role":"master"},{"mac":"8396cd006c8c","vc_ports":["xe-0/1/0","xe-0/1/1"],"vc_role":"backup"},{"mac":"8396cd00888c","vc_ports":["xe-0/1/0"],"vc_role":"linecard"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesDevicesWiredVirtualChassis.CreateSiteVirtualChassis(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":{"members":[{"mac":"string","member":0,"vc_ports":["string"],"vc_role":"master"}],"op":"add"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesWiredVirtualChassisTestUpdateSiteVirtualChassisMember tests the behavior of the SitesDevicesWiredVirtualChassis +func TestSitesDevicesWiredVirtualChassisTestUpdateSiteVirtualChassisMember(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.VirtualChassisUpdate + errBody := json.Unmarshal([]byte(`{"members":[{"mac":"aff827549235","member":0,"vc_ports":["xe-0/1/1"],"vc_role":"linecard"},{"mac":"8396cd00777c","vc_ports":["xe-0/1/0"],"vc_role":"linecard"}],"op":"add"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesDevicesWiredVirtualChassis.UpdateSiteVirtualChassisMember(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":{"members":[{"mac":"string","member":0,"vc_ports":["string"],"vc_role":"master"}],"op":"add"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesWiredVirtualChassisTestSetSiteVcPort tests the behavior of the SitesDevicesWiredVirtualChassis +func TestSitesDevicesWiredVirtualChassisTestSetSiteVcPort(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.VirtualChassisPort + errBody := json.Unmarshal([]byte(`{"members":[{"member":0,"vc_ports":["xe-0/1/1"]},{"member":2,"vc_ports":["xe-0/1/1"]}],"op":"delete"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := sitesDevicesWiredVirtualChassis.SetSiteVcPort(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_devices_wireless_test.go b/mistapi/sites_devices_wireless_test.go new file mode 100644 index 00000000..fdb2f6ca --- /dev/null +++ b/mistapi/sites_devices_wireless_test.go @@ -0,0 +1,78 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesDevicesWirelessTestGetSiteDeviceRadioChannels tests the behavior of the SitesDevicesWireless +func TestSitesDevicesWirelessTestGetSiteDeviceRadioChannels(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + countryCode := "US" + apiResponse, err := sitesDevicesWireless.GetSiteDeviceRadioChannels(ctx, siteId, &countryCode) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"band24_40mhz_allowed":false,"band24_channels":{"20":[1,2,3,4,5,6,7,8,9,10,11],"40":[1,2,3,4,5,6,7,8,9,10,11]},"band24_enabled":true,"band5_channels":{"20":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165],"40":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161],"80":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161],"dfs":[52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144],"outdoor":[36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165]},"band5_enabled":true,"certified":true,"code":840,"dfs_ok":true,"key":"US","name":"United States","uses":"US_FCC"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesDevicesWirelessTestGetSiteDeviceIotPort tests the behavior of the SitesDevicesWireless +func TestSitesDevicesWirelessTestGetSiteDeviceIotPort(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesDevicesWireless.GetSiteDeviceIotPort(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"A1":1,"DO":0}` + testHelper.RawBodyMatcher(t, expected, apiResponse.Response.Body) +} + +// TestSitesDevicesWirelessTestSetSiteDeviceIotPort tests the behavior of the SitesDevicesWireless +func TestSitesDevicesWirelessTestSetSiteDeviceIotPort(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesDevicesWireless.SetSiteDeviceIotPort(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"A1":1,"DO":0}` + testHelper.RawBodyMatcher(t, expected, apiResponse.Response.Body) +} diff --git a/mistapi/sites_events_test.go b/mistapi/sites_events_test.go new file mode 100644 index 00000000..6e021412 --- /dev/null +++ b/mistapi/sites_events_test.go @@ -0,0 +1,85 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesEventsTestGetSiteRoamingEvents tests the behavior of the SitesEvents +func TestSitesEventsTestGetSiteRoamingEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesEvents.GetSiteRoamingEvents(ctx, siteId, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1501023379,"limit":2,"next":"/api/v1/sites/dca0a44b-324c-11e6-a776-0243ad110007/events/fast_roam?type=success&start=1428939600&end=1428949600&limit=200&token=AAAAEgAIAAVVJh4hF8AAAARzc2lkAH%2F%2F%2F%2F0%3D","results":[{"ap_mac":"5c5b350e040b","client_mac":"dc2b2a3fb13d","fromap":"5c5b350e0569","latency":0.1874195,"ssid":"marvis_test","subtype":"CLIENT_AUTHENTICATED_11R","timestamp":1501000002283782}],"start":1500940800}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesEventsTestCountSiteSystemEvents tests the behavior of the SitesEvents +func TestSitesEventsTestCountSiteSystemEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteSystemEventsCountDistinctEnum("type") + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesEvents.CountSiteSystemEvents(ctx, siteId, &distinct, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesEventsTestSearchSiteSystemEvents tests the behavior of the SitesEvents +func TestSitesEventsTestSearchSiteSystemEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesEvents.SearchSiteSystemEvents(ctx, siteId, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"ap":"5c5b351e13b5","apfw":"5c5b351e13b5","model":"BT11-WW","org_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862a","site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","text":"Succeeding DNS query from 172.29.101.134 to 172.29.101.7 for \"portal.mistsys.com\" on vlan 1, id 60224","timestamp":1547235620.89,"type":"CLIENT_DNS_OK"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_evpn_topologies_test.go b/mistapi/sites_evpn_topologies_test.go new file mode 100644 index 00000000..666f21b4 --- /dev/null +++ b/mistapi/sites_evpn_topologies_test.go @@ -0,0 +1,120 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesEVPNTopologiesTestListSiteEvpnTopologies tests the behavior of the SitesEVPNTopologies +func TestSitesEVPNTopologiesTestListSiteEvpnTopologies(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesEvpnTopologies.ListSiteEvpnTopologies(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesEVPNTopologiesTestCreateSiteEvpnTopology tests the behavior of the SitesEVPNTopologies +func TestSitesEVPNTopologiesTestCreateSiteEvpnTopology(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.EvpnTopology + errBody := json.Unmarshal([]byte(`{"name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"mac":"5c5b35000003","role":"collapsed-core"},{"mac":"5c5b35000004","role":"collapsed-core"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesEvpnTopologies.CreateSiteEvpnTopology(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesEVPNTopologiesTestDeleteSiteEvpnTopology tests the behavior of the SitesEVPNTopologies +func TestSitesEVPNTopologiesTestDeleteSiteEvpnTopology(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesEvpnTopologies.DeleteSiteEvpnTopology(ctx, siteId, evpnTopologyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesEVPNTopologiesTestGetSiteEvpnTopology tests the behavior of the SitesEVPNTopologies +func TestSitesEVPNTopologiesTestGetSiteEvpnTopology(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesEvpnTopologies.GetSiteEvpnTopology(ctx, siteId, evpnTopologyId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesEVPNTopologiesTestUpdateSiteEvpnTopology tests the behavior of the SitesEVPNTopologies +func TestSitesEVPNTopologiesTestUpdateSiteEvpnTopology(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + evpnTopologyId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.EvpnTopology + errBody := json.Unmarshal([]byte(`{"overwrite":false,"switches":[{"mac":"5c5b35000003","role":"collapsed-core"},{"mac":"5c5b35000004","role":"none"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesEvpnTopologies.UpdateSiteEvpnTopology(ctx, siteId, evpnTopologyId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"9197ec96-4c8d-529f-c595-035895e688b2","name":"CC","overwrite":true,"pod_names":{"1":"default","2":"default"},"switches":[{"deviceprofile_id":"6a1deab1-96df-4fa2-8455-d5253f943d06","downlink_ips":["10.255.240.6","10.255.240.8"],"downlinks":["5c5b35000007","5c5b35000008"],"esilaglinks":["5c5b3500000f"],"evpn_id":1,"mac":"5c5b35000003","model":"QFX10002-36Q","role":"collapsed-core","site_id":"1916d52a-4a90-11e5-8b45-1258369c38a9","uplinks":["5c5b35000005","5c5b35000006"]}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_gateway_templates_test.go b/mistapi/sites_gateway_templates_test.go new file mode 100644 index 00000000..c998ef04 --- /dev/null +++ b/mistapi/sites_gateway_templates_test.go @@ -0,0 +1,27 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesGatewayTemplatesTestGetSiteGatewayTemplateDerived tests the behavior of the SitesGatewayTemplates +func TestSitesGatewayTemplatesTestGetSiteGatewayTemplateDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesGatewayTemplates.GetSiteGatewayTemplateDerived(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/sites_guests_test.go b/mistapi/sites_guests_test.go new file mode 100644 index 00000000..27976a69 --- /dev/null +++ b/mistapi/sites_guests_test.go @@ -0,0 +1,163 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesGuestsTestListSiteAllGuestAuthorizations tests the behavior of the SitesGuests +func TestSitesGuestsTestListSiteAllGuestAuthorizations(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesGuests.ListSiteAllGuestAuthorizations(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesGuestsTestCountSiteGuestAuthorizations tests the behavior of the SitesGuests +func TestSitesGuestsTestCountSiteGuestAuthorizations(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteGuestsCountDistinctEnum("auth_method") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesGuests.CountSiteGuestAuthorizations(ctx, siteId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesGuestsTestListSiteAllGuestAuthorizationsDerived tests the behavior of the SitesGuests +func TestSitesGuestsTestListSiteAllGuestAuthorizationsDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + crossSite := bool(false) + apiResponse, err := sitesGuests.ListSiteAllGuestAuthorizationsDerived(ctx, siteId, nil, &crossSite) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesGuestsTestSearchSiteGuestAuthorization tests the behavior of the SitesGuests +func TestSitesGuestsTestSearchSiteGuestAuthorization(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId := "00000000-0000-0000-0000-000000000000" + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesGuests.SearchSiteGuestAuthorization(ctx, siteId, &wlanId, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1531862583,"limit":2,"next":"/api/v1/sites/8aaba0aa-09cc-44bd-9709-33b98040550c/guests/search?wlan_id=88ffe630-95b8-11e8-b294-346895ed1b7d&end=1531855849.000&limit=2&start=1531776183.0","results":[{"ap":"5c5b350e0001","auth_method":"passphrase","authorized_expiring_time":1531810258.1862731,"authorized_time":1531782218,"company":"mistsystems","email":"user@mistsys.com","name":"john","ssid":"openNet","timestamp":1531782218},{"ap":"5c5b350e0001","auth_method":"facebook","authorized_expiring_time":1531810821.145,"authorized_time":1531782632,"company":"xyz inc.","email":"cool_user@yahoo.com","name":"John White","ssid":"openNet","timestamp":1531782632}],"start":1531776183,"total":14}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesGuestsTestDeleteSiteGuestAuthorization tests the behavior of the SitesGuests +func TestSitesGuestsTestDeleteSiteGuestAuthorization(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + resp, err := sitesGuests.DeleteSiteGuestAuthorization(ctx, siteId, guestMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesGuestsTestGetSiteGuestAuthorization tests the behavior of the SitesGuests +func TestSitesGuestsTestGetSiteGuestAuthorization(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + apiResponse, err := sitesGuests.GetSiteGuestAuthorization(ctx, siteId, guestMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesGuestsTestUpdateSiteGuestAuthorization tests the behavior of the SitesGuests +func TestSitesGuestsTestUpdateSiteGuestAuthorization(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + guestMac := "0000000000ab" + + apiResponse, err := sitesGuests.UpdateSiteGuestAuthorization(ctx, siteId, guestMac, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"authorized":true,"authorized_expiring_time":0,"authorized_time":0,"company":"string","email":"user@example.com","field1":"string","field2":"string","field3":"string","field4":"string","mac":"string","minutes":0,"name":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_jse_test.go b/mistapi/sites_jse_test.go new file mode 100644 index 00000000..ec0131fe --- /dev/null +++ b/mistapi/sites_jse_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesJSETestGetSiteJseInfo tests the behavior of the SitesJSE +func TestSitesJSETestGetSiteJseInfo(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesJse.GetSiteJseInfo(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cloud_name":"devcentral.juniperclouds.net","org_names":["Mist-Sys","Mist-Eng"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_licenses_test.go b/mistapi/sites_licenses_test.go new file mode 100644 index 00000000..d56d7b47 --- /dev/null +++ b/mistapi/sites_licenses_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesLicensesTestGetSiteLicenseUsage tests the behavior of the SitesLicenses +func TestSitesLicensesTestGetSiteLicenseUsage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesLicenses.GetSiteLicenseUsage(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"org_entitled":{"SUB-LOC":30,"SUB-MAN":60},"svna_enabled":true,"trial_enabled":true,"usages":{"SUB-LOC":30,"SUB-MAN":60},"vna_eligible":true,"vna_ui":true,"wvna_eligible":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_location_test.go b/mistapi/sites_location_test.go new file mode 100644 index 00000000..ea5b762f --- /dev/null +++ b/mistapi/sites_location_test.go @@ -0,0 +1,190 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesLocationTestGetSiteBeamCoverageOverview tests the behavior of the SitesLocation +func TestSitesLocationTestGetSiteBeamCoverageOverview(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId := "00000000-0000-0000-0000-000000000000" + + + duration := "1d" + resolution := models.ResolutionEnum("default") + + + apiResponse, err := sitesLocation.GetSiteBeamCoverageOverview(ctx, siteId, &mapId, nil, nil, &duration, &resolution, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"beams_means":[[1,3,3.2],[6,10,6.5]],"end":1428954000,"gridsize":1,"result_def":["x","y","beams_mean","beacons_mean","max_rssi","avg_rssi"],"results":[[1,3,3.2,18.5,-68,-70],[6,10,6.5,30,1,-72.5,-75]],"start":1428939600}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesLocationTestGetSiteMachineLearningCurrentStat tests the behavior of the SitesLocation +func TestSitesLocationTestGetSiteMachineLearningCurrentStat(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId := "00000000-0000-0000-0000-000000000000" + apiResponse, err := sitesLocation.GetSiteMachineLearningCurrentStat(ctx, siteId, &mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"current":{"Android":{"completed":36,"int":-6,"level":3,"ple":-3,"quality":"4","src":"device","timestamp":1442854794},"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"2","src":"default","timestamp":1442854704},"iPod":{"int":-10,"overwrite":true,"ple":-5,"src":"overwrite"}},"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},{"beacon_id":"7913f032-aab4-c3ae-e83e-5a2756ef4d40","current":{"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"last","src":"device","timestamp":1442854704}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesLocationTestGetSiteDefaultPlfForModels tests the behavior of the SitesLocation +func TestSitesLocationTestGetSiteDefaultPlfForModels(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesLocation.GetSiteDefaultPlfForModels(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"current":{"Android":{"completed":36,"int":-6,"level":3,"ple":-3,"quality":"4","src":"device","timestamp":1442854794},"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"2","src":"default","timestamp":1442854704},"iPod":{"int":-10,"overwrite":true,"ple":-5,"src":"overwrite"}},"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},{"beacon_id":"7913f032-aab4-c3ae-e83e-5a2756ef4d40","current":{"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"last","src":"device","timestamp":1442854704}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesLocationTestClearSiteMlOverwriteForDevice tests the behavior of the SitesLocation +func TestSitesLocationTestClearSiteMlOverwriteForDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesLocation.ClearSiteMlOverwriteForDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesLocationTestOverwriteSiteMlForDevice tests the behavior of the SitesLocation +func TestSitesLocationTestOverwriteSiteMlForDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body map[string]models.MlOverwriteAdditionalProperties + errBody := json.Unmarshal([]byte(`{"iOS":{"int":6,"ple":-3},"iPod":{"int":-10,"ple":-5}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesLocation.OverwriteSiteMlForDevice(ctx, siteId, deviceId, body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"current":{"Android":{"completed":36,"int":-6,"level":3,"ple":-3,"quality":"4","src":"device","timestamp":1442854794},"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"2","src":"default","timestamp":1442854704},"iPod":{"int":-10,"overwrite":true,"ple":-5,"src":"overwrite"}},"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},{"beacon_id":"7913f032-aab4-c3ae-e83e-5a2756ef4d40","current":{"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"last","src":"device","timestamp":1442854704}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesLocationTestClearSiteMlOverwriteForMap tests the behavior of the SitesLocation +func TestSitesLocationTestClearSiteMlOverwriteForMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesLocation.ClearSiteMlOverwriteForMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesLocationTestOverwriteSiteMlForMap tests the behavior of the SitesLocation +func TestSitesLocationTestOverwriteSiteMlForMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body map[string]models.MlOverwriteAdditionalProperties + errBody := json.Unmarshal([]byte(`{"iOS":{"int":6,"ple":-3},"iPod":{"int":-10,"ple":-5}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesLocation.OverwriteSiteMlForMap(ctx, siteId, mapId, body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"current":{"Android":{"completed":36,"int":-6,"level":3,"ple":-3,"quality":"4","src":"device","timestamp":1442854794},"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"2","src":"default","timestamp":1442854704},"iPod":{"int":-10,"overwrite":true,"ple":-5,"src":"overwrite"}},"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},{"beacon_id":"7913f032-aab4-c3ae-e83e-5a2756ef4d40","current":{"iOS":{"completed":16,"int":-6,"level":6,"ple":-3,"quality":"last","src":"device","timestamp":1442854704}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesLocationTestResetSiteMlStatsByMap tests the behavior of the SitesLocation +func TestSitesLocationTestResetSiteMlStatsByMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesLocation.ResetSiteMlStatsByMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_maps_auto_placement_test.go b/mistapi/sites_maps_auto_placement_test.go new file mode 100644 index 00000000..2fa33538 --- /dev/null +++ b/mistapi/sites_maps_auto_placement_test.go @@ -0,0 +1,175 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesMapsAutoPlacementTestDeleteSiteApAutoOrientation tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestDeleteSiteApAutoOrientation(t *testing.T) { + ctx := context.Background() + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMapsAutoPlacement.DeleteSiteApAutoOrientation(ctx, mapId, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsAutoPlacementTestStartSiteApAutoOrientation tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestStartSiteApAutoOrientation(t *testing.T) { + ctx := context.Background() + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesMapsAutoPlacement.StartSiteApAutoOrientation(ctx, mapId, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"state":"Not Started","time_queued":1675414259}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMapsAutoPlacementTestDeleteSiteApAutoplacement tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestDeleteSiteApAutoplacement(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMapsAutoPlacement.DeleteSiteApAutoplacement(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsAutoPlacementTestGetSiteApAutoPlacement tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestGetSiteApAutoPlacement(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesMapsAutoPlacement.GetSiteApAutoPlacement(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end_time":1678900362,"start_time":1678900062,"status":"done"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMapsAutoPlacementTestRunSiteApAutoplacement tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestRunSiteApAutoplacement(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesMapsAutoPlacement.RunSiteApAutoplacement(ctx, siteId, mapId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsAutoPlacementTestClearSiteApAutoOrient tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestClearSiteApAutoOrient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesMapsAutoPlacement.ClearSiteApAutoOrient(ctx, siteId, mapId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsAutoPlacementTestClearSiteApAutoplacement tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestClearSiteApAutoplacement(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesMapsAutoPlacement.ClearSiteApAutoplacement(ctx, siteId, mapId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsAutoPlacementTestConfirmSiteApLocalizationData tests the behavior of the SitesMapsAutoPlacement +func TestSitesMapsAutoPlacementTestConfirmSiteApLocalizationData(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UseAutoApValues + errBody := json.Unmarshal([]byte(`{"accept":false,"device_macs":["string"],"for":"placement"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := sitesMapsAutoPlacement.ConfirmSiteApLocalizationData(ctx, siteId, mapId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_maps_test.go b/mistapi/sites_maps_test.go new file mode 100644 index 00000000..e5fef785 --- /dev/null +++ b/mistapi/sites_maps_test.go @@ -0,0 +1,212 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesMapsTestListSiteMaps tests the behavior of the SitesMaps +func TestSitesMapsTestListSiteMaps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesMaps.ListSiteMaps(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"flags":{},"height":0,"height_m":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","latlng_br":{"lat":"string","lng":"string"},"latlng_tl":{"lat":"string","lng":"string"},"locked":true,"modified_time":0,"name":"string","occupancy_limit":0,"org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","orientation":0,"origin_x":0,"origin_y":0,"ppm":0,"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitesurvey_path":[{"coordinate":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]}],"thumbnail_url":"string","type":"image","url":"string","view":"roadmap","wall_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"wayfinding":{"micello":{"account_key":"string","default_level_id":0,"map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},"snap_to_path":true},"wayfinding_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"width":0,"width_m":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMapsTestCreateSiteMap tests the behavior of the SitesMaps +func TestSitesMapsTestCreateSiteMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Map + errBody := json.Unmarshal([]byte(`{"flags":{},"height":0,"height_m":0,"latlng_br":{"lat":"string","lng":"string"},"latlng_tl":{"lat":"string","lng":"string"},"locked":true,"name":"string","occupancy_limit":0,"orientation":0,"origin_x":0,"origin_y":0,"ppm":0,"sitesurvey_path":[{"coordinate":"string","name":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]}],"type":"image","view":"roadmap","wall_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"wayfinding":{"micello":{"account_key":"string","default_level_id":0},"snap_to_path":true},"wayfinding_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"width":0,"width_m":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesMaps.CreateSiteMap(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesMapsTestImportSiteMaps tests the behavior of the SitesMaps +func TestSitesMapsTestImportSiteMaps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + autoDeviceprofileAssignment := bool(true) + + + + apiResponse, err := sitesMaps.ImportSiteMaps(ctx, siteId, &autoDeviceprofileAssignment, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aps":[{"action":"assigned-placed","floorplan_id":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","height":3,"mac":"5c5b35000001","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","orientation":45}],"floorplans":[{"action":"imported","id":"cbdb7f0b-3be0-4872-88f9-58790b509c23","map_id":"845a23bf-bed9-e43c-4c86-6fa474be7ae5","name":"map1"}],"site_id":"4ac1dcf4-9d8b-7211-65c4-057819f0862b","summary":{"num_ap_assigned":1,"num_inv_assigned":1,"num_map_assigned":1}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMapsTestDeleteSiteMap tests the behavior of the SitesMaps +func TestSitesMapsTestDeleteSiteMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMaps.DeleteSiteMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsTestGetSiteMap tests the behavior of the SitesMaps +func TestSitesMapsTestGetSiteMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesMaps.GetSiteMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesMapsTestUpdateSiteMap tests the behavior of the SitesMaps +func TestSitesMapsTestUpdateSiteMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Map + errBody := json.Unmarshal([]byte(`{"flags":{},"height":0,"height_m":0,"latlng_br":{"lat":"string","lng":"string"},"latlng_tl":{"lat":"string","lng":"string"},"locked":true,"name":"string","occupancy_limit":0,"orientation":0,"origin_x":0,"origin_y":0,"ppm":0,"sitesurvey_path":[{"coordinate":"string","name":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]}],"type":"image","view":"roadmap","wall_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"wayfinding":{"micello":{"account_key":"string","default_level_id":0},"snap_to_path":true},"wayfinding_path":{"coordinate":"string","nodes":[{"edges":{"N2":"string"},"name":"string","position":{"x":0,"y":0}}]},"width":0,"width_m":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesMaps.UpdateSiteMap(ctx, siteId, mapId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesMapsTestDeleteSiteMapImage tests the behavior of the SitesMaps +func TestSitesMapsTestDeleteSiteMapImage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMaps.DeleteSiteMapImage(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMapsTestBulkAssignSiteApsToMap tests the behavior of the SitesMaps +func TestSitesMapsTestBulkAssignSiteApsToMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["5c5b35000001","5c5b35584a6f"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesMaps.BulkAssignSiteApsToMap(ctx, siteId, mapId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"locked":["5c5b35584a6f"],"moved":["5c5b35000001"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMapsTestImportSiteWayfindings tests the behavior of the SitesMaps +func TestSitesMapsTestImportSiteWayfindings(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesMaps.ImportSiteWayfindings(ctx, siteId, mapId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_mx_edges_test.go b/mistapi/sites_mx_edges_test.go new file mode 100644 index 00000000..4aee2838 --- /dev/null +++ b/mistapi/sites_mx_edges_test.go @@ -0,0 +1,188 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesMxEdgesTestListSiteMxEdges tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestListSiteMxEdges(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesMxEdges.ListSiteMxEdges(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"cpu_stat":{"cpus":{"cpu0":{"idle":79,"interrupt":0,"system":4,"usage":20,"user":16},"cpu1":{"idle":93,"interrupt":0,"system":4,"usage":6,"user":1}},"idle":87,"interrupt":0,"system":5,"usage":12,"user":7},"ext_ip":"116.187.144.16","id":"387804a7-3474-85ce-15a2-f9a9684c9c90","ip_stat":{"ip":"172.16.5.3","ips":{"ens192":"172.16.5.3/24,fe81::20c:29ff:fef8:d18e/64"}},"lag_stat":{"lag0":{"active_ports":["0","1"]}},"last_seen":1547437078,"magic":"ExNpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","memory_stats":{"active":1061085184,"available":4124860416,"buffers":789495808,"cached":718016512,"free":2818838528,"inactive":458158080,"swap_cached":0,"swap_free":8161062912,"swap_total":8161062912,"total":7947616256,"usage":65},"model":"ME-S2019","mxagent_registered":false,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","name":"Guest","num_tunnels":31,"port_stat":{"eth0":{"full_duplex":true,"lldp_stats":{"mgmt_addr":"122.16.3.11","port_desc":"GigabitEthernet4/0/16","port_id":"\u0005Gi4/0/16","system_desc":"Cisco IOS Software","system_name":"ME-DC2-DIS-SW"},"rx_bytes":2056,"rx_errors":0,"rx_pkts":670,"speed":1000,"tx_bytes":2056,"tx_pkts":670,"up":true},"eth1":{"up":false},"module":{"up":false}},"status":"connected","tunterm_registered":false,"tunterm_stat":{"monitoring_failed":false},"uptime":884221,"version":"0.1.2","virtualization_type":"VirtualizationVMware"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMxEdgesTestCreateSiteMxEdge tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestCreateSiteMxEdge(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesMxEdges.CreateSiteMxEdge(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"L-NpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","model":"ME-100","mxagent_registered":true,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"name":"Guest","ntp_servers":[],"oob_ip_config":{"dns":["8.8.8.8","4.4.4.4"],"gateway":"10.2.1.254","ip":"10.2.1.10","netmask":"255.255.255.0","type":"static"},"tunterm_dhcpd_config":{"2":{"enabled":true,"servers":["11.2.3.44"]},"enabled":false,"servers":["11.2.3.4"]},"tunterm_extra_routes":{"11.0.0.0/8":{"via":"10.3.3.1"}},"tunterm_ip_config":{"dns":["8.8.8.8"],"dns_suffix":[".mist.local"],"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMxEdgesTestCountSiteMxEdgeEvents tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestCountSiteMxEdgeEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteMxedgeEventsCountDistinctEnum("mxedge_id") + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesMxEdges.CountSiteMxEdgeEvents(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMxEdgesTestSearchSiteMistEdgeEvents tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestSearchSiteMistEdgeEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesMxEdges.SearchSiteMistEdgeEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1694708579,"limit":10,"page":3,"results":[{"mxcluster_id":"2815c917-58e7-472f-a190-bfd44fb58d05","mxedge_id":"00000000-0000-0000-1000-020000dc585c","org_id":"f2695c32-0e83-4936-b1b2-96fc88051213","service":"tunterm","timestamp":1694678225.927,"type":"ME_SERVICE_STOPPED"}],"start":1694622179}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMxEdgesTestDeleteSiteMxEdge tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestDeleteSiteMxEdge(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMxEdges.DeleteSiteMxEdge(ctx, siteId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMxEdgesTestGetSiteMxEdge tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestGetSiteMxEdge(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMxEdges.GetSiteMxEdge(ctx, siteId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesMxEdgesTestUpdateSiteMxEdge tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestUpdateSiteMxEdge(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesMxEdges.UpdateSiteMxEdge(ctx, siteId, mxedgeId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"95ddd29a-6a3c-929e-a431-51a5b09f36a6","magic":"L-NpT5gi-ADR8WTFd4EiQPY3cP5WdSoD","model":"ME-100","mxagent_registered":true,"mxcluster_id":"572586b7-f97b-a22b-526c-8b97a3f609c4","mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"name":"Guest","ntp_servers":[],"oob_ip_config":{"dns":["8.8.8.8","4.4.4.4"],"gateway":"10.2.1.254","ip":"10.2.1.10","netmask":"255.255.255.0","type":"static"},"tunterm_dhcpd_config":{"2":{"enabled":true,"servers":["11.2.3.44"]},"enabled":false,"servers":["11.2.3.4"]},"tunterm_extra_routes":{"11.0.0.0/8":{"via":"10.3.3.1"}},"tunterm_ip_config":{"dns":["8.8.8.8"],"dns_suffix":[".mist.local"],"gateway":"10.2.1.254","ip":"10.2.1.1","netmask":"255.255.255.0"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesMxEdgesTestUploadSiteMxEdgeSupportFiles tests the behavior of the SitesMxEdges +func TestSitesMxEdgesTestUploadSiteMxEdgeSupportFiles(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesMxEdges.UploadSiteMxEdgeSupportFiles(ctx, siteId, mxedgeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_network_templates_test.go b/mistapi/sites_network_templates_test.go new file mode 100644 index 00000000..4a1f0092 --- /dev/null +++ b/mistapi/sites_network_templates_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesNetworkTemplatesTestGetSiteNetworkTemplateDerived tests the behavior of the SitesNetworkTemplates +func TestSitesNetworkTemplatesTestGetSiteNetworkTemplateDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesNetworkTemplates.GetSiteNetworkTemplateDerived(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"additional_config_cmds":["set snmp community public"],"created_time":0,"dhcp_snooping":{"all_networks":true,"enable_arp_spoof_check":true,"enable_ip_source_guard":true,"enabled":true,"networks":["string"]},"dns_servers":["string"],"dns_suffix":["string"],"extra_routes":{"property1":{"via":"string"},"property2":{"via":"string"}},"group_tags":{},"id":"497f6eca-6276-4993-bfeb-53cbbbba6708","import_org_networks":["ap"],"mist_nac":{"enabled":true,"network":"string"},"modified_time":0,"name":"string","networks":{"property1":{"subnet":"192.168.1.0/24","vlan_id":10},"property2":{"subnet":"192.168.1.0/24","vlan_id":10}},"ntp_servers":["string"],"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"switch_mgmt":{"config_revert":10,"protect_re":{"enabled":false},"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]}},"vrf_config":{"enabled":false},"vrf_instances":{"property1":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]},"property2":{"extra_routes":{"property1":{"via":"198.51.100.1"},"property2":{"via":"198.51.100.10"}},"networks":["string"]}}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_networks_test.go b/mistapi/sites_networks_test.go new file mode 100644 index 00000000..5d42fd3d --- /dev/null +++ b/mistapi/sites_networks_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesNetworksTestListSiteNetworksDerived tests the behavior of the SitesNetworks +func TestSitesNetworksTestListSiteNetworksDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + apiResponse, err := sitesNetworks.ListSiteNetworksDerived(ctx, siteId, &resolve) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"disallow_mist_services":false,"gateway":"192.168.70.1","hosts":{"property1":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"},"property2":{"external_ips":"172.16.10.32-172.16.10.35","ips":"192.168.70.32-192.168.70.35"}},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f13","internal_access":{"enabled":true},"internet_access":{"create_simple_service_policy":false,"destination_nat":{"property1":{"internal_ip":"192.168.70.30","name":"web server","port":443},"property2":{"internal_ip":"192.168.70.30","name":"web server","port":443}},"enabled":true,"restricted":false,"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"printer-1"},"property2":{"internal_ip":"192.168.70.3","name":"printer-1"}}},"isolation":true,"modified_time":0,"name":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","subnet":"192.168.70.0/24","tenants":{"property1":{"addresses":["10.10.10.10"]},"property2":{"addresses":["10.10.10.45"]}},"vlan_id":10,"vpn_access":{"property1":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"},"property2":{"allow_ping":true,"destination_nat":{"property1":{"name":"web server","port":443,"to":"192.168.70.5/30"},"property2":{"name":"web server","port":443,"to":"192.168.70.5/30"}},"nat_pool":"172.16.0.0/26","routed":true,"source_nat":{"external_ip":"172.16.0.8/30"},"static_nat":{"property1":{"internal_ip":"192.168.70.3","name":"pos_station-1"},"property2":{"internal_ip":"192.168.70.3","name":"pos_station-1"}},"summarized_subnet":"172.16.0.0/16"}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_psks_test.go b/mistapi/sites_psks_test.go new file mode 100644 index 00000000..13d4dd63 --- /dev/null +++ b/mistapi/sites_psks_test.go @@ -0,0 +1,167 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesPsksTestListSitePsks tests the behavior of the SitesPsks +func TestSitesPsksTestListSitePsks(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + limit := int(100) + page := int(1) + apiResponse, err := sitesPsks.ListSitePsks(ctx, siteId, nil, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesPsksTestCreateSitePsk tests the behavior of the SitesPsks +func TestSitesPsksTestCreateSitePsk(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Psk + errBody := json.Unmarshal([]byte(`{"mac":"string","name":"string","passphrase":"stringst","ssid":"string","usage":"multi","vlan_id":1}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesPsks.CreateSitePsk(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesPsksTestUpdateSiteMultiplePsks tests the behavior of the SitesPsks +func TestSitesPsksTestUpdateSiteMultiplePsks(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesPsks.UpdateSiteMultiplePsks(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesPsksTestImportSitePsks tests the behavior of the SitesPsks +func TestSitesPsksTestImportSitePsks(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesPsks.ImportSitePsks(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","passphrase":"stringst","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ssid":"string","usage":"multi","vlan_id":1}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesPsksTestDeleteSitePsk tests the behavior of the SitesPsks +func TestSitesPsksTestDeleteSitePsk(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesPsks.DeleteSitePsk(ctx, siteId, pskId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesPsksTestGetSitePsk tests the behavior of the SitesPsks +func TestSitesPsksTestGetSitePsk(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesPsks.GetSitePsk(ctx, siteId, pskId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesPsksTestUpdateSitePsk tests the behavior of the SitesPsks +func TestSitesPsksTestUpdateSitePsk(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + pskId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Psk + errBody := json.Unmarshal([]byte(`{"mac":"string","name":"string","passphrase":"stringst","ssid":"string","usage":"multi","vlan_id":1}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesPsks.UpdateSitePsk(ctx, siteId, pskId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/sites_rf_templates_test.go b/mistapi/sites_rf_templates_test.go new file mode 100644 index 00000000..acbf949c --- /dev/null +++ b/mistapi/sites_rf_templates_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesRFTemplatesTestGetSiteRfTemplateDerived tests the behavior of the SitesRFTemplates +func TestSitesRFTemplatesTestGetSiteRfTemplateDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesRfTemplates.GetSiteRfTemplateDerived(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ant_gain_24":0,"ant_gain_5":0,"band_24":{"allow_rrm_disable":true,"ant_gain":0,"bandwidth":20,"channels":[1,6,11],"disabled":false,"power_max":11,"power_min":3,"preamble":"short"},"band_24_usage":"auto","band_5":{"allow_rrm_disable":false,"ant_gain":0,"bandwidth":80,"channels":[36,40,44,48,52,56,60,64,100,104,149,153,157,161],"disabled":false,"power_max":16,"power_min":9,"preamble":"short"},"country_code":"FR","created_time":1594743723,"id":"b3f20330-f76a-49f1-bc65-0d8727140b1d","model_specific":{},"modified_time":1613582192,"name":"Lab","org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_rfdiags_test.go b/mistapi/sites_rfdiags_test.go new file mode 100644 index 00000000..74e1b611 --- /dev/null +++ b/mistapi/sites_rfdiags_test.go @@ -0,0 +1,161 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesRfdiagsTestGetSiteSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestGetSiteSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesRfdiags.GetSiteSiteRfdiagRecording(ctx, siteId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[[{"asset_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","asset_name":"string","client_name":"string","duration":0,"end_time":0,"frame_count":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","next":"string","raw_events":"string","ready":true,"sdkclient_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sdkclient_name":"string","sdkclient_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","start_time":0,"type":"sdkclient","url":"string"}]]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRfdiagsTestStartSiteRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestStartSiteRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesRfdiags.StartSiteRecording(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"asset_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","asset_name":"string","client_name":"string","duration":0,"end_time":0,"frame_count":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","next":"string","raw_events":"string","ready":true,"sdkclient_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sdkclient_name":"string","sdkclient_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","start_time":0,"type":"sdkclient","url":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRfdiagsTestDeleteSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestDeleteSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rfdiagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesRfdiags.DeleteSiteRfdiagRecording(ctx, siteId, rfdiagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesRfdiagsTestGetSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestGetSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rfdiagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesRfdiags.GetSiteRfdiagRecording(ctx, siteId, rfdiagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"asset_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","asset_name":"string","client_name":"string","duration":0,"end_time":0,"frame_count":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","next":"string","raw_events":"string","ready":true,"sdkclient_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sdkclient_name":"string","sdkclient_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","start_time":0,"type":"sdkclient","url":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRfdiagsTestUpdateSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestUpdateSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rfdiagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesRfdiags.UpdateSiteRfdiagRecording(ctx, siteId, rfdiagId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"asset_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","asset_name":"string","client_name":"string","duration":0,"end_time":0,"frame_count":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","mac":"string","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","name":"string","next":"string","raw_events":"string","ready":true,"sdkclient_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sdkclient_name":"string","sdkclient_uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","start_time":0,"type":"sdkclient","url":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRfdiagsTestDownloadSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestDownloadSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rfdiagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesRfdiags.DownloadSiteRfdiagRecording(ctx, siteId, rfdiagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesRfdiagsTestStopSiteRfdiagRecording tests the behavior of the SitesRfdiags +func TestSitesRfdiagsTestStopSiteRfdiagRecording(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rfdiagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesRfdiags.StopSiteRfdiagRecording(ctx, siteId, rfdiagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_rogues_test.go b/mistapi/sites_rogues_test.go new file mode 100644 index 00000000..52d1174e --- /dev/null +++ b/mistapi/sites_rogues_test.go @@ -0,0 +1,142 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesRoguesTestListSiteRogueAPs tests the behavior of the SitesRogues +func TestSitesRoguesTestListSiteRogueAPs(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + limit := int(100) + + + duration := "1d" + interval := "10m" + apiResponse, err := sitesRogues.ListSiteRogueAPs(ctx, siteId, nil, &limit, nil, nil, &duration, &interval) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"next":"/api/v1/sites/a3eda150-ab3f-11e4-aa18-13e21dd250cc/rogues?start=1498482000&end=1498485600&limit=10&interval=1h&type=others","results":[{"ap_mac":"5c5b350e021c","avg_rssi":-72,"bssid":"d8-97-ba-76-b5-aa","channel":"11","num_aps":4,"ssid":"xfinitywifi","times_heard":8}],"start":1428939600}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRoguesTestListSiteRogueClients tests the behavior of the SitesRogues +func TestSitesRoguesTestListSiteRogueClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + + + duration := "1d" + interval := "10m" + apiResponse, err := sitesRogues.ListSiteRogueClients(ctx, siteId, &limit, nil, nil, &duration, &interval) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"next":"/api/v1/sites/a3eda150-ab3f-11e4-aa18-13e21dd250cc/rogues/clients?start=1498482000&end=1498485600&limit=10&interval=1h","results":[{"annotation":"whitelist","ap_mac":"5c-5b-35-0e-02-1c","avg_rssi":-63.9,"band":"5","bssid":"d8-97-ba-76-b5-aa","client_mac":"34-f8-32-13-57-c2","num_aps":2}],"start":1428939600}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRoguesTestCountSiteRogueEvents tests the behavior of the SitesRogues +func TestSitesRoguesTestCountSiteRogueEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteRogueEventsCountDistinctEnum("bssid") + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesRogues.CountSiteRogueEvents(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRoguesTestSearchSiteRogueEvents tests the behavior of the SitesRogues +func TestSitesRoguesTestSearchSiteRogueEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesRogues.SearchSiteRogueEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1538074800,"limit":10,"results":[{"ap":"5c5b350e10030","bssid":"38ff363c8c4c","channel":136,"rssi":-54,"ssid":"MyHomeNetwork","timestamp":1538074612},{"ap":"5c5b350e10030","bssid":"60d02c2394cc","channel":11,"rssi":-59,"ssid":"Home-Office","timestamp":1538074612}],"start":1538071200,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRoguesTestGetSiteRogueAP tests the behavior of the SitesRogues +func TestSitesRoguesTestGetSiteRogueAP(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rogueBssid := "0000000000ab" + apiResponse, err := sitesRogues.GetSiteRogueAP(ctx, siteId, rogueBssid) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"manufacture":"Intel Corporate","seen_as_client":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_rrm_test.go b/mistapi/sites_rrm_test.go new file mode 100644 index 00000000..c2c802a5 --- /dev/null +++ b/mistapi/sites_rrm_test.go @@ -0,0 +1,54 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesRRMTestGetSiteCurrentChannelPlanning tests the behavior of the SitesRRM +func TestSitesRRMTestGetSiteCurrentChannelPlanning(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesRrm.GetSiteCurrentChannelPlanning(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"band_24":{},"band_24_metric":{"avg_aps_per_channel":0,"channel_distribution_uniformity":0,"cochannel_neighbors":0,"density":0,"naps_by_channel":{},"naps_by_power":{},"neighbors":0,"noise":0},"band_5":{},"band_5_metric":{"avg_aps_per_channel":0,"channel_distribution_uniformity":0,"cochannel_neighbors":0,"density":0,"naps_by_channel":{},"naps_by_power":{},"neighbors":0,"noise":0},"rftemplate":{"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":6,"disabled":true,"power":5,"power_max":3,"power_min":18,"preamble":"auto","usage":"24"},"band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":100,"disabled":true,"power":9,"power_max":6,"power_min":17,"preamble":"auto"},"country_code":"string","created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","model_specific":{"property1":{"band_24":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":6,"disabled":true,"power":9,"power_max":6,"power_min":17,"preamble":"auto","usage":"rrm"},"band_5":{"allow_rrm_disable":true,"antenna_mode":"default","bandwidth":20,"channel":112,"disabled":true,"power":10,"power_max":6,"power_min":15,"preamble":"auto"}}},"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"},"rftemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rftemplate_name":"string","status":"updating","timestamp":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRRMTestGetSiteRrmEvents tests the behavior of the SitesRRM +func TestSitesRRMTestGetSiteRrmEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesRrm.GetSiteRrmEvents(ctx, siteId, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1428954000,"limit":100,"next":"/api/v1/sites/dca0a44b-324c-11e6-a776-0243ad110007/events/rrm?start=1428939600&end=1428949600&limit=200&token=001a0010000000120010000005005880ec18000004776c616e007fffffeb067ab8e29c1d659b6a7c8cf698bf81490003","results":[{"ap_id":"00000000-0000-0000-1000-5c5b359e4fe0","band":"24","bandwidth":20,"channel":6,"event":"scheduled-site_rrm","power":5,"pre_bandwidth":20,"pre_channel":1,"pre_power":11,"pre_usage":"24","timestamp":1428939600,"usage":"24"}],"start":1428939600}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_rssi_zones_test.go b/mistapi/sites_rssi_zones_test.go new file mode 100644 index 00000000..2e47d3aa --- /dev/null +++ b/mistapi/sites_rssi_zones_test.go @@ -0,0 +1,126 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesRSSIZonesTestListSiteRssiZones tests the behavior of the SitesRSSIZones +func TestSitesRSSIZonesTestListSiteRssiZones(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesRssiZones.ListSiteRssiZones(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesRSSIZonesTestCreateSiteRssiZone tests the behavior of the SitesRSSIZones +func TestSitesRSSIZonesTestCreateSiteRssiZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.RssiZone + errBody := json.Unmarshal([]byte(`{"devices":[{"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rssi":0}],"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesRssiZones.CreateSiteRssiZone(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"devices":[{"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rssi":0}],"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRSSIZonesTestDeleteSiteRssiZone tests the behavior of the SitesRSSIZones +func TestSitesRSSIZonesTestDeleteSiteRssiZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rssizoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesRssiZones.DeleteSiteRssiZone(ctx, siteId, rssizoneId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesRSSIZonesTestGetSiteRssiZone tests the behavior of the SitesRSSIZones +func TestSitesRSSIZonesTestGetSiteRssiZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rssizoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesRssiZones.GetSiteRssiZone(ctx, siteId, rssizoneId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"devices":[{"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rssi":0}],"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesRSSIZonesTestUpdateSiteRssiZone tests the behavior of the SitesRSSIZones +func TestSitesRSSIZonesTestUpdateSiteRssiZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rssizoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.RssiZone + errBody := json.Unmarshal([]byte(`{"devices":[{"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rssi":0}],"name":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesRssiZones.UpdateSiteRssiZone(ctx, siteId, rssizoneId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"devices":[{"device_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","rssi":0}],"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_service_policies_test.go b/mistapi/sites_service_policies_test.go new file mode 100644 index 00000000..c6d596cb --- /dev/null +++ b/mistapi/sites_service_policies_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesServicePoliciesTestListSiteServicePoliciesDerived tests the behavior of the SitesServicePolicies +func TestSitesServicePoliciesTestListSiteServicePoliciesDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + apiResponse, err := sitesServicePolicies.ListSiteServicePoliciesDerived(ctx, siteId, &resolve) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","created_time":0,"id":"string","modified_time":0,"name":"string","org_id":"string","services":["string"],"tenants":["string"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_services_test.go b/mistapi/sites_services_test.go new file mode 100644 index 00000000..a0586111 --- /dev/null +++ b/mistapi/sites_services_test.go @@ -0,0 +1,101 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesServicesTestListSiteServicesDerived tests the behavior of the SitesServices +func TestSitesServicesTestListSiteServicesDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + apiResponse, err := sitesServices.ListSiteServicesDerived(ctx, siteId, &resolve) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"addresses":["string"],"apps":["string"],"dscp":8,"hostnames":["string"],"max_jitter":0,"max_latency":0,"max_loss":0,"name":"string","specs":[{"port_range":"0","protocol":"any"}],"traffic_class":"best_effort","traffic_type":"default","type":"custom"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesServicesTestCountSiteServicePathEvents tests the behavior of the SitesServices +func TestSitesServicesTestCountSiteServicePathEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteServiceEventsCountDistinctEnum("type") + + + + + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesServices.CountSiteServicePathEvents(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesServicesTestSearchSiteServicePathEvents tests the behavior of the SitesServices +func TestSitesServicesTestSearchSiteServicePathEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesServices.SearchSiteServicePathEvents(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1697096379,"limit":10,"results":[{"mac":"90ec7734b374","model":"SSR120","org_id":"a3c6718f-2823-4e48-bf5e-b841768a4c9b","policy":"INTERNET","port_id":"ge-1/0/6","site_id":"4279edbd-1d24-41ea-9505-2eb26c8590fa","text":"Peer Path Down","timestamp":1697037328.6517749,"type":"GW_SERVICE_PATH_REMOVE","version":"6.1.5-14.lts","vpn_name":"Syracuse_HUB","vpn_path":"Syracuse_HUB-Wan0"}],"start":1697009979,"total":2}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_setting_test.go b/mistapi/sites_setting_test.go new file mode 100644 index 00000000..f28943e5 --- /dev/null +++ b/mistapi/sites_setting_test.go @@ -0,0 +1,168 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesSettingTestGetSiteSetting tests the behavior of the SitesSetting +func TestSitesSettingTestGetSiteSetting(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesSetting.GetSiteSetting(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"additional_config_cmds":["set snmp community public"],"analytic":{"enabled":false},"ap_matching":{"enabled":true,"rules":[{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}]},"ap_port_config":{"model_specific":{"AP32":{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}}},"auto_placement":{"orientation":45,"x":30,"y":60},"auto_upgrade":{"custom_versions":{"AP21":"stable","AP41":"0.1.5135","AP61":"0.1.7215"},"day_of_week":"sun","enabled":false,"time_of_day":"12:00","version":"beta"},"blacklist_url":"https://papi.s3.amazonaws.com/blacklist/xxx...","ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"config_auto_revert":false,"created_time":0,"device_updown_threshold":0,"dns_servers":["string"],"dns_suffix":["string"],"engagement":{"dwell_tag_names":{"bounce":"Bounce","engaged":"Engaged","passerby":"Passer By","stationed":"Stationed"},"dwell_tags":{"bounce":null,"engaged":"300-14400","passerby":null,"stationed":"14400-43200"},"hours":{"fri":"09:00-17:00","mon":"09:00-17:00","sat":"09:00-12:00","sun":"09:00-12:00","thu":"09:00-17:00","tue":"09:00-17:00","wed":"09:00-17:00"},"max_dwell":43200,"min_dwell":0},"evpn_options":{"auto_loopback_subnet":"100.101.0.0/16","auto_router_id_subnet":"100.100.0.0/24","core_as_border":false,"overlay":{"as":65000},"per_vlan_vga_v4_mac":false,"routed_at":"edge","underlay":{"as_base":65001,"routed_id_prefix":"/24","subnet":"10.255.240.0/20"}},"flags":{"property1":"string","property2":"string"},"for_site":true,"gateway_additional_config_cmds":["set snmp community public"],"gateway_mgmt":{"admin_sshkeys":["string"],"app_probing":{"apps":["string"],"custom_apps":[{"app_type":"string","hostname":["string"],"name":"string","protocol":"http"}],"enabled":true},"app_usage":true,"auto_signature_update":{"day_of_week":"mon","enable":true,"time_of_day":"string"},"config_revert_timer":10,"probe_hosts":["string"],"root_password":"string","security_log_source_address":"192.168.1.1","security_log_source_interface":"string"},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f09","led":{"brightness":255,"enabled":true},"modified_time":0,"mxedge":{"mist_das":{"coa_servers":[{"disable_event_timestamp_check":false,"enabled":true,"host":"string","port":3799,"secret":"string"}],"enabled":false},"radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string","ssids":["string"]}],"auth_servers":[{"host":"string","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"string","keywrap_mack":"string","port":1812,"secret":"string","ssids":["string"]}],"enabled":true,"match_ssid":true,"proxy_hosts":["string"],"server_selection":"ordered","source":"any"}},"mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"ntp_servers":["pool.ntp.org"],"occupancy":{"assets_enabled":false,"clients_enabled":true,"min_duration":3000,"sdkclients_enabled":false,"unconnected_clients_enabled":false},"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","ospf_areas":{"property1":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"},"property2":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"}},"persist_config_on_device":false,"port_mirroring":{"property1":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"},"property2":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"}},"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"proxy":{"url":"http://proxy.internal:8080/"},"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"remote_syslog":{"archive":{"files":20,"size":"5m"},"console":{"contents":[{"facility":"config","severity":"warning"}]},"enabled":false,"files":[{"archive":{"files":10,"size":"5m"},"contents":[{"facility":"config","severity":"warning"}],"explicit_priority":true,"file":"file-name","match":"!alarm|ntp|errors.crc_error[chan]","structured_data":true}],"network":"default","send_to_all_servers":false,"servers":[{"facility":"config","host":"syslogd.internal","port":514,"protocol":"udp","severity":"info","tag":""}],"time_format":"millisecond","users":[{"contents":[{"facility":"config","severity":"warning"}],"match":"\"!alarm|ntp|errors.crc_error[chan]\"","user":"*"}]},"report_gatt":false,"rogue":{"enabled":false,"honeypot_enabled":false,"min_duration":10,"min_rssi":-80,"whitelisted_bssids":["NeighborSSID"],"whitelisted_ssids":["cc:8e:6f:d4:bf:16","cc-8e-6f-d4-bf-16","cc-73-*","cc:82:*"]},"rtsa":{"app_waking":false,"disable_dead_reckoning":true,"disable_pressure_sensor":false,"enabled":true,"track_asset":false},"simple_alert":{"arp_failure":{"client_count":10,"duration":20,"incident_count":10},"dhcp_failure":{"client_count":10,"duration":10,"incident_count":20},"dns_failure":{"client_count":20,"duration":10,"incident_count":30}},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","skyatp":{"enabled":true,"send_ip_mac_mapping":true},"srx_app":{"enabled":false},"ssh_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...Wxa6p6UW0ZbcP john@host"],"ssr":{"conductor_hosts":["\"1.1.1.1\", \"2.2.2.2\""],"disable_stats":true},"status_portal":{"enabled":false,"hostnames":["my.misty.com"]},"switch_mgmt":{"ap_affinity_threshold":10,"config_revert_timer":10,"dhcp_option_fqdn":false,"mxedge_proxy_host":"string","mxedge_proxy_port":2222,"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]},"use_mxedge_proxy":true},"vars":{"RADIUS_IP1":"172.31.2.5","RADIUS_SECRET":"11s64632d"},"vna":{"enabled":false},"vrf_instances":{"guest":{"extra_routes":{"0.0.0.0/0":{"via":"192.168.31.1"}},"networks":["guest"]}},"vrrp_groups":{"property1":{"auth_key":"auth-key-1","auth_password":"string","auth_type":"md5","networks":{"data":{"ip":"10.182.96.1"},"mgmt":{"ip":"10.182.104.1"},"v10":{"ip":"10.182.104.129"},"wap":{"ip":"10.182.102.1"}}},"property2":{"auth_key":"auth-key-1","auth_password":"string","auth_type":"md5","networks":{"data":{"ip":"10.182.96.1"},"mgmt":{"ip":"10.182.104.1"},"v10":{"ip":"10.182.104.129"},"wap":{"ip":"10.182.102.1"}}}},"wan_vna":{"enabled":false},"watched_station_url":"https://papi.s3.amazonaws.com/watched_station/xxx...","whitelist_url":"https://papi.s3.amazonaws.com/whitelist/xxx...","wids":{"repeated_auth_failures":{"duration":60,"threshold":0}},"wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":false,"enable_arp_spoof_check":false,"enable_shared_radio_scanning":true,"enabled":true,"locate_connected":true,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":false,"mesh_enabled":false,"mesh_psk":"string","mesh_ssid":"string","proxy_arp":"default"},"wired_vna":{"enabled":false},"zone_occupancy_alert":{"email_notifiers":["foo@juniper.net","bar@juniper.net"],"enabled":false,"threshold":5}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSettingTestUpdateSiteSettings tests the behavior of the SitesSetting +func TestSitesSettingTestUpdateSiteSettings(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SiteSetting + errBody := json.Unmarshal([]byte(`{"additional_config_cmds":["set snmp community public"],"analytic":{"enabled":false},"ap_matching":{"enabled":true,"rules":[{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}]},"ap_port_config":{"model_specific":{"AP32":{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}}},"auto_upgrade":{"custom_versions":{"AP21":"stable","AP41":"0.1.5135","AP61":"0.1.7215"},"day_of_week":"sun","enabled":false,"time_of_day":"12:00","version":"beta"},"config_auto_revert":false,"device_updown_threshold":0,"dns_servers":["string"],"dns_suffix":["string"],"engagement":{"dwell_tag_names":{"bounce":"Bounce","engaged":"Engaged","passerby":"Passer By","stationed":"Stationed"},"dwell_tags":{"bounce":null,"engaged":"300-14400","passerby":null,"stationed":"14400-43200"},"hours":{"fri":"09:00-17:00","mon":"09:00-17:00","sat":"09:00-12:00","sun":"09:00-12:00","thu":"09:00-17:00","tue":"09:00-17:00","wed":"09:00-17:00"},"max_dwell":43200,"min_dwell":0},"evpn_options":{"auto_loopback_subnet":"100.101.0.0/16","auto_router_id_subnet":"100.100.0.0/24","core_as_border":false,"overlay":{"as":65000},"per_vlan_vga_v4_mac":false,"routed_at":"edge","underlay":{"as_base":65001,"routed_id_prefix":"/24","subnet":"10.255.240.0/20"}},"gateway_additional_config_cmds":["set snmp community public"],"gateway_mgmt":{"admin_sshkeys":["string"],"app_probing":{"apps":["string"],"custom_apps":[{"app_type":"string","hostname":["string"],"name":"string","protocol":"http"}],"enabled":true},"app_usage":true,"auto_signature_update":{"day_of_week":"any","enable":true,"time_of_day":"string"},"config_revert_timer":10,"probe_hosts":["string"],"root_password":"string","security_log_source_address":"192.168.1.1","security_log_source_interface":"string"},"led":{"brightness":255,"enabled":true},"mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"networks":{"property1":{"dns":["string"],"dns_suffix":["string"],"gateway":"string","ospf_interface_type":"string","subnet":"string","vlan_id":10,"zone":"string"},"property2":{"dns":["string"],"dns_suffix":["string"],"gateway":"string","ospf_interface_type":"string","subnet":"string","vlan_id":10,"zone":"string"}},"ntp_servers":["string"],"occupancy":{"assets_enabled":false,"clients_enabled":true,"min_duration":3000,"sdkclients_enabled":false,"unconnected_clients_enabled":false},"ospf_areas":{"property1":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"},"property2":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"}},"persist_config_on_device":false,"port_mirroring":{"property1":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"},"property2":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"}},"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"proxy":{"url":"http://proxy.internal:8080/*"},"rogue":{"enabled":false,"honeypot_enabled":false,"min_duration":10,"min_rssi":-80,"whitelisted_bssids":["NeighborSSID"],"whitelisted_ssids":["cc:8e:6f:d4:bf:16","cc-8e-6f-d4-bf-16","cc-73-*","cc:82:*"]},"simple_alert":{"arp_failure":{"client_count":10,"duration":20,"incident_count":10},"dhcp_failure":{"client_count":10,"duration":10,"incident_count":20},"dns_failure":{"client_count":20,"duration":10,"incident_count":30}},"skyatp":{"enabled":true,"send_ip_mac_mapping":true},"srx_app":{"enabled":false},"ssh_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...Wxa6p6UW0ZbcP john@host"],"ssr":{"conductor_hosts":["\"1.1.1.1\", \"2.2.2.2\""],"disable_stats":true},"status_portal":{"enabled":false,"hostnames":["my.misty.com"]},"vars":{"RADIUS_IP1":"172.31.2.5","RADIUS_SECRET":"11s64632d"},"vna":{"enabled":false},"wan_vna":{"enabled":false},"wids":{"repeated_auth_failures":{"duration":60,"threshold":0}},"wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":false,"enable_arp_spoof_check":false,"enable_shared_radio_scanning":true,"enabled":true,"locate_connected":true,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":false,"mesh_enabled":false,"mesh_psk":"string","mesh_ssid":"string","proxy_arp":"default"},"wired_vna":{"enabled":false},"zone_occupancy_alert":{"email_notifiers":["foo@juniper.net","bar@juniper.net"],"enabled":false,"threshold":5}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesSetting.UpdateSiteSettings(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"additional_config_cmds":["set snmp community public"],"analytic":{"enabled":false},"ap_matching":{"enabled":true,"rules":[{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}]},"ap_port_config":{"model_specific":{"AP32":{"eth1,eth2":{"port_vlan_id":1,"vlan_ids":[1,10,50]}}}},"auto_placement":{"orientation":45,"x":30,"y":60},"auto_upgrade":{"custom_versions":{"AP21":"stable","AP41":"0.1.5135","AP61":"0.1.7215"},"day_of_week":"sun","enabled":false,"time_of_day":"12:00","version":"beta"},"blacklist_url":"https://papi.s3.amazonaws.com/blacklist/xxx...","ble_config":{"beacon_enabled":false,"beacon_rate":3,"beacon_rate_mode":"custom","beam_disabled":[1,3,6],"custom_ble_packet_enabled":false,"custom_ble_packet_frame":"0x........","custom_ble_packet_freq_msec":300,"eddystone_uid_adv_power":-65,"eddystone_uid_beams":"2-4,7","eddystone_uid_enabled":false,"eddystone_uid_freq_msec":200,"eddystone_uid_instance":"5c5b35000001","eddystone_uid_namespace":"2818e3868dec25629ede","eddystone_url_adv_power":-65,"eddystone_url_beams":"2-4,7","eddystone_url_enabled":true,"eddystone_url_freq_msec":1000,"eddystone_url_url":"https://www.abc.com","ibeacon_adv_power":-65,"ibeacon_beams":"2-4,7","ibeacon_enabled":false,"ibeacon_freq_msec":0,"ibeacon_major":13,"ibeacon_minor":138,"ibeacon_uuid":"f3f17139-704a-f03a-2786-0400279e37c3","power":10,"power_mode":"custom"},"config_auto_revert":false,"created_time":0,"device_updown_threshold":0,"dns_servers":["string"],"dns_suffix":["string"],"engagement":{"dwell_tag_names":{"bounce":"Bounce","engaged":"Engaged","passerby":"Passer By","stationed":"Stationed"},"dwell_tags":{"bounce":null,"engaged":"300-14400","passerby":null,"stationed":"14400-43200"},"hours":{"fri":"09:00-17:00","mon":"09:00-17:00","sat":"09:00-12:00","sun":"09:00-12:00","thu":"09:00-17:00","tue":"09:00-17:00","wed":"09:00-17:00"},"max_dwell":43200,"min_dwell":0},"evpn_options":{"auto_loopback_subnet":"100.101.0.0/16","auto_router_id_subnet":"100.100.0.0/24","core_as_border":false,"overlay":{"as":65000},"per_vlan_vga_v4_mac":false,"routed_at":"edge","underlay":{"as_base":65001,"routed_id_prefix":"/24","subnet":"10.255.240.0/20"}},"flags":{"property1":"string","property2":"string"},"for_site":true,"gateway_additional_config_cmds":["set snmp community public"],"gateway_mgmt":{"admin_sshkeys":["string"],"app_probing":{"apps":["string"],"custom_apps":[{"app_type":"string","hostname":["string"],"name":"string","protocol":"http"}],"enabled":true},"app_usage":true,"auto_signature_update":{"day_of_week":"mon","enable":true,"time_of_day":"string"},"config_revert_timer":10,"probe_hosts":["string"],"root_password":"string","security_log_source_address":"192.168.1.1","security_log_source_interface":"string"},"id":"497f6eca-6276-4993-bfeb-53cbbbba6f09","led":{"brightness":255,"enabled":true},"modified_time":0,"mxedge":{"mist_das":{"coa_servers":[{"disable_event_timestamp_check":false,"enabled":true,"host":"string","port":3799,"secret":"string"}],"enabled":false},"radsec":{"acct_servers":[{"host":"string","port":1813,"secret":"string","ssids":["string"]}],"auth_servers":[{"host":"string","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"string","keywrap_mack":"string","port":1812,"secret":"string","ssids":["string"]}],"enabled":true,"match_ssid":true,"proxy_hosts":["string"],"server_selection":"ordered","source":"any"}},"mxedge_mgmt":{"mist_password":"MIST_PASSWORD","root_password":"ROOT_PASSWORD"},"ntp_servers":["pool.ntp.org"],"occupancy":{"assets_enabled":false,"clients_enabled":true,"min_duration":3000,"sdkclients_enabled":false,"unconnected_clients_enabled":false},"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","ospf_areas":{"property1":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"},"property2":{"include_loopback":false,"networks":{"corp":{"auth_keys":{"1":"auth-key-1"},"auth_type":"md5","bfd_minimum_interval":500,"dead_interval":40,"hello_interval":10,"interface_type":"nbma","metric":10000},"guest":{"passive":true}},"type":"default"}},"persist_config_on_device":false,"port_mirroring":{"property1":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"},"property2":{"input_networks_ingress":["corp"],"input_port_ids_egress":["ge-0/0/3"],"input_port_ids_ingress":["ge-0/0/3"],"output_network":"analyze","output_port_id":"ge-0/0/5"}},"port_usages":{"dynamic":{"mode":"dynamic","reset_default_when":"link_down","rules":[{"equals":"string","equals_any":["string"],"expression":"string","src":"lldp_chassis_id","usage":"string"}]},"property1":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_auth":"dot1x","port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"},"property2":{"all_networks":false,"allow_dhcpd":true,"authentication_protocol":"pap","bypass_auth_when_server_down":true,"description":"string","disable_autoneg":false,"disabled":false,"duplex":"auto","enable_mac_auth":true,"enable_qos":true,"guest_network":"string","mac_auth_only":true,"mac_limit":0,"mode":"access","mtu":0,"networks":["string"],"persist_mac":false,"poe_disabled":false,"port_network":"string","rejected_network":null,"speed":"string","storm_control":{"no_broadcast":false,"no_multicast":false,"no_registered_multicast":false,"no_unknown_unicast":false,"percentage":80},"stp_edge":true,"voip_network":"string"}},"proxy":{"url":"http://proxy.internal:8080/"},"radius_config":{"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_retries":3,"auth_servers_timeout":5,"coa_enabled":false,"coa_port":3799,"network":"string","source_ip":"string"},"remote_syslog":{"archive":{"files":20,"size":"5m"},"console":{"contents":[{"facility":"config","severity":"warning"}]},"enabled":false,"files":[{"archive":{"files":10,"size":"5m"},"contents":[{"facility":"config","severity":"warning"}],"explicit_priority":true,"file":"file-name","match":"!alarm|ntp|errors.crc_error[chan]","structured_data":true}],"network":"default","send_to_all_servers":false,"servers":[{"facility":"config","host":"syslogd.internal","port":514,"protocol":"udp","severity":"info","tag":""}],"time_format":"millisecond","users":[{"contents":[{"facility":"config","severity":"warning"}],"match":"\"!alarm|ntp|errors.crc_error[chan]\"","user":"*"}]},"report_gatt":false,"rogue":{"enabled":false,"honeypot_enabled":false,"min_duration":10,"min_rssi":-80,"whitelisted_bssids":["NeighborSSID"],"whitelisted_ssids":["cc:8e:6f:d4:bf:16","cc-8e-6f-d4-bf-16","cc-73-*","cc:82:*"]},"rtsa":{"app_waking":false,"disable_dead_reckoning":true,"disable_pressure_sensor":false,"enabled":true,"track_asset":false},"simple_alert":{"arp_failure":{"client_count":10,"duration":20,"incident_count":10},"dhcp_failure":{"client_count":10,"duration":10,"incident_count":20},"dns_failure":{"client_count":20,"duration":10,"incident_count":30}},"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","skyatp":{"enabled":true,"send_ip_mac_mapping":true},"srx_app":{"enabled":false},"ssh_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...Wxa6p6UW0ZbcP john@host"],"ssr":{"conductor_hosts":["\"1.1.1.1\", \"2.2.2.2\""],"disable_stats":true},"status_portal":{"enabled":false,"hostnames":["my.misty.com"]},"switch_mgmt":{"ap_affinity_threshold":10,"config_revert_timer":10,"dhcp_option_fqdn":false,"mxedge_proxy_host":"string","mxedge_proxy_port":2222,"root_password":"string","tacacs":{"acct_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}],"enabled":true,"network":"string","tacplus_servers":[{"host":"198.51.100.1","port":"49","secret":"string","timeout":10}]},"use_mxedge_proxy":true},"vars":{"RADIUS_IP1":"172.31.2.5","RADIUS_SECRET":"11s64632d"},"vna":{"enabled":false},"vrf_instances":{"guest":{"extra_routes":{"0.0.0.0/0":{"via":"192.168.31.1"}},"networks":["guest"]}},"vrrp_groups":{"property1":{"auth_key":"auth-key-1","auth_password":"string","auth_type":"md5","networks":{"data":{"ip":"10.182.96.1"},"mgmt":{"ip":"10.182.104.1"},"v10":{"ip":"10.182.104.129"},"wap":{"ip":"10.182.102.1"}}},"property2":{"auth_key":"auth-key-1","auth_password":"string","auth_type":"md5","networks":{"data":{"ip":"10.182.96.1"},"mgmt":{"ip":"10.182.104.1"},"v10":{"ip":"10.182.104.129"},"wap":{"ip":"10.182.102.1"}}}},"wan_vna":{"enabled":false},"watched_station_url":"https://papi.s3.amazonaws.com/watched_station/xxx...","whitelist_url":"https://papi.s3.amazonaws.com/whitelist/xxx...","wids":{"repeated_auth_failures":{"duration":60,"threshold":0}},"wifi":{"cisco_enabled":true,"disable_11k":false,"disable_radios_when_power_constrained":false,"enable_arp_spoof_check":false,"enable_shared_radio_scanning":true,"enabled":true,"locate_connected":true,"locate_unconnected":false,"mesh_allow_dfs":false,"mesh_enable_crm":false,"mesh_enabled":false,"mesh_psk":"string","mesh_ssid":"string","proxy_arp":"default"},"wired_vna":{"enabled":false},"zone_occupancy_alert":{"email_notifiers":["foo@juniper.net","bar@juniper.net"],"enabled":false,"threshold":5}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSettingTestDeleteSiteWirelessClientsBlocklist tests the behavior of the SitesSetting +func TestSitesSettingTestDeleteSiteWirelessClientsBlocklist(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesSetting.DeleteSiteWirelessClientsBlocklist(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesSettingTestCreateSiteWirelessClientsBlocklist tests the behavior of the SitesSetting +func TestSitesSettingTestCreateSiteWirelessClientsBlocklist(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesSetting.CreateSiteWirelessClientsBlocklist(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSettingTestDeleteSiteWatchedStations tests the behavior of the SitesSetting +func TestSitesSettingTestDeleteSiteWatchedStations(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesSetting.DeleteSiteWatchedStations(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesSettingTestCreateSiteWatchedStations tests the behavior of the SitesSetting +func TestSitesSettingTestCreateSiteWatchedStations(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MacAddresses + errBody := json.Unmarshal([]byte(`{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesSetting.CreateSiteWatchedStations(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSettingTestDeleteSiteWirelessClientsAllowlist tests the behavior of the SitesSetting +func TestSitesSettingTestDeleteSiteWirelessClientsAllowlist(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesSetting.DeleteSiteWirelessClientsAllowlist(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesSettingTestCreateSiteWirelessClientsAllowlist tests the behavior of the SitesSetting +func TestSitesSettingTestCreateSiteWirelessClientsAllowlist(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesSetting.CreateSiteWirelessClientsAllowlist(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"macs":["18-65-90-de-f4-c6","84-89-ad-5d-69-0d"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_site_templates_test.go b/mistapi/sites_site_templates_test.go new file mode 100644 index 00000000..9affd9bf --- /dev/null +++ b/mistapi/sites_site_templates_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesSiteTemplatesTestGetSiteSiteTemplateDerived tests the behavior of the SitesSiteTemplates +func TestSitesSiteTemplatesTestGetSiteSiteTemplateDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := sitesSiteTemplates.GetSiteSiteTemplateDerived(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"auto_upgrade":{"day_of_week":"mon","enabled":true,"time_of_day":"string","version":"string"},"name":"string","vars":{"SSID_STR":"string","VLAN_ID":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_skyatp_test.go b/mistapi/sites_skyatp_test.go new file mode 100644 index 00000000..18785e09 --- /dev/null +++ b/mistapi/sites_skyatp_test.go @@ -0,0 +1,68 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesSkyatpTestCountSiteSkyatpEvents tests the behavior of the SitesSkyatp +func TestSitesSkyatpTestCountSiteSkyatpEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteSkyAtpEventsCountDistinctEnum("type") + + + + + ipAddress := "192.168.1.1" + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesSkyatp.CountSiteSkyatpEvents(ctx, siteId, &distinct, nil, nil, nil, nil, &ipAddress, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSkyatpTestSearchSiteSkyatpEvents tests the behavior of the SitesSkyatp +func TestSitesSkyatpTestSearchSiteSkyatpEvents(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + ipAddress := "192.168.1.1" + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesSkyatp.SearchSiteSkyatpEvents(ctx, siteId, nil, nil, nil, nil, &ipAddress, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513176951,"limit":10,"results":[{"device_mac":"658279bb1fa4","ip":"172.16.0.11","mac":"b019c66c8348","org_id":"3139f2c2-fac6-11e5-8156-0242ac110006","site_id":"70e0f468-fc13-11e5-85ad-0242ac110008","threat_level":7,"timestamp":1592524478,"type":"cc"}],"start":1512572151,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_apps_test.go b/mistapi/sites_stats_apps_test.go new file mode 100644 index 00000000..1d7745a3 --- /dev/null +++ b/mistapi/sites_stats_apps_test.go @@ -0,0 +1,32 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsAppsTestCountSiteApps tests the behavior of the SitesStatsApps +func TestSitesStatsAppsTestCountSiteApps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + apiResponse, err := sitesStatsApps.CountSiteApps(ctx, siteId, nil, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_assets_test.go b/mistapi/sites_stats_assets_test.go new file mode 100644 index 00000000..c56b87d8 --- /dev/null +++ b/mistapi/sites_stats_assets_test.go @@ -0,0 +1,186 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesStatsAssetsTestListSiteAssetsStats tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestListSiteAssetsStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsAssets.ListSiteAssetsStats(ctx, siteId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","last_seen":0,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","rssizones":[{"id":"478f6eca-6276-4993-bfeb-5bcbbbbacf08","since":0}],"x":0,"y":0,"zones":[{"id":"477f6eca-6276-4993-bfeb-5ccbbbbadf08","since":0}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsAssetsTestGetSiteAssetStats tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestGetSiteAssetStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := sitesStatsAssets.GetSiteAssetStats(ctx, siteId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","last_seen":0,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","rssizones":[{"id":"480f6eca-6276-4993-bfeb-59cbbbbaaf08","since":0}],"x":0,"y":0,"zones":[{"id":"479f6eca-6276-4993-bfeb-5acbbbbabf08","since":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsAssetsTestCountSiteAssets tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestCountSiteAssets(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteAssetsCountDistinctEnum("map_id") + apiResponse, err := sitesStatsAssets.CountSiteAssets(ctx, siteId, &distinct) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsAssetsTestSearchSiteAssets tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestSearchSiteAssets(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsAssets.SearchSiteAssets(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"battery_voltage":0,"eddystone_uid_instance":"string","eddystone_uid_namespace":"string","eddystone_url_url":"string","ibeacon_major":0,"ibeacon_minor":0,"ibeacon_uuid":"1f89bc00-d0af-481b-82fe-a6629259a39f","last_seen":0,"mac":"string","map_id":"09d2b626-2e4e-45ef-a3c4-e6aeb6c83db1","name":"string","rssizones":[{"id":"476f6eca-6276-4993-bfeb-5dcbbbbaef08","since":0}],"x":0,"y":0,"zones":[{"id":"475f6eca-6276-4993-bfeb-5ecbbbbf6f08","since":0}]}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsAssetsTestListSiteDiscoveredAssets tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestListSiteDiscoveredAssets(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsAssets.ListSiteDiscoveredAssets(ctx, siteId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsAssetsTestGetSiteAssetsOfInterest tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestGetSiteAssetsOfInterest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + duration := "1d" + + + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsAssets.GetSiteAssetsOfInterest(ctx, siteId, &duration, nil, nil, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"_checkpoint_prep":0,"_checkpoint_preparer":0,"_checkpoint_scan":0,"ap_mac":"string","beam":0,"by":"string","curr_site":"string","device_name":"string","id":"string","last_seen":0,"mac":"string","manufacture":"string","map_id":"string","name":"string","rssi":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsAssetsTestGetSiteDiscoveredAssetByMap tests the behavior of the SitesStatsAssets +func TestSitesStatsAssetsTestGetSiteDiscoveredAssetByMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsAssets.GetSiteDiscoveredAssetByMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/sites_stats_beacons_test.go b/mistapi/sites_stats_beacons_test.go new file mode 100644 index 00000000..e337568c --- /dev/null +++ b/mistapi/sites_stats_beacons_test.go @@ -0,0 +1,31 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsBeaconsTestListSiteBeaconsStats tests the behavior of the SitesStatsBeacons +func TestSitesStatsBeaconsTestListSiteBeaconsStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsBeacons.ListSiteBeaconsStats(ctx, siteId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/sites_stats_bgp_peers_test.go b/mistapi/sites_stats_bgp_peers_test.go new file mode 100644 index 00000000..5fc3315b --- /dev/null +++ b/mistapi/sites_stats_bgp_peers_test.go @@ -0,0 +1,50 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsBGPPeersTestCountSiteBgpStats tests the behavior of the SitesStatsBGPPeers +func TestSitesStatsBGPPeersTestCountSiteBgpStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + apiResponse, err := sitesStatsBgpPeers.CountSiteBgpStats(ctx, siteId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsBGPPeersTestSearchSiteBgpStats tests the behavior of the SitesStatsBGPPeers +func TestSitesStatsBGPPeersTestSearchSiteBgpStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsBgpPeers.SearchSiteBgpStats(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"results":[{"evpn_overlay":true,"for_overlay":true,"local_as":65000,"mac":"020001c04668","neighbor":"15.8.3.5","neighbor_as":65000,"neighbor_mac":"020001c04600","node":"node0","org_id":"0c160b7f-1027-4cd1-923b-744534c4b070","rx_pkts":63366,"rx_routes":60,"site_id":"725a8d34-a126-4f2c-b990-d1219421cb75","state":"established","timestamp":1666251056.07,"tx_pkts":1735,"tx_routes":60,"up":true,"uptime":31355,"vrf_name":"default"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_calls_test.go b/mistapi/sites_stats_calls_test.go new file mode 100644 index 00000000..45ce6af1 --- /dev/null +++ b/mistapi/sites_stats_calls_test.go @@ -0,0 +1,87 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesStatsCallsTestCountSiteCalls tests the behavior of the SitesStatsCalls +func TestSitesStatsCallsTestCountSiteCalls(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distrinct := models.CountSiteCallsDistrinctEnum("mac") + + + + + apiResponse, err := sitesStatsCalls.CountSiteCalls(ctx, siteId, &distrinct, nil, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsCallsTestSearchSiteCalls tests the behavior of the SitesStatsCalls +func TestSitesStatsCallsTestSearchSiteCalls(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + app := "zoom" + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsCalls.SearchSiteCalls(ctx, siteId, nil, &app, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsCallsTestListSiteTroubleshootCalls tests the behavior of the SitesStatsCalls +func TestSitesStatsCallsTestListSiteTroubleshootCalls(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + app := "zoom" + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsCalls.ListSiteTroubleshootCalls(ctx, siteId, nil, nil, nil, &app, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"mac":"983a78ea4a44","meeting_id":"b784d744-9a7c-4fad-9af0-f78858a319b1","results":[{"audio_in":{"ap_num_clients":45.483067936367462,"ap_rtt":6.352042701509264,"client_cpu":9.3234525786505813,"client_radio_band":1.5325644097982959E-06,"client_rssi":17.251008563571506,"client_tx_bytes":1.8379177401463192,"client_tx_rates":10.668423069847954,"client_tx_retries":43.323209603627525,"client_vpn_distance":112.4420166015625,"expected":29.74261474609375,"radio_bandwidth":-0.15336827271514469,"radio_channel":0.662909648484654,"radio_util":27.891777674357098,"radio_util_interference":4.38913492154744,"site_num_clients":-0.28558229323890472,"site_wan_avg_upload_mpbs":-0.988989942603641,"site_wan_jitter":0.78755196597841048,"site_wan_rtt":15.094849904378256,"site_wan_upload_mpbs":-0.81311179531945121},"audio_out":{"ap_num_clients":45.483067936367462,"ap_rtt":6.352042701509264,"client_cpu":9.3234525786505813,"client_radio_band":1.5325644097982959E-06,"client_rssi":17.251008563571506,"client_tx_bytes":1.8379177401463192,"client_tx_rates":10.668423069847954,"client_tx_retries":43.323209603627525,"client_vpn_distance":112.4420166015625,"expected":29.74261474609375,"radio_bandwidth":-0.15336827271514469,"radio_channel":0.662909648484654,"radio_util":27.891777674357098,"radio_util_interference":4.38913492154744,"site_num_clients":-0.28558229323890472,"site_wan_avg_upload_mpbs":-0.988989942603641,"site_wan_jitter":0.78755196597841048,"site_wan_rtt":15.094849904378256,"site_wan_upload_mpbs":-0.81311179531945121},"timestamp":1695425115,"video_in":{"ap_num_clients":45.483067936367462,"ap_rtt":6.352042701509264,"client_cpu":9.3234525786505813,"client_radio_band":1.5325644097982959E-06,"client_rssi":17.251008563571506,"client_tx_bytes":1.8379177401463192,"client_tx_rates":10.668423069847954,"client_tx_retries":43.323209603627525,"client_vpn_distance":112.4420166015625,"expected":29.74261474609375,"radio_bandwidth":-0.15336827271514469,"radio_channel":0.662909648484654,"radio_util":27.891777674357098,"radio_util_interference":4.38913492154744,"site_num_clients":-0.28558229323890472,"site_wan_avg_upload_mpbs":-0.988989942603641,"site_wan_jitter":0.78755196597841048,"site_wan_rtt":15.094849904378256,"site_wan_upload_mpbs":-0.81311179531945121},"video_out":{"ap_num_clients":45.483067936367462,"ap_rtt":6.352042701509264,"client_cpu":9.3234525786505813,"client_radio_band":1.5325644097982959E-06,"client_rssi":17.251008563571506,"client_tx_bytes":1.8379177401463192,"client_tx_rates":10.668423069847954,"client_tx_retries":43.323209603627525,"client_vpn_distance":112.4420166015625,"expected":29.74261474609375,"radio_bandwidth":-0.15336827271514469,"radio_channel":0.662909648484654,"radio_util":27.891777674357098,"radio_util_interference":4.38913492154744,"site_num_clients":-0.28558229323890472,"site_wan_avg_upload_mpbs":-0.988989942603641,"site_wan_jitter":0.78755196597841048,"site_wan_rtt":15.094849904378256,"site_wan_upload_mpbs":-0.81311179531945121}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_clients_sdk_test.go b/mistapi/sites_stats_clients_sdk_test.go new file mode 100644 index 00000000..314a7fa2 --- /dev/null +++ b/mistapi/sites_stats_clients_sdk_test.go @@ -0,0 +1,54 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsClientsSDKTestGetSiteSdkStatsByMap tests the behavior of the SitesStatsClientsSDK +func TestSitesStatsClientsSDKTestGetSiteSdkStatsByMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsClientsSdk.GetSiteSdkStatsByMap(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsClientsSDKTestGetSiteSdkStats tests the behavior of the SitesStatsClientsSDK +func TestSitesStatsClientsSDKTestGetSiteSdkStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sdkclientId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsClientsSdk.GetSiteSdkStats(ctx, siteId, sdkclientId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"d56bd5fa-0a0a-4861-a9df-5ac83d3a2eeb","last_seen":1428939600,"name":"John's iPhone","network_connection":{"mac":"c3-b6-e5-af-41-15","rssi":-75,"signal_level":3,"type":"WiFi"},"uuid":"ada72f8f-1643-e5c6-94db-f2a5636f1a64","vbeacons":[{"id":"d379d29d-24b4-96c5-5dd4-6f2a2dc5aaeb","since":1428939300}],"x":60,"y":80,"zones":[{"id":"8ac84899-32db-6327-334c-9b6d58544cfe","since":1428939600}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_clients_wireless_test.go b/mistapi/sites_stats_clients_wireless_test.go new file mode 100644 index 00000000..039a29af --- /dev/null +++ b/mistapi/sites_stats_clients_wireless_test.go @@ -0,0 +1,102 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsClientsWirelessTestListSiteWirelessClientsStats tests the behavior of the SitesStatsClientsWireless +func TestSitesStatsClientsWirelessTestListSiteWirelessClientsStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wired := bool(false) + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsClientsWireless.ListSiteWirelessClientsStats(ctx, siteId, &wired, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsClientsWirelessTestGetSiteWirelessClientStats tests the behavior of the SitesStatsClientsWireless +func TestSitesStatsClientsWirelessTestGetSiteWirelessClientStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + wired := bool(false) + apiResponse, err := sitesStatsClientsWireless.GetSiteWirelessClientStats(ctx, siteId, clientMac, &wired) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsClientsWirelessTestGetSiteWirelessClientsStatsByMap tests the behavior of the SitesStatsClientsWireless +func TestSitesStatsClientsWirelessTestGetSiteWirelessClientsStatsByMap(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsClientsWireless.GetSiteWirelessClientsStatsByMap(ctx, siteId, mapId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsClientsWirelessTestListSiteUnconnectedClientStats tests the behavior of the SitesStatsClientsWireless +func TestSitesStatsClientsWirelessTestListSiteUnconnectedClientStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsClientsWireless.ListSiteUnconnectedClientStats(ctx, siteId, mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"ap_mac":"5c5b350e0410","last_seen":1428939600,"mac":"5684dae9ac8b","manufacture":"Apple","rssi":-75,"x":60,"y":80}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_devices_test.go b/mistapi/sites_stats_devices_test.go new file mode 100644 index 00000000..ee3bec86 --- /dev/null +++ b/mistapi/sites_stats_devices_test.go @@ -0,0 +1,73 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsDevicesTestGetSiteAllClientsStatsByDevice tests the behavior of the SitesStatsDevices +func TestSitesStatsDevicesTestGetSiteAllClientsStatsByDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsDevices.GetSiteAllClientsStatsByDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesStatsDevicesTestGetSiteGatewayMetrics tests the behavior of the SitesStatsDevices +func TestSitesStatsDevicesTestGetSiteGatewayMetrics(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsDevices.GetSiteGatewayMetrics(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"config_success":99.9,"version_compliance":{"major_version":{"SRX320":{"major_count":0,"major_version":"19.4R2-S1.2"}},"score":99.9,"type":"gateway"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsDevicesTestGetSiteSwitchesMetrics tests the behavior of the SitesStatsDevices +func TestSitesStatsDevicesTestGetSiteSwitchesMetrics(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + apiResponse, err := sitesStatsDevices.GetSiteSwitchesMetrics(ctx, siteId, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"active_ports_summary":{"details":{"active_port_count":4,"total_port_count":4},"score":100,"total_switch_count":2},"config_success":{"details":{"config_success_count":2},"score":100,"total_switch_count":2},"version_compliance":{"details":{"major_versions":[{"major_count":1,"major_version":"21.4R3.5","model":"EX2300-C-12P","system_names":[]},{"major_count":1,"major_version":"6.0.4-11","model":"SSR120","system_names":[]}]},"score":100,"total_switch_count":2}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_discovered_switches_test.go b/mistapi/sites_stats_discovered_switches_test.go new file mode 100644 index 00000000..a9954c78 --- /dev/null +++ b/mistapi/sites_stats_discovered_switches_test.go @@ -0,0 +1,113 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesStatsDiscoveredSwitchesTestSearchSiteDiscoveredSwitchesMetrics tests the behavior of the SitesStatsDiscoveredSwitches +func TestSitesStatsDiscoveredSwitchesTestSearchSiteDiscoveredSwitchesMetrics(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + scope := models.DiscoveredSwitchesMetricScopeEnum("site") + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsDiscoveredSwitches.SearchSiteDiscoveredSwitchesMetrics(ctx, siteId, &scope, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1675193686.0191767,"limit":1,"next":"/api/v1/sites/f5fcbee5-fbca-45b3-8bf1-1619ede87879/stats/discovered_switch_metrics/search?end=1675193686.0191767&limit=1&search_after=%5B1675193400000%5D&start=1675107286.0191767","results":[{"details":{},"org_id":"203d3d02-dbc0-4c1b-9f41-76896a3330f4","scope":"site","score":100,"site_id":"f5fcbee5-fbca-45b3-8bf1-1619ede87879","timestamp":1675193400,"type":"inactive_wired_vlans"}],"start":1675107286.0191767,"total":3}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsDiscoveredSwitchesTestCountSiteDiscoveredSwitches tests the behavior of the SitesStatsDiscoveredSwitches +func TestSitesStatsDiscoveredSwitchesTestCountSiteDiscoveredSwitches(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteDiscoveredSwitchesCountDistinctEnum("system_name") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsDiscoveredSwitches.CountSiteDiscoveredSwitches(ctx, siteId, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsDiscoveredSwitchesTestGetSiteDiscoveredSwitchesMetrics tests the behavior of the SitesStatsDiscoveredSwitches +func TestSitesStatsDiscoveredSwitchesTestGetSiteDiscoveredSwitchesMetrics(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + apiResponse, err := sitesStatsDiscoveredSwitches.GetSiteDiscoveredSwitchesMetrics(ctx, siteId, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"inactive_wired_vlans":{"details":{},"score":100},"poe_compliance":{"details":{"total_aps":63,"total_power":981500},"score":100},"switch_ap_affinity":{"details":{"system_name":["mist-lab-ex2300c","switch1"],"threshold":12},"score":33.3333},"version_compliance":{"details":{"major_versions":[{"major_count":2,"model":"EX2300-C-12P","system_names":["switch1","mist-lab-ex2300c"]},{"major_count":1,"model":"EX4300-48P","system_names":[]}],"total_switch_count":5},"score":75}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsDiscoveredSwitchesTestSearchSiteDiscoveredSwitches tests the behavior of the SitesStatsDiscoveredSwitches +func TestSitesStatsDiscoveredSwitchesTestSearchSiteDiscoveredSwitches(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsDiscoveredSwitches.SearchSiteDiscoveredSwitches(ctx, siteId, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1604496474.8978634,"limit":1000,"results":[{"aps":[{"hostname":"ap41nearlab","inactive_wired_vlans":[],"mac":"5c5b352e2001","poe_status":true,"when":"2019-06-13T19:53:16.870+0000"}],"mgmt_addr":"10.1.1.1","model":"EX2300-C-12P","org_id":"6748cfa6-4e12-11e6-9188-0242ac110007","site_id":"67970e46-4e12-11e6-9188-0242ac110007","system_desc":"Juniper Networks, Inc. ex2300-c-12p Ethernet Switch, kernel JUNOS 18.2R2.6, Build date: 2018-12-07 13:19:04 UTC Copyright (c) 1996-2018 Juniper Networks, Inc.","system_name":"mist-lab-ex2300c","timestamp":1560457177.037,"vendor":"Juniper Networks","version":"18.2R2.6"}],"start":1604410074.8978484,"total":1}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_mx_edges_test.go b/mistapi/sites_stats_mx_edges_test.go new file mode 100644 index 00000000..d81c6298 --- /dev/null +++ b/mistapi/sites_stats_mx_edges_test.go @@ -0,0 +1,60 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsMxEdgesTestListSiteMxEdgesStats tests the behavior of the SitesStatsMxEdges +func TestSitesStatsMxEdgesTestListSiteMxEdgesStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsMxEdges.ListSiteMxEdgesStats(ctx, siteId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"cpu_stat":{"cpus":{"cpu0":{"idle":89,"interrupt":0,"system":8,"usage":10,"user":1},"cpu1":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu2":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu3":{"idle":2,"interrupt":0,"system":50,"usage":97,"user":46}},"idle":62,"interrupt":0,"system":17,"usage":37,"user":19},"created_time":1632684398,"for_site":false,"id":"00000000-0000-0000-1000-020000a80cb4","ip_stat":{"ip":"192.168.1.244","ips":{"ens18":"192.168.1.244/24,fe80::104c:ffff:fee0:caf8/64"},"macs":{"ens18":"e4434b217044"}},"lag_stat":{"lacp0":{"active_ports":["port0","port1"]}},"last_seen":1633721215,"mac":"020000a80cb4","memory_stat":{"active":394936320,"available":4699291648,"buffers":107646976,"cached":478060544,"free":4330659840,"inactive":211980288,"swap_cached":0,"swap_free":1022357504,"swap_total":1022357504,"total":8365957120,"usage":48},"model":"ME-VM","modified_time":1633643629,"mxagent_registered":true,"mxcluster_id":"678bc339-7635-4556-bbc0-e77ad493ef8b","name":"me-vm-1","num_tunnels":0,"oob_ip_config":{"dns":["8.8.8.8","1.1.1.1"],"gateway":"10.0.0.1","ip":"10.0.0.10","netmask":"255.255.255.0","type":"static"},"org_id":"11b08247-b1ee-4152-9b25-312b323ce480","port_stat":{"port0":{"full_duplex":true,"mac":"9e294e49091d","rx_bytes":646898375700,"rx_errors":0,"rx_pkts":8784449574,"speed":10000,"state":"forwarding","tx_bytes":647200748038,"tx_errors":0,"tx_pkts":8788647466,"up":true},"port1":{"full_duplex":true,"mac":"a270fe53437e","rx_bytes":647200437652,"rx_errors":0,"rx_pkts":8788644886,"speed":10000,"state":"forwarding","tx_bytes":646898681650,"tx_errors":0,"tx_pkts":8784452092,"up":true}},"sensor_stat":{},"serial":"string","service_stat":{"mxagent":{"ext_ip":"99.0.86.164","last_seen":1633721215,"package_state":"Installed","package_version":"3.1.1037-1","running_state":"Running","uptime":21240},"tunterm":{"ext_ip":"99.0.86.164","last_seen":1633721203,"package_state":"Installed","package_version":"0.1.2449+deb10","running_state":"Running","uptime":76261}},"services":["tunterm"],"site_id":"00000000-0000-0000-0000-000000000000","status":"connected","tunterm_ip_config":{"gateway":"192.168.11.1","ip":"192.168.11.91","netmask":"255.255.255.0"},"tunterm_port_config":{"downstream_ports":["0","1"],"separate_upstream_downstream":false,"upstream_ports":["0","1"]},"tunterm_registered":true,"tunterm_stat":{"monitoring_failed":false},"uptime":76281,"virtualization_type":"KVM"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsMxEdgesTestGetSiteMxEdgeStats tests the behavior of the SitesStatsMxEdges +func TestSitesStatsMxEdgesTestGetSiteMxEdgeStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxedgeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + apiResponse, err := sitesStatsMxEdges.GetSiteMxEdgeStats(ctx, siteId, mxedgeId, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cpu_stat":{"cpus":{"cpu0":{"idle":89,"interrupt":0,"system":8,"usage":10,"user":1},"cpu1":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu2":{"idle":81,"interrupt":0,"system":4,"usage":18,"user":13},"cpu3":{"idle":2,"interrupt":0,"system":50,"usage":97,"user":46}},"idle":62,"interrupt":0,"system":17,"usage":37,"user":19},"created_time":1632684398,"for_site":false,"id":"00000000-0000-0000-1000-020000a80cb4","ip_stat":{"ip":"192.168.1.244","ips":{"ens18":"192.168.1.244/24,fe80::104c:ffff:fee0:caf8/64"},"macs":{"ens18":"e4434b217044"}},"lag_stat":{"lacp0":{"active_ports":["port0","port1"]}},"last_seen":1633721215,"mac":"020000a80cb4","memory_stat":{"active":394936320,"available":4699291648,"buffers":107646976,"cached":478060544,"free":4330659840,"inactive":211980288,"swap_cached":0,"swap_free":1022357504,"swap_total":1022357504,"total":8365957120,"usage":48},"model":"ME-VM","modified_time":1633643629,"mxagent_registered":true,"mxcluster_id":"678bc339-7635-4556-bbc0-e77ad493ef8b","name":"me-vm-1","num_tunnels":0,"oob_ip_config":{"dns":["8.8.8.8","1.1.1.1"],"gateway":"10.0.0.1","ip":"10.0.0.10","netmask":"255.255.255.0","type":"static"},"org_id":"11b08247-b1ee-4152-9b25-312b323ce480","port_stat":{"port0":{"full_duplex":true,"mac":"9e294e49091d","rx_bytes":646898375700,"rx_errors":0,"rx_pkts":8784449574,"speed":10000,"state":"forwarding","tx_bytes":647200748038,"tx_errors":0,"tx_pkts":8788647466,"up":true},"port1":{"full_duplex":true,"mac":"a270fe53437e","rx_bytes":647200437652,"rx_errors":0,"rx_pkts":8788644886,"speed":10000,"state":"forwarding","tx_bytes":646898681650,"tx_errors":0,"tx_pkts":8784452092,"up":true}},"sensor_stat":{},"serial":"string","service_stat":{"mxagent":{"ext_ip":"99.0.86.164","last_seen":1633721215,"package_state":"Installed","package_version":"3.1.1037-1","running_state":"Running","uptime":21240},"tunterm":{"ext_ip":"99.0.86.164","last_seen":1633721203,"package_state":"Installed","package_version":"0.1.2449+deb10","running_state":"Running","uptime":76261}},"services":["tunterm"],"site_id":"00000000-0000-0000-0000-000000000000","status":"connected","tunterm_ip_config":{"gateway":"192.168.11.1","ip":"192.168.11.91","netmask":"255.255.255.0"},"tunterm_port_config":{"downstream_ports":["0","1"],"separate_upstream_downstream":false,"upstream_ports":["0","1"]},"tunterm_registered":true,"tunterm_stat":{"monitoring_failed":false},"uptime":76281,"virtualization_type":"KVM"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_ports_test.go b/mistapi/sites_stats_ports_test.go new file mode 100644 index 00000000..fe47bfe7 --- /dev/null +++ b/mistapi/sites_stats_ports_test.go @@ -0,0 +1,222 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesStatsPortsTestCountSiteSwOrGwPorts tests the behavior of the SitesStatsPorts +func TestSitesStatsPortsTestCountSiteSwOrGwPorts(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SitePortsCountDistinctEnum("mac") + + + + + + + + + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsPorts.CountSiteSwOrGwPorts(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsPortsTestSearchSiteSwOrGwPorts tests the behavior of the SitesStatsPorts +func TestSitesStatsPortsTestSearchSiteSwOrGwPorts(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsPorts.SearchSiteSwOrGwPorts(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513177200,"limit":10,"results":[{"active":true,"auth_state":"init","for_site":true,"full_duplex":true,"jitter":0,"latency":0,"loss":0,"lte_iccid":"string","lte_imei":"string","lte_imsi":"string","mac":"5c4527a96580","mac_count":0,"mac_limit":0,"neighbor_mac":"64d814353400","neighbor_port_desc":"GigabitEthernet1/0/21","neighbor_system_name":"CORP-D-SW-2","org_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","poe_disabled":true,"poe_mode":"802.3af","poe_on":true,"port_id":"ge-0/0/0","port_mac":"5c4527a96580","port_usage":"lan","power_draw":0,"rx_bcast_pkts":0,"rx_bps":0,"rx_bytes":4563443626,"rx_errors":0,"rx_mcast_pkts":0,"rx_pkts":0,"site_id":"c1698122-c14c-11e5-8e81-1258369c38a9","speed":1000,"stp_role":"designated","stp_state":"forwarding","tx_bcast_pkts":0,"tx_bps":0,"tx_bytes":11299516780,"tx_errors":0,"tx_mcast_pkts":0,"tx_pkts":492176,"type":"gateway","up":true,"xcvr_part_number":"string"}],"start":1511967600,"total":100}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsPortsTestCountSiteSwitchPorts tests the behavior of the SitesStatsPorts +func TestSitesStatsPortsTestCountSiteSwitchPorts(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + distinct := models.SiteSwitchPortsCountDistinctEnum("mac") + + + + + + + + + + + + + + + + + + + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesStatsPorts.CountSiteSwitchPorts(ctx, siteId, &distinct, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesStatsPortsTestSearchSiteSwitchPorts tests the behavior of the SitesStatsPorts +func TestSitesStatsPortsTestSearchSiteSwitchPorts(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + + + + + + + + + + + + + + + + + limit := int(100) + + + duration := "1d" + apiResponse, err := sitesStatsPorts.SearchSiteSwitchPorts(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &limit, nil, nil, &duration) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1513177200,"limit":10,"results":[{"active":true,"auth_state":"init","for_site":true,"full_duplex":true,"jitter":0,"latency":0,"loss":0,"lte_iccid":"string","lte_imei":"string","lte_imsi":"string","mac":"5c4527a96580","mac_count":0,"mac_limit":0,"neighbor_mac":"64d814353400","neighbor_port_desc":"GigabitEthernet1/0/21","neighbor_system_name":"CORP-D-SW-2","org_id":"c168ddee-c14c-11e5-8e81-1258369c38a9","poe_disabled":true,"poe_mode":"802.3af","poe_on":true,"port_id":"ge-0/0/0","port_mac":"5c4527a96580","port_usage":"lan","power_draw":0,"rx_bcast_pkts":0,"rx_bps":0,"rx_bytes":4563443626,"rx_errors":0,"rx_mcast_pkts":0,"rx_pkts":0,"site_id":"c1698122-c14c-11e5-8e81-1258369c38a9","speed":1000,"stp_role":"designated","stp_state":"forwarding","tx_bcast_pkts":0,"tx_bps":0,"tx_bytes":11299516780,"tx_errors":0,"tx_mcast_pkts":0,"tx_pkts":492176,"type":"gateway","up":true,"xcvr_part_number":"string"}],"start":1511967600,"total":100}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_test.go b/mistapi/sites_stats_test.go new file mode 100644 index 00000000..d45c3763 --- /dev/null +++ b/mistapi/sites_stats_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsTestGetSiteStats tests the behavior of the SitesStats +func TestSitesStatsTestGetSiteStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStats.GetSiteStats(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"address":"string","alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","country_code":"string","created_time":0,"id":"55c29ce5-7c0f-45b5-b99b-599f805fa3a1","lat":0,"latlng":{"lat":0,"lng":0},"lng":0,"modified_time":0,"msp_id":"dca3cad3-0c9b-439b-814f-8d5f23797972","name":"string","networktemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","num_ap":0,"num_ap_connected":0,"num_clients":0,"num_devices":0,"num_devices_connected":0,"num_gateway":0,"num_gateway_connected":0,"num_switch":0,"num_switch_connected":0,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rftemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9"],"timezone":"string","tzoffset":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_wx_rules_test.go b/mistapi/sites_stats_wx_rules_test.go new file mode 100644 index 00000000..7bc08510 --- /dev/null +++ b/mistapi/sites_stats_wx_rules_test.go @@ -0,0 +1,28 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsWxRulesTestGetSiteWxRulesUsage tests the behavior of the SitesStatsWxRules +func TestSitesStatsWxRulesTestGetSiteWxRulesUsage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesStatsWxRules.GetSiteWxRulesUsage(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","client_mac":["3bbbf819bb6f","bd96cbc4910f"],"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_wxtags":["d4134466-eec0-3756-6765-381c728a6037","1a42c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"name":"Guest","order":1,"src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"],"usage":{"1a42c7b0-d1d0-5a30-f349-e35fa43dc3b3":{"num_flows":60},"d4134466-eec0-3756-6765-381c728a6037":{"num_flows":60}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_stats_zones_test.go b/mistapi/sites_stats_zones_test.go new file mode 100644 index 00000000..42eeffe6 --- /dev/null +++ b/mistapi/sites_stats_zones_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesStatsZonesTestListSiteZonesStats tests the behavior of the SitesStatsZones +func TestSitesStatsZonesTestListSiteZonesStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mapId := "00000000-0000-0000-0000-000000000000" + apiResponse, err := sitesStatsZones.ListSiteZonesStats(ctx, siteId, &mapId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"assets_waits":{"avg":0,"max":0,"min":0,"p95":0},"clients_waits":{"avg":1200,"max":3610,"min":600,"p95":2800},"created_time":1616625211,"id":"123470c7-5d9d-424a-8475-8b344c621234","map_id":"123449d4-d12f-4feb-b40f-5be0e2ae1234","modified_time":1616625211,"name":"Zone A","num_assets":0,"num_clients":80,"num_sdkclients":10,"occupancy_limit":4,"org_id":"1234c1a0-6ef6-11e6-8bbf-02e208b21234","sdkclients_waits":{"avg":1200,"max":3610,"min":600,"p95":2800},"site_id":"123448e6-6ef6-11e6-8bbf-02e208b21234","vertices":[{"x":732,"y":1821},{"x":732.5,"y":1731},{"x":837.5,"y":1731.5},{"x":839,"y":1821}],"vertices_m":[{"x":24.1983341951072,"y":60.198314985369144},{"x":24.214863111907139,"y":57.223109961380558},{"x":27.685935639893827,"y":57.239638878180493},{"x":27.735522390293639,"y":60.198314985369144}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_synthetic_tests_test.go b/mistapi/sites_synthetic_tests_test.go new file mode 100644 index 00000000..8465e5cb --- /dev/null +++ b/mistapi/sites_synthetic_tests_test.go @@ -0,0 +1,145 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesSyntheticTestsTestStartSiteSwitchRadiusSyntheticTest tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestStartSiteSwitchRadiusSyntheticTest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SynthetictestRadiusServer + errBody := json.Unmarshal([]byte(`{"password":"string","profile":"dot1x","user":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesSyntheticTests.StartSiteSwitchRadiusSyntheticTest(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesSyntheticTestsTestGetSiteDeviceSyntheticTest tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestGetSiteDeviceSyntheticTest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesSyntheticTests.GetSiteDeviceSyntheticTest(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesSyntheticTestsTestTriggerSiteDeviceSyntheticTest tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestTriggerSiteDeviceSyntheticTest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := sitesSyntheticTests.TriggerSiteDeviceSyntheticTest(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesSyntheticTestsTestGetSiteSyntheticTestStatus tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestGetSiteSyntheticTestStatus(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesSyntheticTests.GetSiteSyntheticTestStatus(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"device_type":"gateway","mac":"5c5b35584a6f","port_id":"ge-0/0/1.100","start_time":1675718807,"status":"inprogress","type":"speedtest"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSyntheticTestsTestTriggerSiteSyntheticTest tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestTriggerSiteSyntheticTest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Synthetictest + errBody := json.Unmarshal([]byte(`{"email":"test@mist.com"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesSyntheticTests.TriggerSiteSyntheticTest(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"id":"a42775f6-edc8-69b5-f979-542fa1b43ff9","message":"Successfully queued synthetic test for the site.","status":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesSyntheticTestsTestSearchSiteSyntheticTest tests the behavior of the SitesSyntheticTests +func TestSitesSyntheticTestsTestSearchSiteSyntheticTest(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + apiResponse, err := sitesSyntheticTests.SearchSiteSyntheticTest(ctx, siteId, nil, nil, nil, nil, nil, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":0,"limit":0,"next":"string","results":[{"by":"user","device_type":"gateway","failed":false,"latency":40,"mac":"aff827549235","port_id":"ge-0/0/2","rx_mbps":322,"timestamp":1706824045.059036,"tx_mbps":199,"type":"speedtest","vlan_id":20},{"by":"marvis","device_type":"gateway","failed":true,"latency":0,"mac":"8396cd006c8c","port_id":"ge-0/0/2","reason":"interface not ready to perform test","rx_mbps":0,"timestamp":1706824045.059036,"tx_mbps":0,"type":"speedtest","vlan_id":100}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_test.go b/mistapi/sites_test.go new file mode 100644 index 00000000..9cf5334f --- /dev/null +++ b/mistapi/sites_test.go @@ -0,0 +1,69 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesTestDeleteSite tests the behavior of the Sites +func TestSitesTestDeleteSite(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sites.DeleteSite(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesTestGetSiteInfo tests the behavior of the Sites +func TestSitesTestGetSiteInfo(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sites.GetSiteInfo(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","alarmtemplate_id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","apporttemplate_id":"string","aptemplate_id":"16bdf952-ade2-4491-80b0-85ce506c760b","country_code":"US","created_time":0,"gatewaytemplate_id":"6f9b2e75-9b2f-b5ae-81e3-e14c76f1a90f","id":"497f6eca-6276-5005-bfeb-53cbbbba6f17","latlng":{"lat":37.295833,"lng":-122.032946},"modified_time":0,"name":"Mist Office","networktemplate_id":"12ae9bd2-e0ab-107b-72e8-a7a005565ec2","notes":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rftemplate_id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","secpolicy_id":"3bcd0beb-5d0a-4cbd-92c1-14aea91e98ef","sitegroup_ids":["497f6eca-6276-5006-bfeb-53cbbbba6f18"],"timezone":"America/Los_Angeles"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesTestUpdateSiteInfo tests the behavior of the Sites +func TestSitesTestUpdateSiteInfo(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Site + errBody := json.Unmarshal([]byte(`{"address":"string","alarmtemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","country_code":"string","latlng":{"lat":0,"lng":0},"name":"string","networktemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","notes":"string","rftemplate_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secpolicy_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","sitegroup_ids":["b069b358-4c97-5319-1f8c-7c5ca64d6ab1"],"timezone":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sites.UpdateSiteInfo(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"address":"1601 S. Deanza Blvd., Cupertino, CA, 95014","alarmtemplate_id":"684dfc5c-fe77-2290-eb1d-ef3d677fe168","apporttemplate_id":"string","aptemplate_id":"16bdf952-ade2-4491-80b0-85ce506c760b","country_code":"US","created_time":0,"gatewaytemplate_id":"6f9b2e75-9b2f-b5ae-81e3-e14c76f1a90f","id":"497f6eca-6276-5005-bfeb-53cbbbba6f17","latlng":{"lat":37.295833,"lng":-122.032946},"modified_time":0,"name":"Mist Office","networktemplate_id":"12ae9bd2-e0ab-107b-72e8-a7a005565ec2","notes":"string","org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","rftemplate_id":"bb8a9017-1e36-5d6c-6f2b-551abe8a76a2","secpolicy_id":"3bcd0beb-5d0a-4cbd-92c1-14aea91e98ef","sitegroup_ids":["497f6eca-6276-5006-bfeb-53cbbbba6f18"],"timezone":"America/Los_Angeles"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_ui_settings_test.go b/mistapi/sites_ui_settings_test.go new file mode 100644 index 00000000..f1cb3f6d --- /dev/null +++ b/mistapi/sites_ui_settings_test.go @@ -0,0 +1,146 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesUISettingsTestListSiteUiSettings tests the behavior of the SitesUISettings +func TestSitesUISettingsTestListSiteUiSettings(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesUiSettings.ListSiteUiSettings(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1508823803,"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","for_site":true,"id":"3bdcc7e8-c04d-4512-b4fc-093da9057eb0","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"modified_time":0,"name":"New Databoard","org_id":"cc079380-5029-4d4a-9125-858de85731ff","purpose":"databoard","site_id":"67970e46-4e12-11e6-9188-0242ad112847","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"id":"7a9ab38c-cfc3-483d-b51a-0aec571fadc0","metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesUISettingsTestCreateSiteUiSettings tests the behavior of the SitesUISettings +func TestSitesUISettingsTestCreateSiteUiSettings(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UiSettings + errBody := json.Unmarshal([]byte(`{"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"name":"New Databoard","purpose":"databoard","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesUiSettings.CreateSiteUiSettings(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1508823803,"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","for_site":true,"id":"3bdcc7e8-c04d-4512-b4fc-093da9057eb0","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"modified_time":0,"name":"New Databoard","org_id":"cc079380-5029-4d4a-9125-858de85731ff","purpose":"databoard","site_id":"67970e46-4e12-11e6-9188-0242ad112847","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"id":"7a9ab38c-cfc3-483d-b51a-0aec571fadc0","metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesUISettingsTestGetSiteUiSettingDerived tests the behavior of the SitesUISettings +func TestSitesUISettingsTestGetSiteUiSettingDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesUiSettings.GetSiteUiSettingDerived(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1508823803,"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","for_site":true,"id":"3bdcc7e8-c04d-4512-b4fc-093da9057eb0","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"modified_time":0,"name":"New Databoard","org_id":"cc079380-5029-4d4a-9125-858de85731ff","purpose":"databoard","site_id":"67970e46-4e12-11e6-9188-0242ad112847","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"id":"7a9ab38c-cfc3-483d-b51a-0aec571fadc0","metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesUISettingsTestDeleteSiteUiSetting tests the behavior of the SitesUISettings +func TestSitesUISettingsTestDeleteSiteUiSetting(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + uisettingId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesUiSettings.DeleteSiteUiSetting(ctx, siteId, uisettingId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesUISettingsTestGetSiteUiSetting tests the behavior of the SitesUISettings +func TestSitesUISettingsTestGetSiteUiSetting(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + uisettingId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesUiSettings.GetSiteUiSetting(ctx, siteId, uisettingId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":1508823803,"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","for_site":true,"id":"3bdcc7e8-c04d-4512-b4fc-093da9057eb0","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"modified_time":0,"name":"New Databoard","org_id":"cc079380-5029-4d4a-9125-858de85731ff","purpose":"databoard","site_id":"67970e46-4e12-11e6-9188-0242ad112847","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"id":"7a9ab38c-cfc3-483d-b51a-0aec571fadc0","metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesUISettingsTestUpdateSiteUiSetting tests the behavior of the SitesUISettings +func TestSitesUISettingsTestUpdateSiteUiSetting(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + uisettingId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UiSettings + errBody := json.Unmarshal([]byte(`{"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"name":"New Databoard","purpose":"databoard","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesUiSettings.UpdateSiteUiSetting(ctx, siteId, uisettingId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":1508823803,"defaultScopeId":"67970e46-4e12-11e6-9188-0242ad112847","defaultScopeType":"site","defaultTimeRange":{"end":1508828400,"endDate":"10/23/2017","interval":"1d","name":"This Week","shortName":"thisWeek","start":1508655600,"usePreset":true},"description":"Description of the databoard","for_site":true,"id":"3bdcc7e8-c04d-4512-b4fc-093da9057eb0","isCustomDataboard":true,"isScopeLinked":true,"isTimeRangeLinked":true,"modified_time":0,"name":"New Databoard","org_id":"cc079380-5029-4d4a-9125-858de85731ff","purpose":"databoard","site_id":"67970e46-4e12-11e6-9188-0242ad112847","tiles":[{"chartBand":"2.4 ghz","chartColor":"#00B4AD","chartDirection":"tx + rx","chartRankBy":"string","chartType":"timeSeries","colspan":5,"column":1,"hideEmptyRows":true,"id":"7a9ab38c-cfc3-483d-b51a-0aec571fadc0","metric":{"apiName":"client_dhcp_latency"},"name":"New Analysis","row":1,"rowspan":2,"scopeId":"e0c767834b4c","scopeType":"client","sortedColumns":null,"timeRange":{"end":1508823743,"endDate":"10/23/2017","interval":"1d","name":"Past 7 Days","shortName":"7d","start":1508223600,"usePreset":true},"trendType":"line","vizType":"averageTimeSeriesChart"}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_v_beacons_test.go b/mistapi/sites_v_beacons_test.go new file mode 100644 index 00000000..7ae54de9 --- /dev/null +++ b/mistapi/sites_v_beacons_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesVBeaconsTestListSiteVBeacons tests the behavior of the SitesVBeacons +func TestSitesVBeaconsTestListSiteVBeacons(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesVBeacons.ListSiteVBeacons(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","major":0,"map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","message":"string","minor":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":4,"power_mode":"default","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","url":"string","uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","wayfinding_nodename":"string","x":0,"y":0}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesVBeaconsTestCreateSiteVBeacon tests the behavior of the SitesVBeacons +func TestSitesVBeaconsTestCreateSiteVBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Vbeacon + errBody := json.Unmarshal([]byte(`{"major":0,"message":"string","minor":0,"name":"string","power":4,"power_mode":"default","url":"string","uuid":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","wayfinding_nodename":"string","x":0,"y":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesVBeacons.CreateSiteVBeacon(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","major":0,"map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","message":"string","minor":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":4,"power_mode":"default","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","url":"string","uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","wayfinding_nodename":"string","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesVBeaconsTestDeleteSiteVBeacon tests the behavior of the SitesVBeacons +func TestSitesVBeaconsTestDeleteSiteVBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vbeaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesVBeacons.DeleteSiteVBeacon(ctx, siteId, vbeaconId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesVBeaconsTestGetSiteVBeacon tests the behavior of the SitesVBeacons +func TestSitesVBeaconsTestGetSiteVBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vbeaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesVBeacons.GetSiteVBeacon(ctx, siteId, vbeaconId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","major":0,"map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","message":"string","minor":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":4,"power_mode":"default","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","url":"string","uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","wayfinding_nodename":"string","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesVBeaconsTestUpdateSiteVBeacon tests the behavior of the SitesVBeacons +func TestSitesVBeaconsTestUpdateSiteVBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + vbeaconId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Vbeacon + errBody := json.Unmarshal([]byte(`{"major":0,"message":"string","minor":0,"name":"string","power":4,"power_mode":"default","url":"string","uuid":"6f4bf402-45f9-2a56-6c8b-7f83d3bc98e9","wayfinding_nodename":"string","x":0,"y":0}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesVBeacons.UpdateSiteVBeacon(ctx, siteId, vbeaconId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","major":0,"map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","message":"string","minor":0,"modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","power":4,"power_mode":"default","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","url":"string","uuid":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","wayfinding_nodename":"string","x":0,"y":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_vp_ns_test.go b/mistapi/sites_vp_ns_test.go new file mode 100644 index 00000000..e9f5f215 --- /dev/null +++ b/mistapi/sites_vp_ns_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestSitesVPNsTestListSiteVpnsDerived tests the behavior of the SitesVPNs +func TestSitesVPNsTestListSiteVpnsDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + apiResponse, err := sitesVpNs.ListSiteVpnsDerived(ctx, siteId, &resolve) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"name":"string","paths":{"property1":{"bfd_profile":"broadband","ip":"string"},"property2":{"bfd_profile":"lte","ip":"string"}}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_wan_usages_test.go b/mistapi/sites_wan_usages_test.go new file mode 100644 index 00000000..b2d2cb35 --- /dev/null +++ b/mistapi/sites_wan_usages_test.go @@ -0,0 +1,72 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWANUsagesTestCountSiteWanUsage tests the behavior of the SitesWANUsages +func TestSitesWANUsagesTestCountSiteWanUsage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + distinct := models.WanUsagesCountDisctinctEnum("policy") + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesWanUsages.CountSiteWanUsage(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, &distinct, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWANUsagesTestSearchSiteWanUsage tests the behavior of the SitesWANUsages +func TestSitesWANUsagesTestSearchSiteWanUsage(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + + + + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := sitesWanUsages.SearchSiteWanUsage(ctx, siteId, nil, nil, nil, nil, nil, nil, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/sites_webhooks_test.go b/mistapi/sites_webhooks_test.go new file mode 100644 index 00000000..877cfeee --- /dev/null +++ b/mistapi/sites_webhooks_test.go @@ -0,0 +1,211 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWebhooksTestListSiteWebhooks tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestListSiteWebhooks(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesWebhooks.ListSiteWebhooks(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestCreateSiteWebhook tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestCreateSiteWebhook(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Webhook + errBody := json.Unmarshal([]byte(`{"enabled":true,"headers":{},"name":"string","secret":"string","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWebhooks.CreateSiteWebhook(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestDeleteSiteWebhook tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestDeleteSiteWebhook(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWebhooks.DeleteSiteWebhook(ctx, siteId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesWebhooksTestGetSiteWebhook tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestGetSiteWebhook(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWebhooks.GetSiteWebhook(ctx, siteId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestUpdateSiteWebhook tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestUpdateSiteWebhook(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Webhook + errBody := json.Unmarshal([]byte(`{"enabled":true,"headers":{},"name":"string","secret":"string","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWebhooks.UpdateSiteWebhook(ctx, siteId, webhookId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"enabled":true,"headers":{},"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","secret":"string","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","splunk_token":"string","topics":["location"],"type":"http-post","url":"string","verify_cert":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestCountSiteWebhooksDeliveries tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestCountSiteWebhooksDeliveries(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + status := models.WebhookDeliveryStatusEnum("failure") + topic := models.WebhookDeliveryTopicEnum("audits") + distinct := models.WebhookDeliveryDistinctEnum("webhook_id") + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesWebhooks.CountSiteWebhooksDeliveries(ctx, siteId, webhookId, nil, nil, &status, &topic, &distinct, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"distinct":"string","end":0,"limit":0,"results":[{"count":0,"property":"string"}],"start":0,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestSearchSiteWebhooksDeliveries tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestSearchSiteWebhooksDeliveries(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + status := models.WebhookDeliveryStatusEnum("failure") + topic := models.WebhookDeliveryTopicEnum("audits") + + + duration := "1d" + limit := int(100) + apiResponse, err := sitesWebhooks.SearchSiteWebhooksDeliveries(ctx, siteId, webhookId, nil, nil, &status, &topic, nil, nil, &duration, &limit) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1688035193,"limit":10,"results":[{"error":"string","id":"55b0f02f-ebf6-4ad2-8b10-200508a97581","org_id":"fc7e2967-e7ef-41e6-b007-1217713de05a","req_headers":"{\\\"Content-Type\\\":[\\\"application/json\\\"],\\\"User-Agent\\\":[\\\"Mist-webhook\\\"]}","req_payload":"{\\\"topic\\\":\\\"audits\\\",\\\"events\\\":[{\\\"admin_name\\\":\\\"John Doe john.doe@juniper.net\\\",\\\"after\\\":\\\"{\\\\\"radio_config\\\\\": {\\\\\"band_24\\\\\": {\\\\\"disabled\\\\\": false, \\\\\"allow_rrm_disable\\\\\": false, \\\\\"power_min\\\\\": null, \\\\\"power_max\\\\\": null, \\\\\"power\\\\\": 10, \\\\\"preamble\\\\\": \\\\\"short\\\\\", \\\\\"channels\\\\\": [1, 10], \\\\\"bandwidth\\\\\": 20}}}\\\",\\\"before\\\":\\\"{\\\\\"radio_config\\\\\": {\\\\\"band_24\\\\\": {\\\\\"disabled\\\\\": false, \\\\\"allow_rrm_disable\\\\\": false, \\\\\"power_min\\\\\": 8, \\\\\"power_max\\\\\": 18, \\\\\"power\\\\\": null, \\\\\"preamble\\\\\": \\\\\"long\\\\\", \\\\\"channels\\\\\": [1, 10], \\\\\"bandwidth\\\\\": 20}}}\\\",\\\"id\\\":\\\"737909a2-04ff-4aeb-b9da-cc924e74a4dd\\\",\\\"message\\\":\\\"Update Site Settings\\\",\\\"org_id\\\":\\\"fc7e2967-e7ef-41e6-b007-1217713de05a\\\",\\\"site_id\\\":\\\"256c3a35-9cb7-436e-bc6d-314972645d95\\\",\\\"site_name\\\":\\\"Test Site\\\",\\\"src_ip\\\":\\\"1.2.3.4\\\",\\\"timestamp\\\":1685956576.923601,\\\"user_agent\\\":\\\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36\\\"}]}","req_url":"http://example.com","resp_body":"Ok","resp_headers":"string","site_id":"256c3a35-9cb7-436e-bc6d-314972645d95","status":"success","status_code":200,"timestamp":1687962508.5836561,"topic":"audits","webhook_id":"7a11b901-f719-4c91-8aef-deb8699a6364"}],"start":1687948793,"total":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWebhooksTestPingSiteWebhook tests the behavior of the SitesWebhooks +func TestSitesWebhooksTestPingSiteWebhook(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + webhookId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWebhooks.PingSiteWebhook(ctx, siteId, webhookId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/sites_wlans_test.go b/mistapi/sites_wlans_test.go new file mode 100644 index 00000000..e9e670bd --- /dev/null +++ b/mistapi/sites_wlans_test.go @@ -0,0 +1,175 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWlansTestListSiteWlans tests the behavior of the SitesWlans +func TestSitesWlansTestListSiteWlans(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesWlans.ListSiteWlans(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesWlansTestCreateSiteWlan tests the behavior of the SitesWlans +func TestSitesWlansTestCreateSiteWlan(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Wlan + errBody := json.Unmarshal([]byte(`{"acct_immediate_update":false,"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"airwatch":{"api_key":"aHhlbGxvYXNkZmFzZGZhc2Rmc2RmCg==\"","console_url":"https://hs1.airwatchportals.com","enabled":true,"password":"user1","username":"test123"},"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"ap_ids":["497f6eca-6276-4993-bfeb-53cbbbbb6f08"],"app_limit":{"apps":{"dropbox":300,"netflix":60},"enabled":false,"wxtag_ids":{"f99862d9-2726-931f-7559-3dfdf5d070d3":30}},"app_qos":{"apps":{"skype-business-video":{"dscp":32,"dst_subnet":"10.2.0.0/16","src_subnet":"10.2.0.0/16"}},"enabled":true,"others":[{"dscp":32,"dst_subnet":"10.2.0.0/16","port_ranges":"80,1024-6553","protocol":"udp","src_subnet":"10.2.0.0/16"}]},"apply_to":"site","arp_filter":false,"auth":{"anticlog_threshold":16,"eap_reauth":false,"enable_mac_auth":false,"key_idx":1,"keys":["string"],"multi_psk_only":false,"pairwise":["wpa2-ccmp"],"private_wlan":true,"psk":"foryoureyesonly","type":"psk","wep_as_secondary_auth":true},"auth_server_selection":"ordered","auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_nas_id":"5c5b350e0101-nas","auth_servers_nas_ip":"15.3.1.5","auth_servers_retries":5,"auth_servers_timeout":5,"band":"string","band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10,20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"cisco_cwa":{"allowed_hostnames":["snapchat.com"],"allowed_subnets":["63.5.3.0/24"],"blocked_subnets":["192.168.0.0/16"],"enabled":false},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"coa_servers":[{"disable_event_timestamp_check":false,"enabled":false,"ip":"1.2.3.4","port":3799,"secret":"testing456"}],"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dns_server_rewrite":{"enabled":false,"radius_groups":{"contractor":"172.1.1.1","guest":"8.8.8.8"}},"dtim":2,"dynamic_psk":{"default_psk":"foryoureyesonly","default_vlan_id":999,"enabled":false,"source":"cloud_psks","vlan_ids":[1]},"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"hotspot20":{"domain_name":["mist.com"],"enabled":true,"nai_realms":["string"],"operators":["google","att"],"rcoi":["5A03BA0000"],"venue_name":"some_name"},"interface":"all","isolation":false,"l2_isolation":false,"legacy_overds":false,"limit_bcast":false,"limit_probe_response":true,"max_idletime":1800,"mist_nac":{"enabled":false},"no_static_dns":false,"no_static_ip":false,"ssid":"demo"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWlans.CreateSiteWlan(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWlansTestListSiteWlanDerived tests the behavior of the SitesWlans +func TestSitesWlansTestListSiteWlanDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resolve := bool(false) + + apiResponse, err := sitesWlans.ListSiteWlanDerived(ctx, siteId, &resolve, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestSitesWlansTestDeleteSiteWlan tests the behavior of the SitesWlans +func TestSitesWlansTestDeleteSiteWlan(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWlans.DeleteSiteWlan(ctx, siteId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesWlansTestGetSiteWlan tests the behavior of the SitesWlans +func TestSitesWlansTestGetSiteWlan(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWlans.GetSiteWlan(ctx, siteId, wlanId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWlansTestUpdateSiteWlan tests the behavior of the SitesWlans +func TestSitesWlansTestUpdateSiteWlan(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Wlan + errBody := json.Unmarshal([]byte(`{"acct_immediate_update":false,"acct_interim_interval":0,"acct_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1813,"secret":"testing123"}],"airwatch":{"api_key":"aHhlbGxvYXNkZmFzZGZhc2Rmc2RmCg==\"","console_url":"https://hs1.airwatchportals.com","enabled":true,"password":"user1","username":"test123"},"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"ap_ids":["497f6eca-6276-4993-bfeb-53cbbbbe6f08"],"app_limit":{"apps":{"dropbox":300,"netflix":60},"enabled":false,"wxtag_ids":{"f99862d9-2726-931f-7559-3dfdf5d070d3":30}},"app_qos":{"apps":{"skype-business-video":{"dscp":32,"dst_subnet":"10.2.0.0/16","src_subnet":"10.2.0.0/16"}},"enabled":true,"others":[{"dscp":32,"dst_subnet":"10.2.0.0/16","port_ranges":"80,1024-6553","protocol":"udp","src_subnet":"10.2.0.0/16"}]},"apply_to":"site","arp_filter":false,"auth":{"anticlog_threshold":16,"eap_reauth":false,"enable_mac_auth":false,"key_idx":1,"keys":["string"],"multi_psk_only":false,"pairwise":["wpa2-ccmp"],"private_wlan":true,"psk":"foryoureyesonly","type":"psk","wep_as_secondary_auth":true},"auth_server_selection":"ordered","auth_servers":[{"host":"1.2.3.4","keywrap_enabled":true,"keywrap_format":"hex","keywrap_kek":"1122334455","keywrap_mack":"1122334455","port":1812,"secret":"testing123"}],"auth_servers_nas_id":"5c5b350e0101-nas","auth_servers_nas_ip":"15.3.1.5","auth_servers_retries":5,"auth_servers_timeout":5,"band":"string","band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10,20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"cisco_cwa":{"allowed_hostnames":["snapchat.com"],"allowed_subnets":["63.5.3.0/24"],"blocked_subnets":["192.168.0.0/16"],"enabled":false},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"coa_servers":[{"disable_event_timestamp_check":false,"enabled":false,"ip":"1.2.3.4","port":3799,"secret":"testing456"}],"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dns_server_rewrite":{"enabled":false,"radius_groups":{"contractor":"172.1.1.1","guest":"8.8.8.8"}},"dtim":2,"dynamic_psk":{"default_psk":"foryoureyesonly","default_vlan_id":999,"enabled":false,"source":"cloud_psks","vlan_ids":[1]},"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"hotspot20":{"domain_name":["mist.com"],"enabled":true,"nai_realms":["string"],"operators":["google","att"],"rcoi":["5A03BA0000"],"venue_name":"some_name"},"interface":"all","isolation":false,"l2_isolation":false,"legacy_overds":false,"limit_bcast":false,"limit_probe_response":true,"max_idletime":1800,"mist_nac":{"enabled":false},"no_static_dns":false,"no_static_ip":false,"ssid":"demo"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWlans.UpdateSiteWlan(ctx, siteId, wlanId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"allow_ipv6_ndp":true,"allow_mdns":false,"allow_ssdp":false,"arp_filter":false,"band_steer":false,"band_steer_force_band5":false,"bands":["24","5"],"block_blacklist_clients":false,"bonjour":{"additional_vlan_ids":"10, 20","enabled":false,"services":{"airplay":{"radius_groups":["teachers"],"scope":"same_ap"}}},"client_limit_down":0,"client_limit_down_enabled":false,"client_limit_up":0,"client_limit_up_enabled":false,"disable_11ax":false,"disable_ht_vht_rates":false,"disable_uapsd":false,"disable_v1_roam_notify":false,"disable_v2_roam_notify":false,"disable_wmm":false,"dynamic_vlan":{"default_vlan_id":999,"enabled":false,"local_vlan_ids":[1],"type":"airespace-interface-name","vlans":{"131":"default","322":"fast,video"}},"enable_local_keycaching":false,"enable_wireless_bridging":false,"enabled":true,"fast_dot1x_timers":false,"hide_ssid":false,"hostname_ie":false,"ssid":"demo"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWlansTestUpdateSiteWlanPortalTemplate tests the behavior of the SitesWlans +func TestSitesWlansTestUpdateSiteWlanPortalTemplate(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wlanId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WlanPortalTemplate + errBody := json.Unmarshal([]byte(`{"accessCodeAlternateEmail":"string","alignment":"string","authButtonAmazon":"string","authButtonAzure":"string","authButtonEmail":"string","authButtonFacebook":"string","authButtonGoogle":"string","authButtonMicrosoft":"string","authButtonPassphrase":"string","authButtonSms":"string","authButtonSponsor":"string","authLabel":"string","backLink":"string","color":"string","colorDark":"string","colorLight":"string","company":true,"companyError":"string","companyLabel":"string","email":true,"emailAccessDomainError":"string","emailCancel":"string","emailCodeError":"string","emailError":"string","emailFieldLabel":"string","emailLabel":"string","emailMessage":"string","emailSubmit":"string","emailTitle":"string","field1":true,"field1Error":"string","field1Label":"string","field1Required":true,"field2":true,"field2Error":"string","field2Label":"string","field2Required":true,"field3":true,"field3Error":"string","field3Label":"string","field3Required":true,"field4":true,"field4Error":"string","field4Label":"string","field4Required":true,"message":"string","name":true,"nameError":"string","nameLabel":"string","optout":true,"optoutLabel":"string","pageTitle":"string","passphraseCancel":"string","passphraseError":"string","passphraseLabel":"string","passphraseMessage":"string","passphraseSubmit":"string","passphraseTitle":"string","poweredBy":true,"requiredFieldLabel":"string","signInLabel":"string","smsCarrierDefault":"string","smsCarrierError":"string","smsCarrierFieldLabel":"string","smsCodeCancel":"string","smsCodeError":"string","smsCodeFieldLabel":"string","smsCodeMessage":"string","smsCodeSubmit":"string","smsCodeTitle":"string","smsCountryFieldLabel":"string","smsCountryFormat":"string","smsHaveAccessCode":"string","smsMessageFormat":"string","smsNumberCancel":"string","smsNumberError":"string","smsNumberFieldLabel":"string","smsNumberFormat":"string","smsNumberMessage":"string","smsNumberSubmit":"string","smsNumberTitle":"string","smsUsernameFormat":"string","smsValidityDuration":0,"sponsorBackLink":"string","sponsorCancel":"string","sponsorEmail":"string","sponsorEmailError":"string","sponsorEmailTemplate":"string","sponsorInfoApproved":"string","sponsorInfoDenied":"string","sponsorInfoPending":"string","sponsorName":"string","sponsorNameError":"string","sponsorNotePending":"string","sponsorStatusApproved":"string","sponsorStatusDenied":"string","sponsorStatusPending":"string","sponsorSubmit":"string","tos":true,"tosAcceptLabel":"string","tosError":"string","tosLink":"string","tosText":"string"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWlans.UpdateSiteWlanPortalTemplate(ctx, siteId, wlanId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"portal_template":{"accessCodeAlternateEmail":"string","alignment":"left","authButtonAmazon":"string","authButtonAzure":"string","authButtonEmail":"string","authButtonFacebook":"string","authButtonGoogle":"string","authButtonMicrosoft":"string","authButtonPassphrase":"string","authButtonSms":"string","authButtonSponsor":"string","authLabel":"string","backLink":"string","color":"string","colorDark":"string","colorLight":"string","company":true,"companyError":"string","companyLabel":"string","email":true,"emailAccessDomainError":"string","emailCancel":"string","emailCodeError":"string","emailError":"string","emailFieldLabel":"string","emailLabel":"string","emailMessage":"string","emailSubmit":"string","emailTitle":"string","field1":true,"field1Error":"string","field1Label":"string","field1Required":true,"field2":true,"field2Error":"string","field2Label":"string","field2Required":true,"field3":true,"field3Error":"string","field3Label":"string","field3Required":true,"field4":true,"field4Error":"string","field4Label":"string","field4Required":true,"message":"string","name":true,"nameError":"string","nameLabel":"string","optout":true,"optoutLabel":"string","pageTitle":"string","passphraseCancel":"string","passphraseError":"string","passphraseLabel":"string","passphraseMessage":"string","passphraseSubmit":"string","passphraseTitle":"string","poweredBy":true,"requiredFieldLabel":"string","signInLabel":"string","smsCarrierDefault":"string","smsCarrierError":"string","smsCarrierFieldLabel":"string","smsCodeCancel":"string","smsCodeError":"string","smsCodeFieldLabel":"string","smsCodeMessage":"string","smsCodeSubmit":"string","smsCodeTitle":"string","smsCountryFieldLabel":"string","smsCountryFormat":"string","smsHaveAccessCode":"string","smsMessageFormat":"string","smsNumberCancel":"string","smsNumberError":"string","smsNumberFieldLabel":"string","smsNumberFormat":"string","smsNumberMessage":"string","smsNumberSubmit":"string","smsNumberTitle":"string","smsUsernameFormat":"string","smsValidityDuration":5,"sponsorBackLink":"string","sponsorCancel":"string","sponsorEmail":"string","sponsorEmailError":"string","sponsorEmailTemplate":"string","sponsorInfoApproved":"string","sponsorInfoDenied":"string","sponsorInfoPending":"string","sponsorName":"string","sponsorNameError":"string","sponsorNotePending":"string","sponsorStatusApproved":"string","sponsorStatusDenied":"string","sponsorStatusPending":"string","sponsorSubmit":"string","tos":true,"tosAcceptLabel":"string","tosError":"string","tosLink":"string","tosText":"string"}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_wx_rules_test.go b/mistapi/sites_wx_rules_test.go new file mode 100644 index 00000000..b0791137 --- /dev/null +++ b/mistapi/sites_wx_rules_test.go @@ -0,0 +1,148 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWxRulesTestListSiteWxRules tests the behavior of the SitesWxRules +func TestSitesWxRulesTestListSiteWxRules(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesWxRules.ListSiteWxRules(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53ebbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxRulesTestCreateSiteWxRule tests the behavior of the SitesWxRules +func TestSitesWxRulesTestCreateSiteWxRule(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanRule + errBody := json.Unmarshal([]byte(`{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"order":1,"src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxRules.CreateSiteWxRule(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxRulesTestGetSiteWxRulesDerived tests the behavior of the SitesWxRules +func TestSitesWxRulesTestGetSiteWxRulesDerived(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxRules.GetSiteWxRulesDerived(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-bfeb-53ebbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxRulesTestDeleteSiteWxRule tests the behavior of the SitesWxRules +func TestSitesWxRulesTestDeleteSiteWxRule(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWxRules.DeleteSiteWxRule(ctx, siteId, wxruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesWxRulesTestGetSiteWxRule tests the behavior of the SitesWxRules +func TestSitesWxRulesTestGetSiteWxRule(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxRules.GetSiteWxRule(ctx, siteId, wxruleId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxRulesTestUpdateSiteWxRule tests the behavior of the SitesWxRules +func TestSitesWxRulesTestUpdateSiteWxRule(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxruleId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanRule + errBody := json.Unmarshal([]byte(`{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"order":1,"src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxRules.UpdateSiteWxRule(ctx, siteId, wxruleId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"action":"allow","apply_tags":["c049dfcd-0c73-5014-1c64-062e9903f1e5"],"blocked_apps":["mist","all-videos"],"created_time":0,"dst_allow_wxtags":["fff34466-eec0-3756-6765-381c728a6037","eee2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"dst_deny_wxtags":["aaa34466-eec0-3756-6765-381c728a6037","bbb2c7b0-d1d0-5a30-f349-e35fa43dc3b3"],"enabled":true,"for_site":true,"id":"497f6eca-6276-4993-9feb-53cbbbba6f08","modified_time":0,"order":1,"org_id":"a40f5d1f-d889-42e9-94ea-b9b33585fc6b","site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","src_wxtags":["8bfc2490-d726-3587-038d-cb2e71bd2330","3aa8e73f-9f46-d827-8d6a-567bb7e67fc9"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_wx_tags_test.go b/mistapi/sites_wx_tags_test.go new file mode 100644 index 00000000..aad1521c --- /dev/null +++ b/mistapi/sites_wx_tags_test.go @@ -0,0 +1,172 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWxTagsTestListSiteWxTags tests the behavior of the SitesWxTags +func TestSitesWxTagsTestListSiteWxTags(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesWxTags.ListSiteWxTags(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTagsTestCreateSiteWxTag tests the behavior of the SitesWxTags +func TestSitesWxTagsTestCreateSiteWxTag(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanTag + errBody := json.Unmarshal([]byte(`{"match":"app","name":"match app","type":"match","values":["gmail","dropbox"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxTags.CreateSiteWxTag(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTagsTestGetSiteApplicationList tests the behavior of the SitesWxTags +func TestSitesWxTagsTestGetSiteApplicationList(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxTags.GetSiteApplicationList(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"group":"Emails","key":"gmail","name":"Gmail - web/app"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTagsTestDeleteSiteWxTag tests the behavior of the SitesWxTags +func TestSitesWxTagsTestDeleteSiteWxTag(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWxTags.DeleteSiteWxTag(ctx, siteId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesWxTagsTestGetSiteWxTag tests the behavior of the SitesWxTags +func TestSitesWxTagsTestGetSiteWxTag(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxTags.GetSiteWxTag(ctx, siteId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTagsTestUpdateSiteWxTag tests the behavior of the SitesWxTags +func TestSitesWxTagsTestUpdateSiteWxTag(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanTag + errBody := json.Unmarshal([]byte(`{"match":"app","name":"match app","type":"match","values":["gmail","dropbox"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxTags.UpdateSiteWxTag(ctx, siteId, wxtagId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","last_ips":["string"],"mac":"string","match":"wlan_id","modified_time":0,"name":"string","op":"in","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","resource_mac":"string","services":["string"],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","specs":[{"port_range":"string","protocol":"tcp","subnet":["string"]}],"subnet":"string","type":"match","values":["string"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTagsTestGetSiteCurrentMatchingClientsOfAWxTag tests the behavior of the SitesWxTags +func TestSitesWxTagsTestGetSiteCurrentMatchingClientsOfAWxTag(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtagId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxTags.GetSiteCurrentMatchingClientsOfAWxTag(ctx, siteId, wxtagId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"mac":"5684dae9ac8b","since":1428939600}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_wx_tunnels_test.go b/mistapi/sites_wx_tunnels_test.go new file mode 100644 index 00000000..ea52dd51 --- /dev/null +++ b/mistapi/sites_wx_tunnels_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesWxTunnelsTestListSiteWxTunnels tests the behavior of the SitesWxTunnels +func TestSitesWxTunnelsTestListSiteWxTunnels(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesWxTunnels.ListSiteWxTunnels(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":1500,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTunnelsTestCreateSiteWxTunnel tests the behavior of the SitesWxTunnels +func TestSitesWxTunnelsTestCreateSiteWxTunnel(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanTunnel + errBody := json.Unmarshal([]byte(`{"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"mtu":0,"name":"string","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"udp_port":0,"use_udp":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxTunnels.CreateSiteWxTunnel(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTunnelsTestDeleteSiteWxTunnel tests the behavior of the SitesWxTunnels +func TestSitesWxTunnelsTestDeleteSiteWxTunnel(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesWxTunnels.DeleteSiteWxTunnel(ctx, siteId, wxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesWxTunnelsTestGetSiteWxTunnel tests the behavior of the SitesWxTunnels +func TestSitesWxTunnelsTestGetSiteWxTunnel(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesWxTunnels.GetSiteWxTunnel(ctx, siteId, wxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesWxTunnelsTestUpdateSiteWxTunnel tests the behavior of the SitesWxTunnels +func TestSitesWxTunnelsTestUpdateSiteWxTunnel(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + wxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.WxlanTunnel + errBody := json.Unmarshal([]byte(`{"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"mtu":0,"name":"string","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"udp_port":0,"use_udp":true}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesWxTunnels.UpdateSiteWxTunnel(ctx, siteId, wxtunnelId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"dmvpn":{"enabled":true,"holding_time":0,"host_routes":["string"]},"for_mgmt":true,"hello_interval":1,"hello_retries":3,"hostname":"string","id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","ipsec":{"enabled":true,"psk":"string123"},"is_static":true,"modified_time":0,"mtu":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","peers":["string"],"router_id":"string","secret":"string","sessions":[{"ap_as_session_id":"string","comment":"string","enable_cookie":true,"ethertype":"ethernet","local_session_id":1,"pseudo_802.1ad_enabled":true,"remote_id":"string","remote_session_id":1,"use_ap_as_session_ids":true}],"site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","udp_port":0,"use_udp":true}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/sites_zones_test.go b/mistapi/sites_zones_test.go new file mode 100644 index 00000000..b49fe478 --- /dev/null +++ b/mistapi/sites_zones_test.go @@ -0,0 +1,128 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestSitesZonesTestListSiteZones tests the behavior of the SitesZones +func TestSitesZonesTestListSiteZones(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + limit := int(100) + page := int(1) + apiResponse, err := sitesZones.ListSiteZones(ctx, siteId, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vertices":[{"x":0,"y":0}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesZonesTestCreateSiteZone tests the behavior of the SitesZones +func TestSitesZonesTestCreateSiteZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Zone + errBody := json.Unmarshal([]byte(`{"name":"string","vertices":[{"x":0,"y":0}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesZones.CreateSiteZone(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vertices":[{"x":0,"y":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesZonesTestDeleteSiteZone tests the behavior of the SitesZones +func TestSitesZonesTestDeleteSiteZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + zoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := sitesZones.DeleteSiteZone(ctx, siteId, zoneId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestSitesZonesTestGetSiteZone tests the behavior of the SitesZones +func TestSitesZonesTestGetSiteZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + zoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := sitesZones.GetSiteZone(ctx, siteId, zoneId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vertices":[{"x":0,"y":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestSitesZonesTestUpdateSiteZone tests the behavior of the SitesZones +func TestSitesZonesTestUpdateSiteZone(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + zoneId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.Zone + errBody := json.Unmarshal([]byte(`{"name":"string","vertices":[{"x":0,"y":0}]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := sitesZones.UpdateSiteZone(ctx, siteId, zoneId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"created_time":0,"id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","map_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","modified_time":0,"name":"string","org_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","site_id":"b069b358-4c97-5319-1f8c-7c5ca64d6ab1","vertices":[{"x":0,"y":0}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/tests_base.go b/mistapi/tests_base.go new file mode 100644 index 00000000..51759bff --- /dev/null +++ b/mistapi/tests_base.go @@ -0,0 +1,561 @@ +package mistapi + +var admins Admins + +var adminsLogin AdminsLogin + +var adminsLogout AdminsLogout + +var adminsRecoverPassword AdminsRecoverPassword + +var adminsLookup AdminsLookup + +var installer Installer + +var msPs MSPs + +var msPsAdmins MSPsAdmins + +var msPsInventory MSPsInventory + +var msPsLogo MSPsLogo + +var msPsLogs MSPsLogs + +var msPsLicenses MSPsLicenses + +var msPsMarvis MSPsMarvis + +var msPsOrgGroups MSPsOrgGroups + +var msPsOrgs MSPsOrgs + +var msPsSsoRoles MSPsSSORoles + +var msPsSso MSPsSSO + +var msPsTickets MSPsTickets + +var orgs Orgs + +var orgsAdmins OrgsAdmins + +var orgsAlarms OrgsAlarms + +var orgsAlarmTemplates OrgsAlarmTemplates + +var orgsApTemplates OrgsAPTemplates + +var orgsApiTokens OrgsAPITokens + +var orgsAssets OrgsAssets + +var orgsAssetFilters OrgsAssetFilters + +var orgsCert OrgsCert + +var orgsAntivirusProfiles OrgsAntivirusProfiles + +var orgsClientsMarvis OrgsClientsMarvis + +var orgsClientsNac OrgsClientsNAC + +var orgsClientsWan OrgsClientsWan + +var orgsClientsWired OrgsClientsWired + +var orgsClientsWireless OrgsClientsWireless + +var orgsClientsSdk OrgsClientsSDK + +var orgsCradlepoint OrgsCradlepoint + +var orgsCrl OrgsCRL + +var orgsDeviceProfiles OrgsDeviceProfiles + +var orgsDevices OrgsDevices + +var orgsDevicesSsr OrgsDevicesSSR + +var orgsEvpnTopologies OrgsEVPNTopologies + +var orgsDevicesOthers OrgsDevicesOthers + +var orgsSettingZscaler OrgsSettingZscaler + +var orgsScep OrgsSCEP + +var orgsGatewayTemplates OrgsGatewayTemplates + +var orgsGuests OrgsGuests + +var orgsIdpProfiles OrgsIDPProfiles + +var orgsInventory OrgsInventory + +var orgsJse OrgsJSE + +var orgsJsi OrgsJSI + +var orgsLicenses OrgsLicenses + +var orgsLinkedApplications OrgsLinkedApplications + +var orgsLogs OrgsLogs + +var orgsMarvis OrgsMarvis + +var orgsMaps OrgsMaps + +var orgsMxClusters OrgsMxClusters + +var orgsMxEdges OrgsMxEdges + +var orgsMxTunnels OrgsMxTunnels + +var orgsNacidp OrgsNACIDP + +var orgsNacTags OrgsNACTags + +var orgsNacPortals OrgsNACPortals + +var orgsNaccrl OrgsNACCRL + +var orgsStats OrgsStats + +var orgsStatsAssets OrgsStatsAssets + +var orgsStatsBgpPeers OrgsStatsBGPPeers + +var orgsStatsMxEdges OrgsStatsMxEdges + +var orgsStatsOtherDevices OrgsStatsOtherDevices + +var orgsStatsPorts OrgsStatsPorts + +var orgsStatsTunnels OrgsStatsTunnels + +var orgsStatsVpnPeers OrgsStatsVPNPeers + +var orgsNacRules OrgsNACRules + +var orgsNetworkTemplates OrgsNetworkTemplates + +var orgsNetworks OrgsNetworks + +var orgsPremiumAnalytics OrgsPremiumAnalytics + +var orgsPsks OrgsPsks + +var orgsPskPortals OrgsPskPortals + +var orgsRfTemplates OrgsRFTemplates + +var orgsSdkInvites OrgsSDKInvites + +var orgsSdkTemplates OrgsSDKTemplates + +var orgsSecPolicies OrgsSecPolicies + +var orgsServices OrgsServices + +var orgsServicePolicies OrgsServicePolicies + +var orgsSetting OrgsSetting + +var orgsSitegroups OrgsSitegroups + +var orgsSites OrgsSites + +var orgsSiteTemplates OrgsSiteTemplates + +var orgsSsoRoles OrgsSSORoles + +var orgsSso OrgsSSO + +var orgsSubscriptions OrgsSubscriptions + +var orgsWlanTemplates OrgsWLANTemplates + +var orgsTickets OrgsTickets + +var orgsUserMaCs OrgsUserMACs + +var orgsVars OrgsVars + +var orgsVpNs OrgsVPNs + +var orgsWebhooks OrgsWebhooks + +var orgsWlans OrgsWlans + +var orgsWxRules OrgsWxRules + +var orgsWxTags OrgsWxTags + +var orgsWxTunnels OrgsWxTunnels + +var sites Sites + +var sitesAlarms SitesAlarms + +var sitesApTemplates SitesAPTemplates + +var sitesApplications SitesApplications + +var sitesAssetFilters SitesAssetFilters + +var sitesAssets SitesAssets + +var sitesBeacons SitesBeacons + +var sitesClientsNac SitesClientsNAC + +var sitesClientsWan SitesClientsWan + +var sitesClientsWired SitesClientsWired + +var sitesClientsWireless SitesClientsWireless + +var sitesDevices SitesDevices + +var sitesDevicesWireless SitesDevicesWireless + +var sitesDevicesOthers SitesDevicesOthers + +var sitesDevicesWired SitesDevicesWired + +var sitesDevicesWiredVirtualChassis SitesDevicesWiredVirtualChassis + +var sitesDevicesWanCluster SitesDevicesWANCluster + +var sitesDeviceProfiles SitesDeviceProfiles + +var sitesEvents SitesEvents + +var sitesEvpnTopologies SitesEVPNTopologies + +var sitesGatewayTemplates SitesGatewayTemplates + +var sitesGuests SitesGuests + +var sitesJse SitesJSE + +var sitesLicenses SitesLicenses + +var sitesLocation SitesLocation + +var sitesMaps SitesMaps + +var sitesMapsAutoPlacement SitesMapsAutoPlacement + +var sitesMxEdges SitesMxEdges + +var sitesNetworkTemplates SitesNetworkTemplates + +var sitesNetworks SitesNetworks + +var sitesPsks SitesPsks + +var sitesRfTemplates SitesRFTemplates + +var sitesRfdiags SitesRfdiags + +var sitesRogues SitesRogues + +var sitesRrm SitesRRM + +var sitesRssiZones SitesRSSIZones + +var sitesServices SitesServices + +var sitesServicePolicies SitesServicePolicies + +var sitesSetting SitesSetting + +var sitesSiteTemplates SitesSiteTemplates + +var sitesSkyatp SitesSkyatp + +var sitesSyntheticTests SitesSyntheticTests + +var sitesUiSettings SitesUISettings + +var sitesVBeacons SitesVBeacons + +var sitesVpNs SitesVPNs + +var sitesWanUsages SitesWANUsages + +var sitesWebhooks SitesWebhooks + +var sitesWlans SitesWlans + +var sitesWxRules SitesWxRules + +var sitesWxTags SitesWxTags + +var sitesWxTunnels SitesWxTunnels + +var sitesZones SitesZones + +var sitesStats SitesStats + +var sitesStatsApps SitesStatsApps + +var sitesStatsAssets SitesStatsAssets + +var sitesStatsBeacons SitesStatsBeacons + +var sitesStatsBgpPeers SitesStatsBGPPeers + +var sitesStatsCalls SitesStatsCalls + +var sitesStatsClientsWireless SitesStatsClientsWireless + +var sitesStatsClientsSdk SitesStatsClientsSDK + +var sitesStatsDevices SitesStatsDevices + +var sitesStatsMxEdges SitesStatsMxEdges + +var sitesStatsPorts SitesStatsPorts + +var sitesStatsWxRules SitesStatsWxRules + +var sitesStatsZones SitesStatsZones + +var sitesStatsDiscoveredSwitches SitesStatsDiscoveredSwitches + +var constantsDefinitions ConstantsDefinitions + +var constantsEvents ConstantsEvents + +var constantsModels ConstantsModels + +var selfAccount SelfAccount + +var selfApiToken SelfAPIToken + +var selfMfa SelfMFA + +var selfAlarms SelfAlarms + +var selfAuditLogs SelfAuditLogs + +var samplesWebhooks SamplesWebhooks + +var utilitiesCommon UtilitiesCommon + +var utilitiesWan UtilitiesWAN + +var utilitiesLan UtilitiesLAN + +var utilitiesWiFi UtilitiesWiFi + +var utilitiesPcaPs UtilitiesPCAPs + +var utilitiesLocation UtilitiesLocation + +var utilitiesMxEdge UtilitiesMxEdge + +var utilitiesUpgrade UtilitiesUpgrade + +// init is an initialization function that sets up the controllers. +// It creates a configuration from the environment with a specified HTTP configuration and initializes the client. +// Then, it assigns the different controllers from the client to the corresponding variables for further use. +func init() { + + config := CreateConfigurationFromEnvironment( + WithHttpConfiguration( + CreateHttpConfiguration( + WithTimeout(30), + ), + ), + ) + + client := NewClient(config) + + admins = *client.Admins() + adminsLogin = *client.AdminsLogin() + adminsLogout = *client.AdminsLogout() + adminsRecoverPassword = *client.AdminsRecoverPassword() + adminsLookup = *client.AdminsLookup() + installer = *client.Installer() + msPs = *client.MSPs() + msPsAdmins = *client.MSPsAdmins() + msPsInventory = *client.MSPsInventory() + msPsLogo = *client.MSPsLogo() + msPsLogs = *client.MSPsLogs() + msPsLicenses = *client.MSPsLicenses() + msPsMarvis = *client.MSPsMarvis() + msPsOrgGroups = *client.MSPsOrgGroups() + msPsOrgs = *client.MSPsOrgs() + msPsSsoRoles = *client.MSPsSSORoles() + msPsSso = *client.MSPsSSO() + msPsTickets = *client.MSPsTickets() + orgs = *client.Orgs() + orgsAdmins = *client.OrgsAdmins() + orgsAlarms = *client.OrgsAlarms() + orgsAlarmTemplates = *client.OrgsAlarmTemplates() + orgsApTemplates = *client.OrgsAPTemplates() + orgsApiTokens = *client.OrgsAPITokens() + orgsAssets = *client.OrgsAssets() + orgsAssetFilters = *client.OrgsAssetFilters() + orgsCert = *client.OrgsCert() + orgsAntivirusProfiles = *client.OrgsAntivirusProfiles() + orgsClientsMarvis = *client.OrgsClientsMarvis() + orgsClientsNac = *client.OrgsClientsNAC() + orgsClientsWan = *client.OrgsClientsWan() + orgsClientsWired = *client.OrgsClientsWired() + orgsClientsWireless = *client.OrgsClientsWireless() + orgsClientsSdk = *client.OrgsClientsSDK() + orgsCradlepoint = *client.OrgsCradlepoint() + orgsCrl = *client.OrgsCRL() + orgsDeviceProfiles = *client.OrgsDeviceProfiles() + orgsDevices = *client.OrgsDevices() + orgsDevicesSsr = *client.OrgsDevicesSSR() + orgsEvpnTopologies = *client.OrgsEVPNTopologies() + orgsDevicesOthers = *client.OrgsDevicesOthers() + orgsSettingZscaler = *client.OrgsSettingZscaler() + orgsScep = *client.OrgsSCEP() + orgsGatewayTemplates = *client.OrgsGatewayTemplates() + orgsGuests = *client.OrgsGuests() + orgsIdpProfiles = *client.OrgsIDPProfiles() + orgsInventory = *client.OrgsInventory() + orgsJse = *client.OrgsJSE() + orgsJsi = *client.OrgsJSI() + orgsLicenses = *client.OrgsLicenses() + orgsLinkedApplications = *client.OrgsLinkedApplications() + orgsLogs = *client.OrgsLogs() + orgsMarvis = *client.OrgsMarvis() + orgsMaps = *client.OrgsMaps() + orgsMxClusters = *client.OrgsMxClusters() + orgsMxEdges = *client.OrgsMxEdges() + orgsMxTunnels = *client.OrgsMxTunnels() + orgsNacidp = *client.OrgsNACIDP() + orgsNacTags = *client.OrgsNACTags() + orgsNacPortals = *client.OrgsNACPortals() + orgsNaccrl = *client.OrgsNACCRL() + orgsStats = *client.OrgsStats() + orgsStatsAssets = *client.OrgsStatsAssets() + orgsStatsBgpPeers = *client.OrgsStatsBGPPeers() + orgsStatsMxEdges = *client.OrgsStatsMxEdges() + orgsStatsOtherDevices = *client.OrgsStatsOtherDevices() + orgsStatsPorts = *client.OrgsStatsPorts() + orgsStatsTunnels = *client.OrgsStatsTunnels() + orgsStatsVpnPeers = *client.OrgsStatsVPNPeers() + orgsNacRules = *client.OrgsNACRules() + orgsNetworkTemplates = *client.OrgsNetworkTemplates() + orgsNetworks = *client.OrgsNetworks() + orgsPremiumAnalytics = *client.OrgsPremiumAnalytics() + orgsPsks = *client.OrgsPsks() + orgsPskPortals = *client.OrgsPskPortals() + orgsRfTemplates = *client.OrgsRFTemplates() + orgsSdkInvites = *client.OrgsSDKInvites() + orgsSdkTemplates = *client.OrgsSDKTemplates() + orgsSecPolicies = *client.OrgsSecPolicies() + orgsServices = *client.OrgsServices() + orgsServicePolicies = *client.OrgsServicePolicies() + orgsSetting = *client.OrgsSetting() + orgsSitegroups = *client.OrgsSitegroups() + orgsSites = *client.OrgsSites() + orgsSiteTemplates = *client.OrgsSiteTemplates() + orgsSsoRoles = *client.OrgsSSORoles() + orgsSso = *client.OrgsSSO() + orgsSubscriptions = *client.OrgsSubscriptions() + orgsWlanTemplates = *client.OrgsWLANTemplates() + orgsTickets = *client.OrgsTickets() + orgsUserMaCs = *client.OrgsUserMACs() + orgsVars = *client.OrgsVars() + orgsVpNs = *client.OrgsVPNs() + orgsWebhooks = *client.OrgsWebhooks() + orgsWlans = *client.OrgsWlans() + orgsWxRules = *client.OrgsWxRules() + orgsWxTags = *client.OrgsWxTags() + orgsWxTunnels = *client.OrgsWxTunnels() + sites = *client.Sites() + sitesAlarms = *client.SitesAlarms() + sitesApTemplates = *client.SitesAPTemplates() + sitesApplications = *client.SitesApplications() + sitesAssetFilters = *client.SitesAssetFilters() + sitesAssets = *client.SitesAssets() + sitesBeacons = *client.SitesBeacons() + sitesClientsNac = *client.SitesClientsNAC() + sitesClientsWan = *client.SitesClientsWan() + sitesClientsWired = *client.SitesClientsWired() + sitesClientsWireless = *client.SitesClientsWireless() + sitesDevices = *client.SitesDevices() + sitesDevicesWireless = *client.SitesDevicesWireless() + sitesDevicesOthers = *client.SitesDevicesOthers() + sitesDevicesWired = *client.SitesDevicesWired() + sitesDevicesWiredVirtualChassis = *client.SitesDevicesWiredVirtualChassis() + sitesDevicesWanCluster = *client.SitesDevicesWANCluster() + sitesDeviceProfiles = *client.SitesDeviceProfiles() + sitesEvents = *client.SitesEvents() + sitesEvpnTopologies = *client.SitesEVPNTopologies() + sitesGatewayTemplates = *client.SitesGatewayTemplates() + sitesGuests = *client.SitesGuests() + sitesJse = *client.SitesJSE() + sitesLicenses = *client.SitesLicenses() + sitesLocation = *client.SitesLocation() + sitesMaps = *client.SitesMaps() + sitesMapsAutoPlacement = *client.SitesMapsAutoPlacement() + sitesMxEdges = *client.SitesMxEdges() + sitesNetworkTemplates = *client.SitesNetworkTemplates() + sitesNetworks = *client.SitesNetworks() + sitesPsks = *client.SitesPsks() + sitesRfTemplates = *client.SitesRFTemplates() + sitesRfdiags = *client.SitesRfdiags() + sitesRogues = *client.SitesRogues() + sitesRrm = *client.SitesRRM() + sitesRssiZones = *client.SitesRSSIZones() + sitesServices = *client.SitesServices() + sitesServicePolicies = *client.SitesServicePolicies() + sitesSetting = *client.SitesSetting() + sitesSiteTemplates = *client.SitesSiteTemplates() + sitesSkyatp = *client.SitesSkyatp() + sitesSyntheticTests = *client.SitesSyntheticTests() + sitesUiSettings = *client.SitesUISettings() + sitesVBeacons = *client.SitesVBeacons() + sitesVpNs = *client.SitesVPNs() + sitesWanUsages = *client.SitesWANUsages() + sitesWebhooks = *client.SitesWebhooks() + sitesWlans = *client.SitesWlans() + sitesWxRules = *client.SitesWxRules() + sitesWxTags = *client.SitesWxTags() + sitesWxTunnels = *client.SitesWxTunnels() + sitesZones = *client.SitesZones() + sitesStats = *client.SitesStats() + sitesStatsApps = *client.SitesStatsApps() + sitesStatsAssets = *client.SitesStatsAssets() + sitesStatsBeacons = *client.SitesStatsBeacons() + sitesStatsBgpPeers = *client.SitesStatsBGPPeers() + sitesStatsCalls = *client.SitesStatsCalls() + sitesStatsClientsWireless = *client.SitesStatsClientsWireless() + sitesStatsClientsSdk = *client.SitesStatsClientsSDK() + sitesStatsDevices = *client.SitesStatsDevices() + sitesStatsMxEdges = *client.SitesStatsMxEdges() + sitesStatsPorts = *client.SitesStatsPorts() + sitesStatsWxRules = *client.SitesStatsWxRules() + sitesStatsZones = *client.SitesStatsZones() + sitesStatsDiscoveredSwitches = *client.SitesStatsDiscoveredSwitches() + constantsDefinitions = *client.ConstantsDefinitions() + constantsEvents = *client.ConstantsEvents() + constantsModels = *client.ConstantsModels() + selfAccount = *client.SelfAccount() + selfApiToken = *client.SelfAPIToken() + selfMfa = *client.SelfMFA() + selfAlarms = *client.SelfAlarms() + selfAuditLogs = *client.SelfAuditLogs() + samplesWebhooks = *client.SamplesWebhooks() + utilitiesCommon = *client.UtilitiesCommon() + utilitiesWan = *client.UtilitiesWAN() + utilitiesLan = *client.UtilitiesLAN() + utilitiesWiFi = *client.UtilitiesWiFi() + utilitiesPcaPs = *client.UtilitiesPCAPs() + utilitiesLocation = *client.UtilitiesLocation() + utilitiesMxEdge = *client.UtilitiesMxEdge() + utilitiesUpgrade = *client.UtilitiesUpgrade() +} diff --git a/mistapi/utilities_common_test.go b/mistapi/utilities_common_test.go new file mode 100644 index 00000000..f978b8e5 --- /dev/null +++ b/mistapi/utilities_common_test.go @@ -0,0 +1,506 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesCommonTestArpFromDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestArpFromDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.HaClusterNode + errBody := json.Unmarshal([]byte(`{"node":"node0"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesCommon.ArpFromDevice(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestClearSiteDeviceMacTable tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestClearSiteDeviceMacTable(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.ClearSiteDeviceMacTable(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestClearSiteDevicePolicyHitCount tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestClearSiteDevicePolicyHitCount(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesCommon.ClearSiteDevicePolicyHitCount(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceConfigCmd tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceConfigCmd(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + sort := bool(false) + apiResponse, err := utilitiesCommon.GetSiteDeviceConfigCmd(ctx, siteId, deviceId, &sort) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"cli":["set system hostname corp-a135"]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesCommonTestStartSiteLocateDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestStartSiteLocateDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesCommon.StartSiteLocateDevice(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestMonitorSiteDeviceTraffic tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestMonitorSiteDeviceTraffic(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.MonitorSiteDeviceTraffic(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestPingFromDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestPingFromDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsPing + errBody := json.Unmarshal([]byte(`{"count":10,"host":"1.1.1.1"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesCommon.PingFromDevice(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestReadoptSiteOctermDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestReadoptSiteOctermDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesCommon.ReadoptSiteOctermDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestReleaseSiteDeviceDhcpLease tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestReleaseSiteDeviceDhcpLease(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsReleaseDhcpLeases + errBody := json.Unmarshal([]byte(`{"port_id":"ge-0/0/1.10"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesCommon.ReleaseSiteDeviceDhcpLease(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestReprovisionSiteOctermDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestReprovisionSiteOctermDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesCommon.ReprovisionSiteOctermDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestGetSiteDeviceZtpPassword tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceZtpPassword(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesCommon.GetSiteDeviceZtpPassword(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"root_password":"ef8070ef8f924edb592e1819ed64b31172ab8de9d5cde75d3f46acd9506202ab9b1cbb97e381c5aa11037f17e5ed7b4b609461cd813d944670549d410ef82f2e"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesCommonTestRestartSiteDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestRestartSiteDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesCommon.RestartSiteDevice(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestCreateSiteDeviceShellSession tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestCreateSiteDeviceShellSession(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesCommon.CreateSiteDeviceShellSession(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceArpTable tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceArpTable(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.GetSiteDeviceArpTable(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceBgpSummary tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceBgpSummary(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.GetSiteDeviceBgpSummary(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestShowSiteDeviceDhcpLeases tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestShowSiteDeviceDhcpLeases(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.ShowSiteDeviceDhcpLeases(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceEvpnDatabase tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceEvpnDatabase(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.GetSiteDeviceEvpnDatabase(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceForwardingTable tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceForwardingTable(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.GetSiteDeviceForwardingTable(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestGetSiteDeviceMacTable tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestGetSiteDeviceMacTable(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesCommon.GetSiteDeviceMacTable(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestUploadSiteDeviceSupportFile tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestUploadSiteDeviceSupportFile(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsSendSupportLogs + errBody := json.Unmarshal([]byte(`{"info":"full"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesCommon.UploadSiteDeviceSupportFile(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesCommonTestTracerouteFromDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestTracerouteFromDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsTraceroute + errBody := json.Unmarshal([]byte(`{"host":"string","port":33434,"protocol":"udp"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesCommon.TracerouteFromDevice(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesCommonTestStopSiteLocateDevice tests the behavior of the UtilitiesCommon +func TestUtilitiesCommonTestStopSiteLocateDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesCommon.StopSiteLocateDevice(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/utilities_lan_test.go b/mistapi/utilities_lan_test.go new file mode 100644 index 00000000..0f2ba2cb --- /dev/null +++ b/mistapi/utilities_lan_test.go @@ -0,0 +1,266 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesLANTestReauthOrgDot1xWiredClient tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestReauthOrgDot1xWiredClient(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + apiResponse, err := utilitiesLan.ReauthOrgDot1xWiredClient(ctx, orgId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"device_mac":"5c5b35000002","port_id":"ge-0/0/0","session":"0a2a11b8-4b30-40d8-a6d1-e91ea540d86f"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesLANTestUpgradeSiteDevicesBios tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestUpgradeSiteDevicesBios(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesLan.UpgradeSiteDevicesBios(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestUpgradeSiteDevicesFpga tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestUpgradeSiteDevicesFpga(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesLan.UpgradeSiteDevicesFpga(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestPortsBounceFromSwitch tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestPortsBounceFromSwitch(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsBouncePort + errBody := json.Unmarshal([]byte(`{"ports":["ge-0/0/0","ge-0/0/1"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesLan.PortsBounceFromSwitch(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestCableTestFromSwitch tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestCableTestFromSwitch(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsCableTests + errBody := json.Unmarshal([]byte(`{"port":"ge-0/0/0"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesLan.CableTestFromSwitch(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesLANTestClearBpduErrosFromPortsOnSwitch tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestClearBpduErrosFromPortsOnSwitch(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesLan.ClearBpduErrosFromPortsOnSwitch(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestClearAllLearnedMacsFromPortOnSwitch tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestClearAllLearnedMacsFromPortOnSwitch(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsClearMacs + errBody := json.Unmarshal([]byte(`{"ports":["ge-0/0/0.0"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesLan.ClearAllLearnedMacsFromPortOnSwitch(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestPollSiteSwitchStats tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestPollSiteSwitchStats(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesLan.PollSiteSwitchStats(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesLANTestCreateSiteDeviceSnapshot tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestCreateSiteDeviceSnapshot(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesLan.CreateSiteDeviceSnapshot(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"status_id":"string","staus":"starting","timestamp":0}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesLANTestUpgradeDeviceBios tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestUpgradeDeviceBios(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesLan.UpgradeDeviceBios(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"status":"inprogress","timestamp":1428949501}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesLANTestUpgradeDeviceFPGA tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestUpgradeDeviceFPGA(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesLan.UpgradeDeviceFPGA(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"status":"inprogress","timestamp":1428949501}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesLANTestReauthSiteDot1xWiredClient tests the behavior of the UtilitiesLAN +func TestUtilitiesLANTestReauthSiteDot1xWiredClient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + apiResponse, err := utilitiesLan.ReauthSiteDot1xWiredClient(ctx, siteId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"device_mac":"5c5b35000002","port_id":"ge-0/0/0","session":"0a2a11b8-4b30-40d8-a6d1-e91ea540d86f"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/utilities_location_test.go b/mistapi/utilities_location_test.go new file mode 100644 index 00000000..67e0ffac --- /dev/null +++ b/mistapi/utilities_location_test.go @@ -0,0 +1,29 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesLocationTestSendSiteDevicesArbitratryBleBeacon tests the behavior of the UtilitiesLocation +func TestUtilitiesLocationTestSendSiteDevicesArbitratryBleBeacon(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsSendBleBeacon + errBody := json.Unmarshal([]byte(`{"beacon_frame":"68b329da9893e34099c7d8ad5cb9c940","beacon_freq":100,"duration":10,"macs":["5c5b35584a6f","5c5b350ea3b3"],"map_ids":["845a23bf-bed9-e43c-4c86-6fa474be7ae5"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesLocation.SendSiteDevicesArbitratryBleBeacon(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} diff --git a/mistapi/utilities_mx_edge_test.go b/mistapi/utilities_mx_edge_test.go new file mode 100644 index 00000000..ba141dd9 --- /dev/null +++ b/mistapi/utilities_mx_edge_test.go @@ -0,0 +1,30 @@ +package mistapi + +import ( + "context" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "testing" +) + +// TestUtilitiesMxEdgeTestPreemptSitesMxTunnel tests the behavior of the UtilitiesMxEdge +func TestUtilitiesMxEdgeTestPreemptSitesMxTunnel(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mxtunnelId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesMxEdge.PreemptSitesMxTunnel(ctx, siteId, mxtunnelId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/utilities_pca_ps_test.go b/mistapi/utilities_pca_ps_test.go new file mode 100644 index 00000000..0907da9c --- /dev/null +++ b/mistapi/utilities_pca_ps_test.go @@ -0,0 +1,179 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesPCAPsTestListOrgPacketCaptures tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestListOrgPacketCaptures(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := utilitiesPcaPs.ListOrgPacketCaptures(ctx, orgId, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1461089816,"limit":100,"next":"/api/v1/sites/67970e46-4e12-11e6-9188-0242ac110007/pcaps?start=1461099816&search_after=%5B1694537121217%5D&limit=100&end=1461089816","results":[{"ap_macs":["5c5b35000010"],"timestamp":1461869041,"type":"new_assoc","url":"https://..."}],"start":1461099816}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesPCAPsTestStopOrgPacketCapture tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestStopOrgPacketCapture(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesPcaPs.StopOrgPacketCapture(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesPCAPsTestGetOrgCapturingStatus tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestGetOrgCapturingStatus(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesPcaPs.GetOrgCapturingStatus(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aps":["5c5b350e001c","5c5b350e001b"],"client_mac":"60a10a773412","duration":300,"failed":[],"id":"a9a84e13-a714-b1eb-152f-a434416217d5","includes_mcast":false,"max_pkt_len":128,"num_packets":1000,"ok":["5c5b350e001c","5c5b350e001b"],"started_time":1435080709,"type":"client"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesPCAPsTestStartOrgPacketCapture tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestStartOrgPacketCapture(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.CaptureOrg + errBody := json.Unmarshal([]byte(`{"duration":600,"format":"stream","max_pkt_len":1500,"mxedges":{"00000000-0000-0000-1000-001122334455":{"interfaces":{"port1":{"tcpdump_expression":"udp port 67 or udp port 68"}}}},"num_packets":100,"tcpdump_expression":"vlan 999","type":"mxedge"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesPcaPs.StartOrgPacketCapture(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ap_count":3,"aps":[],"duration":600,"enabled":true,"expiry":1614886726.5411825,"format":"stream","id":"a9a84e13-a714-b1eb-152f-a434416217d5","include_mcast":false,"max_pkt_len":68,"num_packets":100,"org_id":"a9346fba-f920-e99a-cc51-2e8dcc57fa3c","raw":true,"site_id":"67970e46-4e12-11e6-9188-0242ac110007","ssid":"","timestamp":1614886126.5411825,"type":"radiotap"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesPCAPsTestListSitePacketCaptures tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestListSitePacketCaptures(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + + + duration := "1d" + limit := int(100) + page := int(1) + apiResponse, err := utilitiesPcaPs.ListSitePacketCaptures(ctx, siteId, nil, nil, nil, &duration, &limit, &page) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"end":1461089816,"limit":100,"next":"/api/v1/sites/67970e46-4e12-11e6-9188-0242ac110007/pcaps?start=1461099816&search_after=%5B1694537121217%5D&limit=100&end=1461089816","results":[{"ap_macs":["5c5b35000010"],"timestamp":1461869041,"type":"new_assoc","url":"https://..."}],"start":1461099816}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesPCAPsTestStopSitePacketCapture tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestStopSitePacketCapture(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesPcaPs.StopSitePacketCapture(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesPCAPsTestGetSiteCapturingStatus tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestGetSiteCapturingStatus(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesPcaPs.GetSiteCapturingStatus(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"aps":["5c5b350e001c","5c5b350e001b"],"client_mac":"60a10a773412","duration":300,"failed":[],"id":"a9a84e13-a714-b1eb-152f-a434416217d5","includes_mcast":false,"max_pkt_len":128,"num_packets":1000,"ok":["5c5b350e001c","5c5b350e001b"],"started_time":1435080709,"type":"client"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesPCAPsTestStartSitePacketCapture tests the behavior of the UtilitiesPCAPs +func TestUtilitiesPCAPsTestStartSitePacketCapture(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.CaptureSite + errBody := json.Unmarshal([]byte(`{"client_mac":"60a10a773412","duration":600,"includes_mcast":false,"max_pkt_len":128,"num_packets":100,"type":"new_assoc"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesPcaPs.StartSitePacketCapture(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"ap_count":3,"aps":[],"duration":600,"enabled":true,"expiry":1614886726.5411825,"format":"stream","id":"a9a84e13-a714-b1eb-152f-a434416217d5","include_mcast":false,"max_pkt_len":68,"num_packets":100,"org_id":"a9346fba-f920-e99a-cc51-2e8dcc57fa3c","raw":true,"site_id":"67970e46-4e12-11e6-9188-0242ac110007","ssid":"","timestamp":1614886126.5411825,"type":"radiotap"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/utilities_upgrade_test.go b/mistapi/utilities_upgrade_test.go new file mode 100644 index 00000000..4007f9be --- /dev/null +++ b/mistapi/utilities_upgrade_test.go @@ -0,0 +1,426 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesUpgradeTestListOrgDeviceUpgrades tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListOrgDeviceUpgrades(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.ListOrgDeviceUpgrades(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"id":"466f6eca-6276-4993-bfeb-53cbbbba6f88","site_upgrades":[{"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","upgrade_id":"174bda0-06a3-40ee-b918-d9cbde303690"}]}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeOrgDevices tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeOrgDevices(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesUpgrade.UpgradeOrgDevices(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"enable_p2p":true,"force":true,"id":"466f6eca-6276-4993-bfeb-53cbbbba6f88","start_time":0,"status":"created","strategy":"big_bang","target_version":"string","upgrades":[{"site_id":"72771e6a-6f5e-4de4-a5b9-1266c4197811","upgrade":{"id":"465f6eca-6276-4993-bfeb-53cbbbba6f98","start_time":0,"status":"created","targets":{"download_requested":["5c5b3550bd2e"],"downloaded":["003e7316ff9e"],"failed":[],"reboot_in_progress":[],"rebooted":[],"skipped":[],"total":1,"upgraded":[".inf"]}}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestGetOrgDeviceUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestGetOrgDeviceUpgrade(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.GetOrgDeviceUpgrade(ctx, orgId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"enable_p2p":true,"force":true,"id":"31223085-405d-4b64-8aea-9c5b98098b4b","strategy":"big_bang","target_version":"0.14.29411","upgrades":[{"site_id":"1bbe6e79-2583-403c-be1a-9881b4691ab6","upgrade":{"id":"473f6eca-6276-4993-bfeb-53cbbbba6f18","start_time":1717658765,"status":"completed","targets":{"total":2,"upgraded":["5c5b3550bd2e","003e7316ff9e"]}}}]}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeOrgJsiDevice tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeOrgJsiDevice(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceMac := "0000000000ab" + var body models.VersionString + errBody := json.Unmarshal([]byte(`{"version":"3.1.5"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesUpgrade.UpgradeOrgJsiDevice(ctx, orgId, deviceMac, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesUpgradeTestListOrgMxEdgeUpgrades tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListOrgMxEdgeUpgrades(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.ListOrgMxEdgeUpgrades(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesUpgradeTestUpgradeOrgMxEdges tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeOrgMxEdges(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.MxedgeUpgradeMulti + errBody := json.Unmarshal([]byte(`{"channel":"stable","mxedge_ids":["387804a7-3474-85ce-15a2-f9a9684c9c90"],"versions":{"mxagent":"current","tunterm":"default"}}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesUpgrade.UpgradeOrgMxEdges(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesUpgradeTestGetOrgMxEdgeUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestGetOrgMxEdgeUpgrade(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.GetOrgMxEdgeUpgrade(ctx, orgId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesUpgradeTestListOrgSsrUpgrades tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListOrgSsrUpgrades(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.ListOrgSsrUpgrades(ctx, orgId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"channel":"stable","counts":{"failed":0,"queued":1,"success":0,"upgrading":1},"device_type":"gateway","id":"ceef2c8a-e2e6-447a-8b27-cb4f3ec1adae","status":"upgrading","strategy":"serial","versions":{}}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeOrgSsrs tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeOrgSsrs(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SsrUpgradeMulti + errBody := json.Unmarshal([]byte(`{"channel":"stable","device_ids":["00000000-0000-0000-1000-5c5b3500001f","00000000-0000-0000-1000-5c5b35000020"],"strategy":"big_bang","version":"5.3.0-93"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesUpgrade.UpgradeOrgSsrs(ctx, orgId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"channel":"stable","counts":{"failed":0,"queued":1,"success":0,"upgrading":1},"device_type":"gateway","id":"ceef2c8a-e2e6-447a-8b27-cb4f3ec1adae","status":"upgrading","strategy":"serial","versions":{}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestCancelOrgSsrUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestCancelOrgSsrUpgrade(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesUpgrade.CancelOrgSsrUpgrade(ctx, orgId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesUpgradeTestListOrgAvailableSsrVersions tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListOrgAvailableSsrVersions(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesUpgrade.ListOrgAvailableSsrVersions(ctx, orgId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"package":"128T-wheeljack","version":"128T-wheeljack-0.1.0-1212.x86_64"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestListSiteDeviceUpgrades tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListSiteDeviceUpgrades(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesUpgrade.ListSiteDeviceUpgrades(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"counts":{"download_requested":0,"downloaded":0,"failed":0,"reboot_in_progress":0,"rebooted":0,"skipped":0,"total":0},"enable_p2p":true,"force":true,"id":"472f6eca-6276-4993-bfeb-53cbbbba6f28","start_time":0,"status":"created","strategy":"big_bang","target_version":"string"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeSiteDevices tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeSiteDevices(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesUpgrade.UpgradeSiteDevices(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"upgrade_id":"4316c116-0acb-4c43-8f06-6723154e741e"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestGetSiteDeviceUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestGetSiteDeviceUpgrade(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.GetSiteDeviceUpgrade(ctx, siteId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"counts":{"downloaded":["5c5b355612ee"],"total":2,"upgraded":["5c5b3550bd2e"]},"enable_p2p":true,"force":true,"id":"473f6eca-6276-4993-bfeb-53cbbbba6f18","start_time":1717663165,"status":"created","strategy":"big_bang","target_version":"string"}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestCancelSiteDeviceUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestCancelSiteDeviceUpgrade(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesUpgrade.CancelSiteDeviceUpgrade(ctx, siteId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesUpgradeTestListSiteAvailableDeviceVersions tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestListSiteAvailableDeviceVersions(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + mType := models.DeviceTypeEnum("ap") + + apiResponse, err := utilitiesUpgrade.ListSiteAvailableDeviceVersions(ctx, siteId, &mType, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `[{"model":"AP41","tag":"stable","version":"v0.1.543"},{"model":"AP21","version":"v0.1.545"}]` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeDevice tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeDevice(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.DeviceUpgrade + errBody := json.Unmarshal([]byte(`{"version":"3.1.5"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesUpgrade.UpgradeDevice(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"status":"inprogress","timestamp":1428949501}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestGetSiteSsrUpgrade tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestGetSiteSsrUpgrade(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + upgradeId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesUpgrade.GetSiteSsrUpgrade(ctx, siteId, upgradeId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"channel":"stable","device_type":"gateway","id":"5cbcee0a-c620-4bb4-a25e-15000934e9d8","status":"upgrading","targets":{"failed":[],"queued":[],"success":[],"upgrading":["8e525f1d-4178-4ae1-a988-2b0176855e55"]},"versions":{}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} + +// TestUtilitiesUpgradeTestUpgradeSsr tests the behavior of the UtilitiesUpgrade +func TestUtilitiesUpgradeTestUpgradeSsr(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.SsrUpgrade + errBody := json.Unmarshal([]byte(`{"channel":"stable","version":"5.3.1-170-93"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesUpgrade.UpgradeSsr(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) + expected := `{"channel":"stable","counts":{"failed":0,"queued":1,"success":0,"upgrading":1},"device_type":"gateway","id":"ceef2c8a-e2e6-447a-8b27-cb4f3ec1adae","status":"upgrading","strategy":"serial","versions":{}}` + testHelper.KeysBodyMatcher(t, expected, apiResponse.Response.Body, false, false) +} diff --git a/mistapi/utilities_wan_test.go b/mistapi/utilities_wan_test.go new file mode 100644 index 00000000..efa4f36f --- /dev/null +++ b/mistapi/utilities_wan_test.go @@ -0,0 +1,232 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesWANTestClearSiteSsrArpCache tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestClearSiteSsrArpCache(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesWan.ClearSiteSsrArpCache(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestClearSiteSsrBgpRoutes tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestClearSiteSsrBgpRoutes(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsClearBgp + errBody := json.Unmarshal([]byte(`{"neighbor":"all","type":"in","vrf":"TestVrf"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesWan.ClearSiteSsrBgpRoutes(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestClearSiteDeviceSession tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestClearSiteDeviceSession(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsClearSession + errBody := json.Unmarshal([]byte(`{"port_id":"ge-0/0/1.10"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWan.ClearSiteDeviceSession(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWANTestReleaseSiteSsrDhcpLease tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestReleaseSiteSsrDhcpLease(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsReleaseDhcp + errBody := json.Unmarshal([]byte(`{"port_id":"ge-0/0/1.10"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWan.ReleaseSiteSsrDhcpLease(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWANTestTestSiteSsrDnsResolution tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestTestSiteSsrDnsResolution(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + apiResponse, err := utilitiesWan.TestSiteSsrDnsResolution(ctx, siteId, deviceId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestServicePingFromSsr tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestServicePingFromSsr(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsServicePing + errBody := json.Unmarshal([]byte(`{"count":10,"host":"1.1.1.1","service":"web-session"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesWan.ServicePingFromSsr(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestGetSiteSsrAndSrxRoutes tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestGetSiteSsrAndSrxRoutes(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + apiResponse, err := utilitiesWan.GetSiteSsrAndSrxRoutes(ctx, siteId, deviceId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestGetSiteSsrServicePath tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestGetSiteSsrServicePath(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsShowServicePath + errBody := json.Unmarshal([]byte(`{"node":"node0","service_name":"any"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesWan.GetSiteSsrServicePath(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} + +// TestUtilitiesWANTestGetSiteSsrAndSrxSessions tests the behavior of the UtilitiesWAN +func TestUtilitiesWANTestGetSiteSsrAndSrxSessions(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + deviceId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsShowSession + errBody := json.Unmarshal([]byte(`{"node":"node0","service_name":"any"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + apiResponse, err := utilitiesWan.GetSiteSsrAndSrxSessions(ctx, siteId, deviceId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, apiResponse.Response.StatusCode, 200) + expectedHeaders:= []testHelper.TestHeader{ + testHelper.NewTestHeader(true,"Content-Type","application/json"), + } + testHelper.CheckResponseHeaders(t, apiResponse.Response.Header, expectedHeaders, true) +} diff --git a/mistapi/utilities_wi_fi_test.go b/mistapi/utilities_wi_fi_test.go new file mode 100644 index 00000000..576a1871 --- /dev/null +++ b/mistapi/utilities_wi_fi_test.go @@ -0,0 +1,216 @@ +package mistapi + +import ( + "context" + "encoding/json" + "github.com/apimatic/go-core-runtime/testHelper" + "github.com/google/uuid" + "github.com/tmunzer/mistapi-go/mistapi/models" + "testing" +) + +// TestUtilitiesWiFiTestReauthOrgDot1xWirelessClient tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestReauthOrgDot1xWirelessClient(t *testing.T) { + ctx := context.Background() + orgId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + resp, err := utilitiesWiFi.ReauthOrgDot1xWirelessClient(ctx, orgId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestDisconnectSiteMultipleClients tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestDisconnectSiteMultipleClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesWiFi.DisconnectSiteMultipleClients(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestUnauthorizeSiteMultipleClients tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestUnauthorizeSiteMultipleClients(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + + resp, err := utilitiesWiFi.UnauthorizeSiteMultipleClients(ctx, siteId, nil) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestReauthSiteDot1xWirelessClient tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestReauthSiteDot1xWirelessClient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + resp, err := utilitiesWiFi.ReauthSiteDot1xWirelessClient(ctx, siteId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestDisconnectSiteWirelessClient tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestDisconnectSiteWirelessClient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + resp, err := utilitiesWiFi.DisconnectSiteWirelessClient(ctx, siteId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestUnauthorizeSiteWirelessClient tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestUnauthorizeSiteWirelessClient(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + clientMac := "0000000000ab" + resp, err := utilitiesWiFi.UnauthorizeSiteWirelessClient(ctx, siteId, clientMac) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestReprovisionSiteAllAps tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestReprovisionSiteAllAps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + resp, err := utilitiesWiFi.ReprovisionSiteAllAps(ctx, siteId) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestResetSiteAllApsToUseRrm tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestResetSiteAllApsToUseRrm(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsResetRadioConfig + errBody := json.Unmarshal([]byte(`{"bands":["24","5","6"],"force":false}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWiFi.ResetSiteAllApsToUseRrm(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestZeroizeSiteFipsAllAps tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestZeroizeSiteFipsAllAps(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsZeroiseFips + errBody := json.Unmarshal([]byte(`{"password":"NUKETHESITE"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWiFi.ZeroizeSiteFipsAllAps(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestDeauthSiteWirelessClientsConnectedToARogue tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestDeauthSiteWirelessClientsConnectedToARogue(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + rogueBssid := "0000000000ab" + resp, err := utilitiesWiFi.DeauthSiteWirelessClientsConnectedToARogue(ctx, siteId, rogueBssid) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestOptimizeSiteRrm tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestOptimizeSiteRrm(t *testing.T) { + ctx := context.Background() + siteId, errUUID := uuid.Parse("000000ab-00ab-00ab-00ab-0000000000ab") + if errUUID != nil { + t.Error(errUUID) + } + var body models.UtilsRrmOptimize + errBody := json.Unmarshal([]byte(`{"bands":["24","5","6"]}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWiFi.OptimizeSiteRrm(ctx, siteId, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestTestSiteWlanTelstraSetup tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestTestSiteWlanTelstraSetup(t *testing.T) { + ctx := context.Background() + var body models.TestTelstra + errBody := json.Unmarshal([]byte(`{"telstra_client_id":"123456","telstra_client_secret":"abcdef","to":"+911122334455"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWiFi.TestSiteWlanTelstraSetup(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +} + +// TestUtilitiesWiFiTestTestSiteWlanTwilioSetup tests the behavior of the UtilitiesWiFi +func TestUtilitiesWiFiTestTestSiteWlanTwilioSetup(t *testing.T) { + ctx := context.Background() + var body models.TestTwilio + errBody := json.Unmarshal([]byte(`{"from":"+185051234567","to":"+19999999999","twilio_auth_token":"2135be04736a1a0a314bce432d61721a","twilio_sid":"AC5f4366878d193fb4865ab151739999eb"}`), &body) + if errBody != nil { + t.Errorf("Cannot parse the model object.") + } + resp, err := utilitiesWiFi.TestSiteWlanTwilioSetup(ctx, &body) + if err != nil { + t.Errorf("Endpoint call failed: %v", err) + } + testHelper.CheckResponseStatusCode(t, resp.StatusCode, 200) +}