diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2ac6f6fe..11ee27d7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,5 +41,4 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: - fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4de..fb38ec23 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -27,3 +27,6 @@ linter: # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options +analyzer: + errors: + invalid_annotation_target: ignore \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index ae5e639c..458ed352 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -22,3 +22,27 @@ services: environment: TZ: 'Asia/Tokyo' FTLCONF_webserver_api_password: 'test123' + + piholeV52: + container_name: piholeV52 + image: pihole/pihole:latest + ports: + - "56:53/tcp" + - "56:53/udp" + - "8082:80/tcp" + - "1446:443/tcp" + environment: + TZ: 'Asia/Tokyo' + WEBPASSWORD: 'test456' + + piholeV62: + container_name: piholeV62 + image: pihole/pihole:development + ports: + - "57:53/tcp" + - "57:53/udp" + - "8083:80/tcp" + - "1447:443/tcp" + environment: + TZ: 'Asia/Tokyo' + FTLCONF_webserver_api_password: 'test456' \ No newline at end of file diff --git a/lib/constants/log_status.dart b/lib/constants/log_status.dart deleted file mode 100644 index 0ebc5830..00000000 --- a/lib/constants/log_status.dart +++ /dev/null @@ -1,17 +0,0 @@ -const List logStatusString = [ - "Blocked (gravity)", - "OK (forwarded)", - "OK (cache)", - "Blocked (regex blacklist)", - "Blocked (exact blacklist)", - "Blocked (external, IP)", - "Blocked (external, NULL)", - "Blocked (external, NXRA)", - "Blocked (gravity, CNAME)", - "Blocked (regex blacklist, CNAME)", - "Blocked (exact blacklist, CNAME)", - "Retried", - "Retried (ignored)", - "OK (already forwarded)", - "Database is busy" -]; diff --git a/lib/constants/query_types.dart b/lib/constants/query_types.dart new file mode 100644 index 00000000..2d72a978 --- /dev/null +++ b/lib/constants/query_types.dart @@ -0,0 +1,252 @@ +import 'package:flutter/material.dart'; +import 'package:pi_hole_client/models/query_status.dart'; + +final List queryStatusesV5 = [ + QueryStatus( + index: 1, + key: "1", + text: "Blocked (gravity)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 2, + key: "2", + text: "OK (forwarded)", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 3, + key: "3", + text: "OK (cache)", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 4, + key: "4", + text: "Blocked (regex blacklist)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 5, + key: "5", + text: "Blocked (exact blacklist)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 6, + key: "6", + text: "Blocked (external, IP)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 7, + key: "7", + text: "Blocked (external, NULL)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 8, + key: "8", + text: "Blocked (external, NXRA)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 9, + key: "9", + text: "Blocked (gravity, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 10, + key: "10", + text: "Blocked (regex blacklist, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 11, + key: "11", + text: "Blocked (exact blacklist, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 12, + key: "12", + text: "Retried", + color: Colors.blue, + icon: Icons.refresh_rounded, + ), + QueryStatus( + index: 13, + key: "13", + text: "Retried (ignored)", + color: Colors.blue, + icon: Icons.refresh_rounded, + ), + QueryStatus( + index: 14, + key: "14", + text: "OK (already forwarded)", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 15, + key: "15", + text: "Database is busy", + color: Colors.orange, + icon: Icons.storage_rounded, + isShown: false, + ), +]; + +final List queryStatusesV6 = [ + QueryStatus( + index: 1, + key: "UNKNOWN", + text: "UNKNOWN", + color: Colors.grey, + icon: Icons.question_mark_rounded, + isShown: false, + ), + QueryStatus( + index: 2, + key: "GRAVITY", + text: "Blocked (gravity)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 3, + key: "FORWARDED", + text: "Forwarded", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 4, + key: "CACHE", + text: "Served from cache", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 5, + key: "REGEX", + text: "Blocked (regex)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 6, + key: "DENYLIST", + text: "Blocked (exact)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 7, + key: "EXTERNAL_BLOCKED_IP", + text: "Blocked (external, IP)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 8, + key: "EXTERNAL_BLOCKED_NULL", + text: "Blocked (external, NULL)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 9, + key: "EXTERNAL_BLOCKED_NXRA", + text: "Blocked (external, NXRA)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 10, + key: "GRAVITY_CNAME", + text: "Blocked (gravity, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 11, + key: "REGEX_CNAME", + text: "Blocked (regex denied, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 12, + key: "DENYLIST_CNAME", + text: "Blocked (exact denied, CNAME)", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + ), + QueryStatus( + index: 13, + key: "RETRIED", + text: "Retried", + color: Colors.blue, + icon: Icons.refresh_rounded, + ), + QueryStatus( + index: 14, + key: "RETRIED_DNSSEC", + text: "Retried (ignored)", + color: Colors.blue, + icon: Icons.refresh_rounded, + ), + QueryStatus( + index: 15, + key: "IN_PROGRESS", + text: "Already forwarded, awaiting reply", + color: Colors.green, + icon: Icons.verified_user_rounded, + ), + QueryStatus( + index: 16, + key: "DBBUSY", + text: "DBBUSY", + color: Colors.orange, + icon: Icons.storage_rounded, + isShown: false, + ), + QueryStatus( + index: 17, + key: "SPECIAL_DOMAIN", + text: "SPECIAL_DOMAIN", + color: Colors.red, + icon: Icons.gpp_bad_rounded, + isShown: false, + ), + QueryStatus( + index: 18, + key: "CACHE_STALE", + text: "Served by cache optimizer", + color: Colors.blue, + icon: Icons.cached_rounded, + isShown: false, + ), + QueryStatus( + index: 19, + key: "EXTERNAL_BLOCKED_EDE15", + text: "EXTERNAL_BLOCKED_EDE15", + color: Colors.orange, + icon: Icons.question_mark_rounded, + isShown: false, + ), +]; diff --git a/lib/gateways/api_gateway_factory.dart b/lib/gateways/api_gateway_factory.dart index 4daade91..96d21415 100644 --- a/lib/gateways/api_gateway_factory.dart +++ b/lib/gateways/api_gateway_factory.dart @@ -1,6 +1,6 @@ import 'package:pi_hole_client/gateways/api_gateway_interface.dart'; import 'package:pi_hole_client/gateways/v5/api_gateway_v5.dart'; -// import 'package:pi_hole_client/gateways/v5/api_gateway_v6.dart'; +import 'package:pi_hole_client/gateways/v6/api_gateway_v6.dart'; import 'package:pi_hole_client/models/server.dart'; class ApiGatewayFactory { @@ -9,8 +9,7 @@ class ApiGatewayFactory { if (version == 'v5') { return ApiGatewayV5(server); } else if (version == 'v6') { - // return ApiGatewayV6(server); - throw Exception('Not implemented yet'); + return ApiGatewayV6(server); } else { throw Exception('Unsupported server version: $version'); } diff --git a/lib/gateways/v5/api_gateway_v5.dart b/lib/gateways/v5/api_gateway_v5.dart index 32a1e67e..83ed5a61 100644 --- a/lib/gateways/v5/api_gateway_v5.dart +++ b/lib/gateways/v5/api_gateway_v5.dart @@ -152,13 +152,13 @@ class ApiGatewayV5 implements ApiGateway { } else { final enableOrDisableParsed = jsonDecode(enableOrDisable.body); if (enableOrDisableParsed.runtimeType != List) { - final phpSessId = enableOrDisable.headers['set-cookie']! + final sid = enableOrDisable.headers['set-cookie']! .split(';')[0] .split('=')[1]; return LoginQueryResponse( result: APiResponseType.success, status: statusParsed['status'], - phpSessId: phpSessId); + sid: sid); } else { return LoginQueryResponse( result: APiResponseType.authError, diff --git a/lib/gateways/v6/api_gateway_v6.dart b/lib/gateways/v6/api_gateway_v6.dart new file mode 100644 index 00000000..fdb24ff9 --- /dev/null +++ b/lib/gateways/v6/api_gateway_v6.dart @@ -0,0 +1,662 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'package:http/http.dart'; +import 'package:http/http.dart' as http; +import 'package:pi_hole_client/functions/logger.dart'; +import 'package:pi_hole_client/models/api/v6/auth/auth.dart' show Session; +import 'package:pi_hole_client/models/api/v6/dns/dns.dart' show Blocking; +import 'package:pi_hole_client/models/api/v6/flt/ftl.dart' show InfoFtl; +import 'package:pi_hole_client/models/api/v6/metrics/stats.dart' + show StatsSummary, StatsTopDomains, StatsTopClients, StatsUpstreams; +import 'package:pi_hole_client/models/api/v6/metrics/history.dart' + show History, HistoryClients; +import 'package:pi_hole_client/models/api/v6/domains/domains.dart' + show AddDomains, Domains; +import 'package:pi_hole_client/models/api/v6/metrics/query.dart' show Queries; +import 'package:pi_hole_client/models/app_log.dart'; +import 'package:pi_hole_client/models/domain.dart'; +import 'package:pi_hole_client/models/gateways.dart'; +import 'package:pi_hole_client/models/log.dart'; +import 'package:pi_hole_client/models/overtime_data.dart'; +import 'package:pi_hole_client/models/realtime_status.dart'; +import 'package:pi_hole_client/models/server.dart'; +import 'package:pi_hole_client/gateways/api_gateway_interface.dart'; + +class ApiGatewayV6 implements ApiGateway { + final Server server; + final http.Client client; + + /// Creates a new instance of the `ApiGatewayV5` class. + /// + /// Parameters: + /// - `server` (`Server`): The server object containing the Pi-hole address, token, and optional basic authentication credentials. + /// - `client` (`http.Client`): An optional HTTP client to use for requests. If not provided, a new client will be created. Add for testing purposes. + ApiGatewayV6(this.server, {http.Client? client}) + : client = client ?? http.Client(); + + /// Sends an HTTP request using the specified method and parameters. + /// + /// This method sends an HTTP request to the specified URL using the provided + /// method, headers, and body. It also handles authentication using the API key + /// if provided. If the request fails due to a 401 response, it will retry the + /// request once after re-authenticating with the server. + /// + /// Parameters: + /// - [method] The HTTP method to use (e.g., 'GET', 'POST'). + /// - [url] The URL to send the request to. + /// - [headers] The headers to send with the request. + /// - [body] The body of the request. + /// - [timeout] The timeout for the request in seconds. Default is 10 seconds. + /// - [maxRetries] The number of times to retry the request if a 401 response is received. Default is 1. + /// + /// Returns + /// - A `Response` object containing the response from the server. + /// + /// Exceptions: + /// - Throws an exception if the request fails or times out. + Future httpClient({ + required String method, + required String url, + Map? headers, + Map? body, + int timeout = 10, + int maxRetries = 1, + }) async { + if (server.sm.sid == null) { + await server.sm.load(); + } + final Map authHeaders = headers != null ? {...headers} : {}; + authHeaders['Content-Type'] = 'application/json'; + if (server.sm.sid != null && server.sm.sid!.isNotEmpty) { + authHeaders['X-FTL-SID'] = server.sm.sid!; + } + + for (int attempt = 0; attempt <= maxRetries; attempt++) { + final response = await _sendRequest( + method: method, + url: url, + headers: authHeaders, + body: body, + timeout: timeout, + ); + + if (response.statusCode == 401) { + if (attempt >= maxRetries) { + return response; + } + + await loginQuery(); + continue; + } + + return response; + } + + throw Exception("Failed to execute HTTP request"); + } + + Future _sendRequest({ + required String method, + required String url, + required Map headers, + Map? body, + required int timeout, + }) async { + switch (method.toUpperCase()) { + case 'POST': + return await client + .post(Uri.parse(url), + headers: headers, body: body != null ? jsonEncode(body) : null) + .timeout(Duration(seconds: timeout)); + + case 'PUT': + return await client + .put(Uri.parse(url), + headers: headers, body: body != null ? jsonEncode(body) : null) + .timeout(Duration(seconds: timeout)); + + case 'PATCH': + return await client + .patch(Uri.parse(url), + headers: headers, body: body != null ? jsonEncode(body) : null) + .timeout(Duration(seconds: timeout)); + + case 'DELETE': + return await client + .delete(Uri.parse(url), headers: headers) + .timeout(Duration(seconds: timeout)); + + case 'GET': + default: + return await client + .get(Uri.parse(url), headers: headers) + .timeout(Duration(seconds: timeout)); + } + } + + /// Handles the login process to a Pi-hole server using its API. + @override + Future loginQuery() async { + try { + // 1. Get DNS blocking status + // If the session ID is already available, use it to get the status + // Otherwise, re-login to get the session ID + final enableOrDisable = await httpClient( + method: 'get', + url: '${server.address}/api/dns/blocking', + maxRetries: 0); + if (enableOrDisable.statusCode == 200) { + logger.i('Reusing session ID login'); + final enableOrDisableParsed = + Blocking.fromJson(jsonDecode(enableOrDisable.body)); + return LoginQueryResponse( + result: APiResponseType.success, + status: enableOrDisableParsed.blocking, + sid: server.sm.sid); + } + + if (server.sm.sid == null || server.sm.sid!.isEmpty) { + logger.i('No session ID available, logging in'); + } else { + logger.i('Session ID is expired or deleted, logging in'); + } + + // 2.login + final status = await httpClient( + method: 'post', + url: '${server.address}/api/auth', + body: {'password': await server.sm.password}, + maxRetries: 0, + ); + + if (status.statusCode == 200) { + final statusParsed = Session.fromJson(jsonDecode(status.body)); + await server.sm.save(statusParsed.session.sid); + + // 3. Get DNS blocking status + final enableOrDisable = await httpClient( + method: 'get', url: '${server.address}/api/dns/blocking'); + if (enableOrDisable.statusCode == 200) { + final enableOrDisableParsed = + Blocking.fromJson(jsonDecode(enableOrDisable.body)); + return LoginQueryResponse( + result: APiResponseType.success, + status: enableOrDisableParsed.blocking, + sid: statusParsed.session.sid); + } else { + return LoginQueryResponse( + result: APiResponseType.authError, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + statusCode: status.statusCode.toString(), + message: 'auth_error_1', + resBody: status.body)); + } + } else if (status.statusCode == 404) { + return LoginQueryResponse( + result: APiResponseType.noConnection, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + statusCode: status.statusCode.toString(), + message: 'no_connection_2', + resBody: status.body)); + } else { + return LoginQueryResponse( + result: APiResponseType.authError, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + statusCode: status.statusCode.toString(), + message: 'auth_error', + resBody: status.body)); + } + } on SocketException { + return LoginQueryResponse( + result: APiResponseType.socket, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + message: 'SocketException')); + } on TimeoutException { + return LoginQueryResponse( + result: APiResponseType.timeout, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + message: 'TimeoutException')); + } on HandshakeException { + return LoginQueryResponse( + result: APiResponseType.sslError, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + message: 'HandshakeException')); + } on FormatException { + return LoginQueryResponse( + result: APiResponseType.authError, + log: AppLog( + type: 'login', + dateTime: DateTime.now(), + message: 'FormatException')); + } catch (e) { + return LoginQueryResponse( + result: APiResponseType.error, + log: AppLog( + type: 'login', dateTime: DateTime.now(), message: e.toString())); + } + } + + /// Fetches real-time status information from a Pi-hole server. + /// + /// This method sends a GET request to the specified Pi-hole server to retrieve + /// detailed status and metrics, including top items, forward destinations, + /// query sources, and query types. It parses the response and returns the + /// data in a structured format. + @override + Future realtimeStatus() async { + try { + final response = await Future.wait([ + httpClient( + method: 'get', + url: '${server.address}/api/stats/summary', + ), + httpClient( + method: 'get', + url: '${server.address}/api/info/ftl', + ), + httpClient( + method: 'get', + url: '${server.address}/api/dns/blocking', + ), + httpClient( + method: 'get', + url: '${server.address}/api/stats/top_domains', + ), + httpClient( + method: 'get', + url: '${server.address}/api/stats/top_domains?blocked=true', + ), + httpClient( + method: 'get', + url: '${server.address}/api/stats/top_clients', + ), + httpClient( + method: 'get', + url: '${server.address}/api/stats/top_clients?blocked=true', + ), + httpClient( + method: 'get', + url: '${server.address}/api/stats/upstreams', + ), + ]); + if (response[0].statusCode == 200 && + response[1].statusCode == 200 && + response[2].statusCode == 200 && + response[3].statusCode == 200 && + response[4].statusCode == 200 && + response[5].statusCode == 200 && + response[6].statusCode == 200 && + response[7].statusCode == 200) { + final summary = StatsSummary.fromJson(jsonDecode(response[0].body)); + final infoFtl = InfoFtl.fromJson(jsonDecode(response[1].body)); + final blocking = Blocking.fromJson(jsonDecode(response[2].body)); + final topPermittedDomains = + StatsTopDomains.fromJson(jsonDecode(response[3].body)); + final topBlockedDomains = + StatsTopDomains.fromJson(jsonDecode(response[4].body)); + final topClients = + StatsTopClients.fromJson(jsonDecode(response[5].body)); + final topBlockedClients = + StatsTopClients.fromJson(jsonDecode(response[6].body)); + final upstreams = StatsUpstreams.fromJson(jsonDecode(response[7].body)); + + return RealtimeStatusResponse( + result: APiResponseType.success, + data: RealtimeStatus.fromV6( + summary, + infoFtl, + blocking, + topPermittedDomains, + topBlockedDomains, + topClients, + topBlockedClients, + upstreams)); + } else { + return RealtimeStatusResponse(result: APiResponseType.error); + } + } on SocketException { + return RealtimeStatusResponse(result: APiResponseType.socket); + } on TimeoutException { + return RealtimeStatusResponse(result: APiResponseType.timeout); + } on HandshakeException { + return RealtimeStatusResponse(result: APiResponseType.sslError); + } catch (e) { + return RealtimeStatusResponse(result: APiResponseType.error); + } + } + + /// Disables a Pi-hole server + /// + /// This method sends a GET request to the specified Pi-hole server to disable + @override + Future disableServerRequest(int time) async { + try { + final response = await httpClient( + method: 'post', + url: '${server.address}/api/dns/blocking', + body: {'blocking': false, 'timer': time}, + ); + if (response.statusCode == 200) { + final body = Blocking.fromJson(jsonDecode(response.body)); + return DisableServerResponse( + result: APiResponseType.success, status: body.blocking); + } else { + return DisableServerResponse(result: APiResponseType.error); + } + } on SocketException { + return DisableServerResponse(result: APiResponseType.noConnection); + } on TimeoutException { + return DisableServerResponse(result: APiResponseType.noConnection); + } on HandshakeException { + return DisableServerResponse(result: APiResponseType.sslError); + } catch (e) { + return DisableServerResponse(result: APiResponseType.error); + } + } + + /// Enables a Pi-hole server + /// + /// This method sends a GET request to the specified Pi-hole server to enable + @override + Future enableServerRequest() async { + try { + final response = await httpClient( + method: 'post', + url: '${server.address}/api/dns/blocking', + body: {'blocking': true, 'timer': null}, + ); + if (response.statusCode == 200) { + final body = Blocking.fromJson(jsonDecode(response.body)); + return EnableServerResponse( + result: APiResponseType.success, status: body.blocking); + } else { + return EnableServerResponse(result: APiResponseType.error); + } + } on SocketException { + return EnableServerResponse(result: APiResponseType.noConnection); + } on TimeoutException { + return EnableServerResponse(result: APiResponseType.noConnection); + } on HandshakeException { + return EnableServerResponse(result: APiResponseType.sslError); + } catch (e) { + return EnableServerResponse(result: APiResponseType.error); + } + } + + /// Fetches over-time data from a Pi-hole server. + /// + /// This method retrieves various over-time data points from the specified + /// Pi-hole server, including queries over time (in 10-minute intervals), client + /// activity, and client names. The data is parsed and returned in a structured format. + @override + Future fetchOverTimeData() async { + try { + final response = await Future.wait([ + httpClient( + method: 'get', + url: '${server.address}/api/history', + ), + httpClient( + method: 'get', + url: '${server.address}/api/history/clients', + ), + ]); + + if (response[0].statusCode == 200 && response[1].statusCode == 200) { + final history = History.fromJson(jsonDecode(response[0].body)); + final historyClients = + HistoryClients.fromJson(jsonDecode(response[1].body)); + return FetchOverTimeDataResponse( + result: APiResponseType.success, + data: OverTimeData.fromV6(history, historyClients)); + } else { + return FetchOverTimeDataResponse(result: APiResponseType.error); + } + } on SocketException { + return FetchOverTimeDataResponse(result: APiResponseType.socket); + } on TimeoutException { + return FetchOverTimeDataResponse(result: APiResponseType.timeout); + } on HandshakeException { + return FetchOverTimeDataResponse(result: APiResponseType.sslError); + } catch (e) { + return FetchOverTimeDataResponse(result: APiResponseType.error); + } + } + + /// Fetches log data from a Pi-hole server within a specified time range. + /// + /// This method retrieves query logs from the given Pi-hole server for a + /// specified time period. The logs are returned in a structured format + /// for further analysis or display. + @override + Future fetchLogs(DateTime from, DateTime until) async { + try { + final response = await httpClient( + method: 'get', + url: + '${server.address}/api/queries?from=${from.millisecondsSinceEpoch ~/ 1000}&until=${until.millisecondsSinceEpoch ~/ 1000}', + timeout: 20, + ); + if (response.statusCode == 200) { + final queries = Queries.fromJson(jsonDecode(response.body)); + logger.d('Queries: ${queries.queries.map((e) => e.toJson()).toList()}'); + return FetchLogsResponse( + result: APiResponseType.success, + data: queries.queries.map((query) => Log.fromV6(query)).toList()); + } else { + return FetchLogsResponse(result: APiResponseType.error); + } + } on FormatException { + return FetchLogsResponse(result: APiResponseType.authError); + } on SocketException { + return FetchLogsResponse(result: APiResponseType.socket); + } on TimeoutException { + return FetchLogsResponse(result: APiResponseType.timeout); + } on HandshakeException { + return FetchLogsResponse(result: APiResponseType.sslError); + } catch (e) { + return FetchLogsResponse(result: APiResponseType.error); + } + } + + /// Adds a domain to the whitelist or blacklist on a Pi-hole server. + /// + /// This method interacts with the Pi-hole server's API to add the specified domain + /// to either the whitelist or the blacklist, depending on the provided `list` parameter. + /// It validates the server's response to confirm the operation's success. + @override + Future setWhiteBlacklist( + String domain, String list) async { + try { + final types = { + 'white': ['allow', 'exact'], + 'black': ['deny', 'exact'], + 'regex_white': ['allow', 'regex'], + 'regex_black': ['deny', 'regex'] + }; + final response = await httpClient( + method: 'post', + url: + '${server.address}/api/domains/${types[list]?[0]}/${types[list]?[1]}', + body: { + "domain": domain, + "comment": null, + "groups": [0], // Array of group IDs + "enabled": true + }); + if (response.statusCode == 201) { + final domains = AddDomains.fromJson(jsonDecode(response.body)); + return SetWhiteBlacklistResponse( + result: APiResponseType.success, + data: DomainResult.fromV6(domains)); + } else { + return SetWhiteBlacklistResponse(result: APiResponseType.error); + } + } on SocketException { + return SetWhiteBlacklistResponse(result: APiResponseType.socket); + } on TimeoutException { + return SetWhiteBlacklistResponse(result: APiResponseType.timeout); + } on HandshakeException { + return SetWhiteBlacklistResponse(result: APiResponseType.sslError); + } catch (e) { + return SetWhiteBlacklistResponse(result: APiResponseType.error); + } + } + + /// Fetches domain lists (whitelist, blacklist, and regex-based lists) from a Pi-hole server. + /// + /// This method retrieves the whitelist, regex whitelist, blacklist, and regex blacklist + /// from the specified Pi-hole server. Each list is processed and returned in a structured format. + @override + Future getDomainLists() async { + try { + final results = await httpClient( + method: 'get', + url: '${server.address}/api/domains', + ); + + if (results.statusCode == 200) { + final domains = Domains.fromJson(jsonDecode(results.body)); + + return GetDomainLists( + result: APiResponseType.success, + data: DomainListResult.fromV6(domains)); + } else { + return GetDomainLists(result: APiResponseType.error); + } + } on SocketException { + return GetDomainLists(result: APiResponseType.socket); + } on TimeoutException { + return GetDomainLists(result: APiResponseType.timeout); + } on HandshakeException { + return GetDomainLists(result: APiResponseType.sslError); + } on FormatException { + return GetDomainLists(result: APiResponseType.authError); + } catch (e) { + return GetDomainLists(result: APiResponseType.error); + } + } + + /// Removes a domain from a specific list on a Pi-hole server. + /// + /// This method interacts with the Pi-hole server's API to remove the specified domain + /// from the given list, which can be one of the following: whitelist, blacklist, + /// regex whitelist, or regex blacklist. The operation's success or failure is determined + /// by the server's response. + @override + Future removeDomainFromList( + Domain domain) async { + List getType(int type) { + switch (type) { + case 0: + return ['allow', 'exact']; + + case 1: + return ['deny', 'exact']; + + case 2: + return ['allow', 'regex']; + + case 3: + return ['deny', 'regex']; + + default: + return ['', '']; + } + } + + try { + final response = await httpClient( + method: 'delete', + url: + '${server.address}/api/domains/${getType(domain.type)[0]}/${getType(domain.type)[1]}/${domain.domain}', + ); + if (response.statusCode == 204) { + return RemoveDomainFromListResponse(result: APiResponseType.success); + } else if (response.statusCode == 404) { + return RemoveDomainFromListResponse( + result: APiResponseType.error, message: 'not_exists'); + } else { + return RemoveDomainFromListResponse(result: APiResponseType.error); + } + } on SocketException { + return RemoveDomainFromListResponse(result: APiResponseType.noConnection); + } on TimeoutException { + return RemoveDomainFromListResponse(result: APiResponseType.noConnection); + } on HandshakeException { + return RemoveDomainFromListResponse(result: APiResponseType.sslError); + } catch (e) { + return RemoveDomainFromListResponse(result: APiResponseType.error); + } + } + + /// Adds a domain to a specified list on a Pi-hole server. + /// + /// This method interacts with the Pi-hole server's API to add a domain to a specified list, + /// such as the whitelist, blacklist, regex whitelist, or regex blacklist. It checks the server's + /// response to determine whether the operation was successful or if the domain already exists + /// in the list. + @override + Future addDomainToList( + Map domainData) async { + try { + final types = { + 'white': ['allow', 'exact'], + 'black': ['deny', 'exact'], + 'regex_white': ['allow', 'regex'], + 'regex_black': ['deny', 'regex'] + }; + final response = await httpClient( + method: 'post', + url: + '${server.address}/api/domains/${types[domainData['list']]?[0]}/${types[domainData['list']]?[1]}', + body: { + "domain": domainData['domain'], + "comment": null, + "groups": [0], // Array of group IDs + "enabled": true + }); + if (response.statusCode == 201) { + final domains = AddDomains.fromJson(jsonDecode(response.body)); + + if (domains.domains.length != 1) { + return AddDomainToListResponse(result: APiResponseType.error); + } + + if (domains.processed.success.isNotEmpty) { + return AddDomainToListResponse(result: APiResponseType.success); + } + + if (domains.processed.errors.isNotEmpty && + domains.processed.errors[0].error + .contains('UNIQUE constraint failed:')) { + return AddDomainToListResponse(result: APiResponseType.alreadyAdded); + } + return AddDomainToListResponse(result: APiResponseType.error); + } else { + return AddDomainToListResponse(result: APiResponseType.error); + } + } on SocketException { + return AddDomainToListResponse(result: APiResponseType.socket); + } on TimeoutException { + return AddDomainToListResponse(result: APiResponseType.timeout); + } on HandshakeException { + return AddDomainToListResponse(result: APiResponseType.sslError); + } catch (e) { + return AddDomainToListResponse(result: APiResponseType.error); + } + } +} diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index dbeefb7a..38c53567 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -124,6 +124,7 @@ "dontCheckCertificate": "SSL Zertifikat nicht überprüfen", "dontCheckCertificateDescription": "Überschreibt die SSL-Zertifikatsvalidierung des Servers", "edit": "Bearbeiten", + "editConnection": "Verbindung bearbeiten", "editServer": "Verbindung bearbeiten", "enable": "Aktivieren", "enabled": "Aktiviert", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 8cad10fa..29948a82 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -124,6 +124,7 @@ "dontCheckCertificate": "Don't check SSL certificate", "dontCheckCertificateDescription": "Overrides the server's SSL certificate validation", "edit": "Edit", + "editConnection": "Edit a Connection", "editServer": "Edit server connection", "enable": "Enable", "enabled": "Enabled", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 7237c868..9164ce26 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -126,6 +126,7 @@ "dontCheckCertificate": "No comprobar el certificado SSL", "dontCheckCertificateDescription": "Anula la validación del certificado SSL del servidor", "edit": "Editar", + "editConnection": "Editar una conexión", "editServer": "Editar conexión", "enable": "Activar", "enabled": "Activado", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 033916b2..0012bd70 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -124,6 +124,7 @@ "dontCheckCertificate": "SSL証明書を確認しない", "dontCheckCertificateDescription": "サーバーのSSL証明書の検証を無効にします", "edit": "編集", + "editConnection": "接続を編集", "editServer": "サーバー接続を編集", "enable": "有効化", "enabled": "有効", diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index bcad2de8..ab58f12a 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -124,6 +124,7 @@ "dontCheckCertificate": "Nie sprawdzaj certyfikatu SSL", "dontCheckCertificateDescription": "Zastępuje sprawdzanie poprawności certyfikatu SSL serwera", "edit": "Edytuj", + "editConnection": "Edytuj połączenie", "editServer": "Edytowanie połączenia z serwerem", "enable": "Włączyć", "enabled": "Włączone", diff --git a/lib/main.dart b/lib/main.dart index beb8e1f0..b160e6e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,7 +58,8 @@ void main() async { ServersProvider serversProvider = ServersProvider(dbRepository); AppConfigProvider configProvider = AppConfigProvider(dbRepository); StatusProvider statusProvider = StatusProvider(); - FiltersProvider filtersProvider = FiltersProvider(); + FiltersProvider filtersProvider = + FiltersProvider(serversProvider: serversProvider); DomainsListProvider domainsListProvider = DomainsListProvider(serversProvider: serversProvider); @@ -117,7 +118,11 @@ void main() async { providers: [ ChangeNotifierProvider(create: ((context) => serversProvider)), ChangeNotifierProvider(create: ((context) => statusProvider)), - ChangeNotifierProvider(create: ((context) => filtersProvider)), + ChangeNotifierProxyProvider( + create: (context) => filtersProvider, + update: (context, serverConfig, servers) => + servers!..update(serverConfig), + ), ChangeNotifierProxyProvider( create: (context) => domainsListProvider, update: (context, serverConfig, servers) => diff --git a/lib/models/api/v6/auth/auth.dart b/lib/models/api/v6/auth/auth.dart new file mode 100644 index 00000000..70951b39 --- /dev/null +++ b/lib/models/api/v6/auth/auth.dart @@ -0,0 +1,40 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'auth.freezed.dart'; +part 'auth.g.dart'; + +@freezed +class Password with _$Password { + factory Password({ + required String password, + }) = _Password; + + factory Password.fromJson(Map json) => + _$PasswordFromJson(json); +} + +@freezed +class Session with _$Session { + factory Session({ + required SessionDetail session, + required double took, + }) = _Session; + + factory Session.fromJson(Map json) => + _$SessionFromJson(json); +} + +@freezed +class SessionDetail with _$SessionDetail { + factory SessionDetail({ + required bool valid, + required bool totp, + required String sid, + required String csrf, + required int validity, + required String message, + }) = _SessionDetail; + + factory SessionDetail.fromJson(Map json) => + _$SessionDetailFromJson(json); +} diff --git a/lib/models/api/v6/auth/auth.freezed.dart b/lib/models/api/v6/auth/auth.freezed.dart new file mode 100644 index 00000000..d493c52d --- /dev/null +++ b/lib/models/api/v6/auth/auth.freezed.dart @@ -0,0 +1,597 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'auth.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Password _$PasswordFromJson(Map json) { + return _Password.fromJson(json); +} + +/// @nodoc +mixin _$Password { + String get password => throw _privateConstructorUsedError; + + /// Serializes this Password to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Password + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PasswordCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PasswordCopyWith<$Res> { + factory $PasswordCopyWith(Password value, $Res Function(Password) then) = + _$PasswordCopyWithImpl<$Res, Password>; + @useResult + $Res call({String password}); +} + +/// @nodoc +class _$PasswordCopyWithImpl<$Res, $Val extends Password> + implements $PasswordCopyWith<$Res> { + _$PasswordCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Password + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? password = null, + }) { + return _then(_value.copyWith( + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PasswordImplCopyWith<$Res> + implements $PasswordCopyWith<$Res> { + factory _$$PasswordImplCopyWith( + _$PasswordImpl value, $Res Function(_$PasswordImpl) then) = + __$$PasswordImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String password}); +} + +/// @nodoc +class __$$PasswordImplCopyWithImpl<$Res> + extends _$PasswordCopyWithImpl<$Res, _$PasswordImpl> + implements _$$PasswordImplCopyWith<$Res> { + __$$PasswordImplCopyWithImpl( + _$PasswordImpl _value, $Res Function(_$PasswordImpl) _then) + : super(_value, _then); + + /// Create a copy of Password + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? password = null, + }) { + return _then(_$PasswordImpl( + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PasswordImpl implements _Password { + _$PasswordImpl({required this.password}); + + factory _$PasswordImpl.fromJson(Map json) => + _$$PasswordImplFromJson(json); + + @override + final String password; + + @override + String toString() { + return 'Password(password: $password)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PasswordImpl && + (identical(other.password, password) || + other.password == password)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, password); + + /// Create a copy of Password + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PasswordImplCopyWith<_$PasswordImpl> get copyWith => + __$$PasswordImplCopyWithImpl<_$PasswordImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PasswordImplToJson( + this, + ); + } +} + +abstract class _Password implements Password { + factory _Password({required final String password}) = _$PasswordImpl; + + factory _Password.fromJson(Map json) = + _$PasswordImpl.fromJson; + + @override + String get password; + + /// Create a copy of Password + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PasswordImplCopyWith<_$PasswordImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Session _$SessionFromJson(Map json) { + return _Session.fromJson(json); +} + +/// @nodoc +mixin _$Session { + SessionDetail get session => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this Session to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SessionCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SessionCopyWith<$Res> { + factory $SessionCopyWith(Session value, $Res Function(Session) then) = + _$SessionCopyWithImpl<$Res, Session>; + @useResult + $Res call({SessionDetail session, double took}); + + $SessionDetailCopyWith<$Res> get session; +} + +/// @nodoc +class _$SessionCopyWithImpl<$Res, $Val extends Session> + implements $SessionCopyWith<$Res> { + _$SessionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? session = null, + Object? took = null, + }) { + return _then(_value.copyWith( + session: null == session + ? _value.session + : session // ignore: cast_nullable_to_non_nullable + as SessionDetail, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SessionDetailCopyWith<$Res> get session { + return $SessionDetailCopyWith<$Res>(_value.session, (value) { + return _then(_value.copyWith(session: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$SessionImplCopyWith<$Res> implements $SessionCopyWith<$Res> { + factory _$$SessionImplCopyWith( + _$SessionImpl value, $Res Function(_$SessionImpl) then) = + __$$SessionImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({SessionDetail session, double took}); + + @override + $SessionDetailCopyWith<$Res> get session; +} + +/// @nodoc +class __$$SessionImplCopyWithImpl<$Res> + extends _$SessionCopyWithImpl<$Res, _$SessionImpl> + implements _$$SessionImplCopyWith<$Res> { + __$$SessionImplCopyWithImpl( + _$SessionImpl _value, $Res Function(_$SessionImpl) _then) + : super(_value, _then); + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? session = null, + Object? took = null, + }) { + return _then(_$SessionImpl( + session: null == session + ? _value.session + : session // ignore: cast_nullable_to_non_nullable + as SessionDetail, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$SessionImpl implements _Session { + _$SessionImpl({required this.session, required this.took}); + + factory _$SessionImpl.fromJson(Map json) => + _$$SessionImplFromJson(json); + + @override + final SessionDetail session; + @override + final double took; + + @override + String toString() { + return 'Session(session: $session, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SessionImpl && + (identical(other.session, session) || other.session == session) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, session, took); + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SessionImplCopyWith<_$SessionImpl> get copyWith => + __$$SessionImplCopyWithImpl<_$SessionImpl>(this, _$identity); + + @override + Map toJson() { + return _$$SessionImplToJson( + this, + ); + } +} + +abstract class _Session implements Session { + factory _Session( + {required final SessionDetail session, + required final double took}) = _$SessionImpl; + + factory _Session.fromJson(Map json) = _$SessionImpl.fromJson; + + @override + SessionDetail get session; + @override + double get took; + + /// Create a copy of Session + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SessionImplCopyWith<_$SessionImpl> get copyWith => + throw _privateConstructorUsedError; +} + +SessionDetail _$SessionDetailFromJson(Map json) { + return _SessionDetail.fromJson(json); +} + +/// @nodoc +mixin _$SessionDetail { + bool get valid => throw _privateConstructorUsedError; + bool get totp => throw _privateConstructorUsedError; + String get sid => throw _privateConstructorUsedError; + String get csrf => throw _privateConstructorUsedError; + int get validity => throw _privateConstructorUsedError; + String get message => throw _privateConstructorUsedError; + + /// Serializes this SessionDetail to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of SessionDetail + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SessionDetailCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SessionDetailCopyWith<$Res> { + factory $SessionDetailCopyWith( + SessionDetail value, $Res Function(SessionDetail) then) = + _$SessionDetailCopyWithImpl<$Res, SessionDetail>; + @useResult + $Res call( + {bool valid, + bool totp, + String sid, + String csrf, + int validity, + String message}); +} + +/// @nodoc +class _$SessionDetailCopyWithImpl<$Res, $Val extends SessionDetail> + implements $SessionDetailCopyWith<$Res> { + _$SessionDetailCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SessionDetail + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? valid = null, + Object? totp = null, + Object? sid = null, + Object? csrf = null, + Object? validity = null, + Object? message = null, + }) { + return _then(_value.copyWith( + valid: null == valid + ? _value.valid + : valid // ignore: cast_nullable_to_non_nullable + as bool, + totp: null == totp + ? _value.totp + : totp // ignore: cast_nullable_to_non_nullable + as bool, + sid: null == sid + ? _value.sid + : sid // ignore: cast_nullable_to_non_nullable + as String, + csrf: null == csrf + ? _value.csrf + : csrf // ignore: cast_nullable_to_non_nullable + as String, + validity: null == validity + ? _value.validity + : validity // ignore: cast_nullable_to_non_nullable + as int, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$SessionDetailImplCopyWith<$Res> + implements $SessionDetailCopyWith<$Res> { + factory _$$SessionDetailImplCopyWith( + _$SessionDetailImpl value, $Res Function(_$SessionDetailImpl) then) = + __$$SessionDetailImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool valid, + bool totp, + String sid, + String csrf, + int validity, + String message}); +} + +/// @nodoc +class __$$SessionDetailImplCopyWithImpl<$Res> + extends _$SessionDetailCopyWithImpl<$Res, _$SessionDetailImpl> + implements _$$SessionDetailImplCopyWith<$Res> { + __$$SessionDetailImplCopyWithImpl( + _$SessionDetailImpl _value, $Res Function(_$SessionDetailImpl) _then) + : super(_value, _then); + + /// Create a copy of SessionDetail + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? valid = null, + Object? totp = null, + Object? sid = null, + Object? csrf = null, + Object? validity = null, + Object? message = null, + }) { + return _then(_$SessionDetailImpl( + valid: null == valid + ? _value.valid + : valid // ignore: cast_nullable_to_non_nullable + as bool, + totp: null == totp + ? _value.totp + : totp // ignore: cast_nullable_to_non_nullable + as bool, + sid: null == sid + ? _value.sid + : sid // ignore: cast_nullable_to_non_nullable + as String, + csrf: null == csrf + ? _value.csrf + : csrf // ignore: cast_nullable_to_non_nullable + as String, + validity: null == validity + ? _value.validity + : validity // ignore: cast_nullable_to_non_nullable + as int, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$SessionDetailImpl implements _SessionDetail { + _$SessionDetailImpl( + {required this.valid, + required this.totp, + required this.sid, + required this.csrf, + required this.validity, + required this.message}); + + factory _$SessionDetailImpl.fromJson(Map json) => + _$$SessionDetailImplFromJson(json); + + @override + final bool valid; + @override + final bool totp; + @override + final String sid; + @override + final String csrf; + @override + final int validity; + @override + final String message; + + @override + String toString() { + return 'SessionDetail(valid: $valid, totp: $totp, sid: $sid, csrf: $csrf, validity: $validity, message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SessionDetailImpl && + (identical(other.valid, valid) || other.valid == valid) && + (identical(other.totp, totp) || other.totp == totp) && + (identical(other.sid, sid) || other.sid == sid) && + (identical(other.csrf, csrf) || other.csrf == csrf) && + (identical(other.validity, validity) || + other.validity == validity) && + (identical(other.message, message) || other.message == message)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, valid, totp, sid, csrf, validity, message); + + /// Create a copy of SessionDetail + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SessionDetailImplCopyWith<_$SessionDetailImpl> get copyWith => + __$$SessionDetailImplCopyWithImpl<_$SessionDetailImpl>(this, _$identity); + + @override + Map toJson() { + return _$$SessionDetailImplToJson( + this, + ); + } +} + +abstract class _SessionDetail implements SessionDetail { + factory _SessionDetail( + {required final bool valid, + required final bool totp, + required final String sid, + required final String csrf, + required final int validity, + required final String message}) = _$SessionDetailImpl; + + factory _SessionDetail.fromJson(Map json) = + _$SessionDetailImpl.fromJson; + + @override + bool get valid; + @override + bool get totp; + @override + String get sid; + @override + String get csrf; + @override + int get validity; + @override + String get message; + + /// Create a copy of SessionDetail + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SessionDetailImplCopyWith<_$SessionDetailImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/auth/auth.g.dart b/lib/models/api/v6/auth/auth.g.dart new file mode 100644 index 00000000..099f1c03 --- /dev/null +++ b/lib/models/api/v6/auth/auth.g.dart @@ -0,0 +1,49 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'auth.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$PasswordImpl _$$PasswordImplFromJson(Map json) => + _$PasswordImpl( + password: json['password'] as String, + ); + +Map _$$PasswordImplToJson(_$PasswordImpl instance) => + { + 'password': instance.password, + }; + +_$SessionImpl _$$SessionImplFromJson(Map json) => + _$SessionImpl( + session: SessionDetail.fromJson(json['session'] as Map), + took: (json['took'] as num).toDouble(), + ); + +Map _$$SessionImplToJson(_$SessionImpl instance) => + { + 'session': instance.session, + 'took': instance.took, + }; + +_$SessionDetailImpl _$$SessionDetailImplFromJson(Map json) => + _$SessionDetailImpl( + valid: json['valid'] as bool, + totp: json['totp'] as bool, + sid: json['sid'] as String, + csrf: json['csrf'] as String, + validity: (json['validity'] as num).toInt(), + message: json['message'] as String, + ); + +Map _$$SessionDetailImplToJson(_$SessionDetailImpl instance) => + { + 'valid': instance.valid, + 'totp': instance.totp, + 'sid': instance.sid, + 'csrf': instance.csrf, + 'validity': instance.validity, + 'message': instance.message, + }; diff --git a/lib/models/api/v6/dns/dns.dart b/lib/models/api/v6/dns/dns.dart new file mode 100644 index 00000000..83d98976 --- /dev/null +++ b/lib/models/api/v6/dns/dns.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'dns.freezed.dart'; +part 'dns.g.dart'; + +@freezed +class Blocking with _$Blocking { + factory Blocking({ + required String blocking, + required int? timer, + required double took, + }) = _Blocking; + + factory Blocking.fromJson(Map json) => + _$BlockingFromJson(json); +} diff --git a/lib/models/api/v6/dns/dns.freezed.dart b/lib/models/api/v6/dns/dns.freezed.dart new file mode 100644 index 00000000..0a4c7a6c --- /dev/null +++ b/lib/models/api/v6/dns/dns.freezed.dart @@ -0,0 +1,200 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'dns.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Blocking _$BlockingFromJson(Map json) { + return _Blocking.fromJson(json); +} + +/// @nodoc +mixin _$Blocking { + String get blocking => throw _privateConstructorUsedError; + int? get timer => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this Blocking to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Blocking + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $BlockingCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $BlockingCopyWith<$Res> { + factory $BlockingCopyWith(Blocking value, $Res Function(Blocking) then) = + _$BlockingCopyWithImpl<$Res, Blocking>; + @useResult + $Res call({String blocking, int? timer, double took}); +} + +/// @nodoc +class _$BlockingCopyWithImpl<$Res, $Val extends Blocking> + implements $BlockingCopyWith<$Res> { + _$BlockingCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Blocking + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? blocking = null, + Object? timer = freezed, + Object? took = null, + }) { + return _then(_value.copyWith( + blocking: null == blocking + ? _value.blocking + : blocking // ignore: cast_nullable_to_non_nullable + as String, + timer: freezed == timer + ? _value.timer + : timer // ignore: cast_nullable_to_non_nullable + as int?, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$BlockingImplCopyWith<$Res> + implements $BlockingCopyWith<$Res> { + factory _$$BlockingImplCopyWith( + _$BlockingImpl value, $Res Function(_$BlockingImpl) then) = + __$$BlockingImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String blocking, int? timer, double took}); +} + +/// @nodoc +class __$$BlockingImplCopyWithImpl<$Res> + extends _$BlockingCopyWithImpl<$Res, _$BlockingImpl> + implements _$$BlockingImplCopyWith<$Res> { + __$$BlockingImplCopyWithImpl( + _$BlockingImpl _value, $Res Function(_$BlockingImpl) _then) + : super(_value, _then); + + /// Create a copy of Blocking + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? blocking = null, + Object? timer = freezed, + Object? took = null, + }) { + return _then(_$BlockingImpl( + blocking: null == blocking + ? _value.blocking + : blocking // ignore: cast_nullable_to_non_nullable + as String, + timer: freezed == timer + ? _value.timer + : timer // ignore: cast_nullable_to_non_nullable + as int?, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$BlockingImpl implements _Blocking { + _$BlockingImpl( + {required this.blocking, required this.timer, required this.took}); + + factory _$BlockingImpl.fromJson(Map json) => + _$$BlockingImplFromJson(json); + + @override + final String blocking; + @override + final int? timer; + @override + final double took; + + @override + String toString() { + return 'Blocking(blocking: $blocking, timer: $timer, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BlockingImpl && + (identical(other.blocking, blocking) || + other.blocking == blocking) && + (identical(other.timer, timer) || other.timer == timer) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, blocking, timer, took); + + /// Create a copy of Blocking + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$BlockingImplCopyWith<_$BlockingImpl> get copyWith => + __$$BlockingImplCopyWithImpl<_$BlockingImpl>(this, _$identity); + + @override + Map toJson() { + return _$$BlockingImplToJson( + this, + ); + } +} + +abstract class _Blocking implements Blocking { + factory _Blocking( + {required final String blocking, + required final int? timer, + required final double took}) = _$BlockingImpl; + + factory _Blocking.fromJson(Map json) = + _$BlockingImpl.fromJson; + + @override + String get blocking; + @override + int? get timer; + @override + double get took; + + /// Create a copy of Blocking + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$BlockingImplCopyWith<_$BlockingImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/dns/dns.g.dart b/lib/models/api/v6/dns/dns.g.dart new file mode 100644 index 00000000..d00b2810 --- /dev/null +++ b/lib/models/api/v6/dns/dns.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'dns.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$BlockingImpl _$$BlockingImplFromJson(Map json) => + _$BlockingImpl( + blocking: json['blocking'] as String, + timer: (json['timer'] as num?)?.toInt(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$BlockingImplToJson(_$BlockingImpl instance) => + { + 'blocking': instance.blocking, + 'timer': instance.timer, + 'took': instance.took, + }; diff --git a/lib/models/api/v6/domains/domains.dart b/lib/models/api/v6/domains/domains.dart new file mode 100644 index 00000000..09eae539 --- /dev/null +++ b/lib/models/api/v6/domains/domains.dart @@ -0,0 +1,77 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'domains.freezed.dart'; +part 'domains.g.dart'; + +@freezed +class Domains with _$Domains { + const factory Domains({ + required List domains, + required double took, // Time in seconds + }) = _Domains; + + factory Domains.fromJson(Map json) => + _$DomainsFromJson(json); +} + +@freezed +class AddDomains with _$AddDomains { + const factory AddDomains({ + required List domains, + required Processed processed, + required double took, // Time in seconds + }) = _AddDomains; + + factory AddDomains.fromJson(Map json) => + _$AddDomainsFromJson(json); +} + +@freezed +class Domain with _$Domain { + const factory Domain({ + required String domain, // Domain + required String unicode, // Unicode domain + required String type, // Domain type (allow | deny) + required String kind, // Domain kind (exact | regex) + required String? comment, // Optional user-provided comment + required List groups, // Array of group IDs + required bool enabled, // Status of domain (default true) + required int id, // Database ID + @JsonKey(name: 'date_added') required int dateAdded, + @JsonKey(name: 'date_modified') required int dateModified, + }) = _Domain; + + factory Domain.fromJson(Map json) => _$DomainFromJson(json); +} + +@freezed +class Processed with _$Processed { + const factory Processed({ + required List success, + required List errors, + }) = _Processed; + + factory Processed.fromJson(Map json) => + _$ProcessedFromJson(json); +} + +@freezed +class ProcessedItem with _$ProcessedItem { + const factory ProcessedItem({ + required String item, + }) = _ProcessedItem; + + factory ProcessedItem.fromJson(Map json) => + _$ProcessedItemFromJson(json); +} + +@freezed +class ProcessedError with _$ProcessedError { + const factory ProcessedError({ + required String item, + required String error, + }) = _ProcessedError; + + factory ProcessedError.fromJson(Map json) => + _$ProcessedErrorFromJson(json); +} diff --git a/lib/models/api/v6/domains/domains.freezed.dart b/lib/models/api/v6/domains/domains.freezed.dart new file mode 100644 index 00000000..791fd949 --- /dev/null +++ b/lib/models/api/v6/domains/domains.freezed.dart @@ -0,0 +1,1269 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'domains.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Domains _$DomainsFromJson(Map json) { + return _Domains.fromJson(json); +} + +/// @nodoc +mixin _$Domains { + List get domains => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this Domains to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DomainsCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DomainsCopyWith<$Res> { + factory $DomainsCopyWith(Domains value, $Res Function(Domains) then) = + _$DomainsCopyWithImpl<$Res, Domains>; + @useResult + $Res call({List domains, double took}); +} + +/// @nodoc +class _$DomainsCopyWithImpl<$Res, $Val extends Domains> + implements $DomainsCopyWith<$Res> { + _$DomainsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? took = null, + }) { + return _then(_value.copyWith( + domains: null == domains + ? _value.domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DomainsImplCopyWith<$Res> implements $DomainsCopyWith<$Res> { + factory _$$DomainsImplCopyWith( + _$DomainsImpl value, $Res Function(_$DomainsImpl) then) = + __$$DomainsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List domains, double took}); +} + +/// @nodoc +class __$$DomainsImplCopyWithImpl<$Res> + extends _$DomainsCopyWithImpl<$Res, _$DomainsImpl> + implements _$$DomainsImplCopyWith<$Res> { + __$$DomainsImplCopyWithImpl( + _$DomainsImpl _value, $Res Function(_$DomainsImpl) _then) + : super(_value, _then); + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? took = null, + }) { + return _then(_$DomainsImpl( + domains: null == domains + ? _value._domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DomainsImpl implements _Domains { + const _$DomainsImpl({required final List domains, required this.took}) + : _domains = domains; + + factory _$DomainsImpl.fromJson(Map json) => + _$$DomainsImplFromJson(json); + + final List _domains; + @override + List get domains { + if (_domains is EqualUnmodifiableListView) return _domains; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_domains); + } + + @override + final double took; + + @override + String toString() { + return 'Domains(domains: $domains, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DomainsImpl && + const DeepCollectionEquality().equals(other._domains, _domains) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_domains), took); + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DomainsImplCopyWith<_$DomainsImpl> get copyWith => + __$$DomainsImplCopyWithImpl<_$DomainsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DomainsImplToJson( + this, + ); + } +} + +abstract class _Domains implements Domains { + const factory _Domains( + {required final List domains, + required final double took}) = _$DomainsImpl; + + factory _Domains.fromJson(Map json) = _$DomainsImpl.fromJson; + + @override + List get domains; + @override + double get took; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DomainsImplCopyWith<_$DomainsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +AddDomains _$AddDomainsFromJson(Map json) { + return _AddDomains.fromJson(json); +} + +/// @nodoc +mixin _$AddDomains { + List get domains => throw _privateConstructorUsedError; + Processed get processed => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this AddDomains to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $AddDomainsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AddDomainsCopyWith<$Res> { + factory $AddDomainsCopyWith( + AddDomains value, $Res Function(AddDomains) then) = + _$AddDomainsCopyWithImpl<$Res, AddDomains>; + @useResult + $Res call({List domains, Processed processed, double took}); + + $ProcessedCopyWith<$Res> get processed; +} + +/// @nodoc +class _$AddDomainsCopyWithImpl<$Res, $Val extends AddDomains> + implements $AddDomainsCopyWith<$Res> { + _$AddDomainsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? processed = null, + Object? took = null, + }) { + return _then(_value.copyWith( + domains: null == domains + ? _value.domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + processed: null == processed + ? _value.processed + : processed // ignore: cast_nullable_to_non_nullable + as Processed, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProcessedCopyWith<$Res> get processed { + return $ProcessedCopyWith<$Res>(_value.processed, (value) { + return _then(_value.copyWith(processed: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$AddDomainsImplCopyWith<$Res> + implements $AddDomainsCopyWith<$Res> { + factory _$$AddDomainsImplCopyWith( + _$AddDomainsImpl value, $Res Function(_$AddDomainsImpl) then) = + __$$AddDomainsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List domains, Processed processed, double took}); + + @override + $ProcessedCopyWith<$Res> get processed; +} + +/// @nodoc +class __$$AddDomainsImplCopyWithImpl<$Res> + extends _$AddDomainsCopyWithImpl<$Res, _$AddDomainsImpl> + implements _$$AddDomainsImplCopyWith<$Res> { + __$$AddDomainsImplCopyWithImpl( + _$AddDomainsImpl _value, $Res Function(_$AddDomainsImpl) _then) + : super(_value, _then); + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? processed = null, + Object? took = null, + }) { + return _then(_$AddDomainsImpl( + domains: null == domains + ? _value._domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + processed: null == processed + ? _value.processed + : processed // ignore: cast_nullable_to_non_nullable + as Processed, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$AddDomainsImpl implements _AddDomains { + const _$AddDomainsImpl( + {required final List domains, + required this.processed, + required this.took}) + : _domains = domains; + + factory _$AddDomainsImpl.fromJson(Map json) => + _$$AddDomainsImplFromJson(json); + + final List _domains; + @override + List get domains { + if (_domains is EqualUnmodifiableListView) return _domains; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_domains); + } + + @override + final Processed processed; + @override + final double took; + + @override + String toString() { + return 'AddDomains(domains: $domains, processed: $processed, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddDomainsImpl && + const DeepCollectionEquality().equals(other._domains, _domains) && + (identical(other.processed, processed) || + other.processed == processed) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_domains), processed, took); + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddDomainsImplCopyWith<_$AddDomainsImpl> get copyWith => + __$$AddDomainsImplCopyWithImpl<_$AddDomainsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$AddDomainsImplToJson( + this, + ); + } +} + +abstract class _AddDomains implements AddDomains { + const factory _AddDomains( + {required final List domains, + required final Processed processed, + required final double took}) = _$AddDomainsImpl; + + factory _AddDomains.fromJson(Map json) = + _$AddDomainsImpl.fromJson; + + @override + List get domains; + @override + Processed get processed; + @override + double get took; + + /// Create a copy of AddDomains + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddDomainsImplCopyWith<_$AddDomainsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Domain _$DomainFromJson(Map json) { + return _Domain.fromJson(json); +} + +/// @nodoc +mixin _$Domain { + String get domain => throw _privateConstructorUsedError; // Domain + String get unicode => throw _privateConstructorUsedError; // Unicode domain + String get type => + throw _privateConstructorUsedError; // Domain type (allow | deny) + String get kind => + throw _privateConstructorUsedError; // Domain kind (exact | regex) + String? get comment => + throw _privateConstructorUsedError; // Optional user-provided comment + List get groups => + throw _privateConstructorUsedError; // Array of group IDs + bool get enabled => + throw _privateConstructorUsedError; // Status of domain (default true) + int get id => throw _privateConstructorUsedError; // Database ID + @JsonKey(name: 'date_added') + int get dateAdded => throw _privateConstructorUsedError; + @JsonKey(name: 'date_modified') + int get dateModified => throw _privateConstructorUsedError; + + /// Serializes this Domain to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DomainCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DomainCopyWith<$Res> { + factory $DomainCopyWith(Domain value, $Res Function(Domain) then) = + _$DomainCopyWithImpl<$Res, Domain>; + @useResult + $Res call( + {String domain, + String unicode, + String type, + String kind, + String? comment, + List groups, + bool enabled, + int id, + @JsonKey(name: 'date_added') int dateAdded, + @JsonKey(name: 'date_modified') int dateModified}); +} + +/// @nodoc +class _$DomainCopyWithImpl<$Res, $Val extends Domain> + implements $DomainCopyWith<$Res> { + _$DomainCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? unicode = null, + Object? type = null, + Object? kind = null, + Object? comment = freezed, + Object? groups = null, + Object? enabled = null, + Object? id = null, + Object? dateAdded = null, + Object? dateModified = null, + }) { + return _then(_value.copyWith( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + unicode: null == unicode + ? _value.unicode + : unicode // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + comment: freezed == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String?, + groups: null == groups + ? _value.groups + : groups // ignore: cast_nullable_to_non_nullable + as List, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + dateAdded: null == dateAdded + ? _value.dateAdded + : dateAdded // ignore: cast_nullable_to_non_nullable + as int, + dateModified: null == dateModified + ? _value.dateModified + : dateModified // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DomainImplCopyWith<$Res> implements $DomainCopyWith<$Res> { + factory _$$DomainImplCopyWith( + _$DomainImpl value, $Res Function(_$DomainImpl) then) = + __$$DomainImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String domain, + String unicode, + String type, + String kind, + String? comment, + List groups, + bool enabled, + int id, + @JsonKey(name: 'date_added') int dateAdded, + @JsonKey(name: 'date_modified') int dateModified}); +} + +/// @nodoc +class __$$DomainImplCopyWithImpl<$Res> + extends _$DomainCopyWithImpl<$Res, _$DomainImpl> + implements _$$DomainImplCopyWith<$Res> { + __$$DomainImplCopyWithImpl( + _$DomainImpl _value, $Res Function(_$DomainImpl) _then) + : super(_value, _then); + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? unicode = null, + Object? type = null, + Object? kind = null, + Object? comment = freezed, + Object? groups = null, + Object? enabled = null, + Object? id = null, + Object? dateAdded = null, + Object? dateModified = null, + }) { + return _then(_$DomainImpl( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + unicode: null == unicode + ? _value.unicode + : unicode // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + kind: null == kind + ? _value.kind + : kind // ignore: cast_nullable_to_non_nullable + as String, + comment: freezed == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String?, + groups: null == groups + ? _value._groups + : groups // ignore: cast_nullable_to_non_nullable + as List, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + dateAdded: null == dateAdded + ? _value.dateAdded + : dateAdded // ignore: cast_nullable_to_non_nullable + as int, + dateModified: null == dateModified + ? _value.dateModified + : dateModified // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DomainImpl implements _Domain { + const _$DomainImpl( + {required this.domain, + required this.unicode, + required this.type, + required this.kind, + required this.comment, + required final List groups, + required this.enabled, + required this.id, + @JsonKey(name: 'date_added') required this.dateAdded, + @JsonKey(name: 'date_modified') required this.dateModified}) + : _groups = groups; + + factory _$DomainImpl.fromJson(Map json) => + _$$DomainImplFromJson(json); + + @override + final String domain; +// Domain + @override + final String unicode; +// Unicode domain + @override + final String type; +// Domain type (allow | deny) + @override + final String kind; +// Domain kind (exact | regex) + @override + final String? comment; +// Optional user-provided comment + final List _groups; +// Optional user-provided comment + @override + List get groups { + if (_groups is EqualUnmodifiableListView) return _groups; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_groups); + } + +// Array of group IDs + @override + final bool enabled; +// Status of domain (default true) + @override + final int id; +// Database ID + @override + @JsonKey(name: 'date_added') + final int dateAdded; + @override + @JsonKey(name: 'date_modified') + final int dateModified; + + @override + String toString() { + return 'Domain(domain: $domain, unicode: $unicode, type: $type, kind: $kind, comment: $comment, groups: $groups, enabled: $enabled, id: $id, dateAdded: $dateAdded, dateModified: $dateModified)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DomainImpl && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.unicode, unicode) || other.unicode == unicode) && + (identical(other.type, type) || other.type == type) && + (identical(other.kind, kind) || other.kind == kind) && + (identical(other.comment, comment) || other.comment == comment) && + const DeepCollectionEquality().equals(other._groups, _groups) && + (identical(other.enabled, enabled) || other.enabled == enabled) && + (identical(other.id, id) || other.id == id) && + (identical(other.dateAdded, dateAdded) || + other.dateAdded == dateAdded) && + (identical(other.dateModified, dateModified) || + other.dateModified == dateModified)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + domain, + unicode, + type, + kind, + comment, + const DeepCollectionEquality().hash(_groups), + enabled, + id, + dateAdded, + dateModified); + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DomainImplCopyWith<_$DomainImpl> get copyWith => + __$$DomainImplCopyWithImpl<_$DomainImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DomainImplToJson( + this, + ); + } +} + +abstract class _Domain implements Domain { + const factory _Domain( + {required final String domain, + required final String unicode, + required final String type, + required final String kind, + required final String? comment, + required final List groups, + required final bool enabled, + required final int id, + @JsonKey(name: 'date_added') required final int dateAdded, + @JsonKey(name: 'date_modified') required final int dateModified}) = + _$DomainImpl; + + factory _Domain.fromJson(Map json) = _$DomainImpl.fromJson; + + @override + String get domain; // Domain + @override + String get unicode; // Unicode domain + @override + String get type; // Domain type (allow | deny) + @override + String get kind; // Domain kind (exact | regex) + @override + String? get comment; // Optional user-provided comment + @override + List get groups; // Array of group IDs + @override + bool get enabled; // Status of domain (default true) + @override + int get id; // Database ID + @override + @JsonKey(name: 'date_added') + int get dateAdded; + @override + @JsonKey(name: 'date_modified') + int get dateModified; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DomainImplCopyWith<_$DomainImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Processed _$ProcessedFromJson(Map json) { + return _Processed.fromJson(json); +} + +/// @nodoc +mixin _$Processed { + List get success => throw _privateConstructorUsedError; + List get errors => throw _privateConstructorUsedError; + + /// Serializes this Processed to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Processed + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProcessedCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProcessedCopyWith<$Res> { + factory $ProcessedCopyWith(Processed value, $Res Function(Processed) then) = + _$ProcessedCopyWithImpl<$Res, Processed>; + @useResult + $Res call({List success, List errors}); +} + +/// @nodoc +class _$ProcessedCopyWithImpl<$Res, $Val extends Processed> + implements $ProcessedCopyWith<$Res> { + _$ProcessedCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Processed + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? success = null, + Object? errors = null, + }) { + return _then(_value.copyWith( + success: null == success + ? _value.success + : success // ignore: cast_nullable_to_non_nullable + as List, + errors: null == errors + ? _value.errors + : errors // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProcessedImplCopyWith<$Res> + implements $ProcessedCopyWith<$Res> { + factory _$$ProcessedImplCopyWith( + _$ProcessedImpl value, $Res Function(_$ProcessedImpl) then) = + __$$ProcessedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List success, List errors}); +} + +/// @nodoc +class __$$ProcessedImplCopyWithImpl<$Res> + extends _$ProcessedCopyWithImpl<$Res, _$ProcessedImpl> + implements _$$ProcessedImplCopyWith<$Res> { + __$$ProcessedImplCopyWithImpl( + _$ProcessedImpl _value, $Res Function(_$ProcessedImpl) _then) + : super(_value, _then); + + /// Create a copy of Processed + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? success = null, + Object? errors = null, + }) { + return _then(_$ProcessedImpl( + success: null == success + ? _value._success + : success // ignore: cast_nullable_to_non_nullable + as List, + errors: null == errors + ? _value._errors + : errors // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ProcessedImpl implements _Processed { + const _$ProcessedImpl( + {required final List success, + required final List errors}) + : _success = success, + _errors = errors; + + factory _$ProcessedImpl.fromJson(Map json) => + _$$ProcessedImplFromJson(json); + + final List _success; + @override + List get success { + if (_success is EqualUnmodifiableListView) return _success; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_success); + } + + final List _errors; + @override + List get errors { + if (_errors is EqualUnmodifiableListView) return _errors; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_errors); + } + + @override + String toString() { + return 'Processed(success: $success, errors: $errors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProcessedImpl && + const DeepCollectionEquality().equals(other._success, _success) && + const DeepCollectionEquality().equals(other._errors, _errors)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_success), + const DeepCollectionEquality().hash(_errors)); + + /// Create a copy of Processed + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProcessedImplCopyWith<_$ProcessedImpl> get copyWith => + __$$ProcessedImplCopyWithImpl<_$ProcessedImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ProcessedImplToJson( + this, + ); + } +} + +abstract class _Processed implements Processed { + const factory _Processed( + {required final List success, + required final List errors}) = _$ProcessedImpl; + + factory _Processed.fromJson(Map json) = + _$ProcessedImpl.fromJson; + + @override + List get success; + @override + List get errors; + + /// Create a copy of Processed + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProcessedImplCopyWith<_$ProcessedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +ProcessedItem _$ProcessedItemFromJson(Map json) { + return _ProcessedItem.fromJson(json); +} + +/// @nodoc +mixin _$ProcessedItem { + String get item => throw _privateConstructorUsedError; + + /// Serializes this ProcessedItem to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ProcessedItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProcessedItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProcessedItemCopyWith<$Res> { + factory $ProcessedItemCopyWith( + ProcessedItem value, $Res Function(ProcessedItem) then) = + _$ProcessedItemCopyWithImpl<$Res, ProcessedItem>; + @useResult + $Res call({String item}); +} + +/// @nodoc +class _$ProcessedItemCopyWithImpl<$Res, $Val extends ProcessedItem> + implements $ProcessedItemCopyWith<$Res> { + _$ProcessedItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ProcessedItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? item = null, + }) { + return _then(_value.copyWith( + item: null == item + ? _value.item + : item // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProcessedItemImplCopyWith<$Res> + implements $ProcessedItemCopyWith<$Res> { + factory _$$ProcessedItemImplCopyWith( + _$ProcessedItemImpl value, $Res Function(_$ProcessedItemImpl) then) = + __$$ProcessedItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String item}); +} + +/// @nodoc +class __$$ProcessedItemImplCopyWithImpl<$Res> + extends _$ProcessedItemCopyWithImpl<$Res, _$ProcessedItemImpl> + implements _$$ProcessedItemImplCopyWith<$Res> { + __$$ProcessedItemImplCopyWithImpl( + _$ProcessedItemImpl _value, $Res Function(_$ProcessedItemImpl) _then) + : super(_value, _then); + + /// Create a copy of ProcessedItem + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? item = null, + }) { + return _then(_$ProcessedItemImpl( + item: null == item + ? _value.item + : item // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ProcessedItemImpl implements _ProcessedItem { + const _$ProcessedItemImpl({required this.item}); + + factory _$ProcessedItemImpl.fromJson(Map json) => + _$$ProcessedItemImplFromJson(json); + + @override + final String item; + + @override + String toString() { + return 'ProcessedItem(item: $item)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProcessedItemImpl && + (identical(other.item, item) || other.item == item)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, item); + + /// Create a copy of ProcessedItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProcessedItemImplCopyWith<_$ProcessedItemImpl> get copyWith => + __$$ProcessedItemImplCopyWithImpl<_$ProcessedItemImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ProcessedItemImplToJson( + this, + ); + } +} + +abstract class _ProcessedItem implements ProcessedItem { + const factory _ProcessedItem({required final String item}) = + _$ProcessedItemImpl; + + factory _ProcessedItem.fromJson(Map json) = + _$ProcessedItemImpl.fromJson; + + @override + String get item; + + /// Create a copy of ProcessedItem + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProcessedItemImplCopyWith<_$ProcessedItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +ProcessedError _$ProcessedErrorFromJson(Map json) { + return _ProcessedError.fromJson(json); +} + +/// @nodoc +mixin _$ProcessedError { + String get item => throw _privateConstructorUsedError; + String get error => throw _privateConstructorUsedError; + + /// Serializes this ProcessedError to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ProcessedError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProcessedErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProcessedErrorCopyWith<$Res> { + factory $ProcessedErrorCopyWith( + ProcessedError value, $Res Function(ProcessedError) then) = + _$ProcessedErrorCopyWithImpl<$Res, ProcessedError>; + @useResult + $Res call({String item, String error}); +} + +/// @nodoc +class _$ProcessedErrorCopyWithImpl<$Res, $Val extends ProcessedError> + implements $ProcessedErrorCopyWith<$Res> { + _$ProcessedErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ProcessedError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? item = null, + Object? error = null, + }) { + return _then(_value.copyWith( + item: null == item + ? _value.item + : item // ignore: cast_nullable_to_non_nullable + as String, + error: null == error + ? _value.error + : error // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProcessedErrorImplCopyWith<$Res> + implements $ProcessedErrorCopyWith<$Res> { + factory _$$ProcessedErrorImplCopyWith(_$ProcessedErrorImpl value, + $Res Function(_$ProcessedErrorImpl) then) = + __$$ProcessedErrorImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String item, String error}); +} + +/// @nodoc +class __$$ProcessedErrorImplCopyWithImpl<$Res> + extends _$ProcessedErrorCopyWithImpl<$Res, _$ProcessedErrorImpl> + implements _$$ProcessedErrorImplCopyWith<$Res> { + __$$ProcessedErrorImplCopyWithImpl( + _$ProcessedErrorImpl _value, $Res Function(_$ProcessedErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of ProcessedError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? item = null, + Object? error = null, + }) { + return _then(_$ProcessedErrorImpl( + item: null == item + ? _value.item + : item // ignore: cast_nullable_to_non_nullable + as String, + error: null == error + ? _value.error + : error // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ProcessedErrorImpl implements _ProcessedError { + const _$ProcessedErrorImpl({required this.item, required this.error}); + + factory _$ProcessedErrorImpl.fromJson(Map json) => + _$$ProcessedErrorImplFromJson(json); + + @override + final String item; + @override + final String error; + + @override + String toString() { + return 'ProcessedError(item: $item, error: $error)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProcessedErrorImpl && + (identical(other.item, item) || other.item == item) && + (identical(other.error, error) || other.error == error)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, item, error); + + /// Create a copy of ProcessedError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProcessedErrorImplCopyWith<_$ProcessedErrorImpl> get copyWith => + __$$ProcessedErrorImplCopyWithImpl<_$ProcessedErrorImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$ProcessedErrorImplToJson( + this, + ); + } +} + +abstract class _ProcessedError implements ProcessedError { + const factory _ProcessedError( + {required final String item, + required final String error}) = _$ProcessedErrorImpl; + + factory _ProcessedError.fromJson(Map json) = + _$ProcessedErrorImpl.fromJson; + + @override + String get item; + @override + String get error; + + /// Create a copy of ProcessedError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProcessedErrorImplCopyWith<_$ProcessedErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/domains/domains.g.dart b/lib/models/api/v6/domains/domains.g.dart new file mode 100644 index 00000000..10702810 --- /dev/null +++ b/lib/models/api/v6/domains/domains.g.dart @@ -0,0 +1,105 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'domains.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$DomainsImpl _$$DomainsImplFromJson(Map json) => + _$DomainsImpl( + domains: (json['domains'] as List) + .map((e) => Domain.fromJson(e as Map)) + .toList(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$DomainsImplToJson(_$DomainsImpl instance) => + { + 'domains': instance.domains, + 'took': instance.took, + }; + +_$AddDomainsImpl _$$AddDomainsImplFromJson(Map json) => + _$AddDomainsImpl( + domains: (json['domains'] as List) + .map((e) => Domain.fromJson(e as Map)) + .toList(), + processed: Processed.fromJson(json['processed'] as Map), + took: (json['took'] as num).toDouble(), + ); + +Map _$$AddDomainsImplToJson(_$AddDomainsImpl instance) => + { + 'domains': instance.domains, + 'processed': instance.processed, + 'took': instance.took, + }; + +_$DomainImpl _$$DomainImplFromJson(Map json) => _$DomainImpl( + domain: json['domain'] as String, + unicode: json['unicode'] as String, + type: json['type'] as String, + kind: json['kind'] as String, + comment: json['comment'] as String?, + groups: (json['groups'] as List) + .map((e) => (e as num).toInt()) + .toList(), + enabled: json['enabled'] as bool, + id: (json['id'] as num).toInt(), + dateAdded: (json['date_added'] as num).toInt(), + dateModified: (json['date_modified'] as num).toInt(), + ); + +Map _$$DomainImplToJson(_$DomainImpl instance) => + { + 'domain': instance.domain, + 'unicode': instance.unicode, + 'type': instance.type, + 'kind': instance.kind, + 'comment': instance.comment, + 'groups': instance.groups, + 'enabled': instance.enabled, + 'id': instance.id, + 'date_added': instance.dateAdded, + 'date_modified': instance.dateModified, + }; + +_$ProcessedImpl _$$ProcessedImplFromJson(Map json) => + _$ProcessedImpl( + success: (json['success'] as List) + .map((e) => ProcessedItem.fromJson(e as Map)) + .toList(), + errors: (json['errors'] as List) + .map((e) => ProcessedError.fromJson(e as Map)) + .toList(), + ); + +Map _$$ProcessedImplToJson(_$ProcessedImpl instance) => + { + 'success': instance.success, + 'errors': instance.errors, + }; + +_$ProcessedItemImpl _$$ProcessedItemImplFromJson(Map json) => + _$ProcessedItemImpl( + item: json['item'] as String, + ); + +Map _$$ProcessedItemImplToJson(_$ProcessedItemImpl instance) => + { + 'item': instance.item, + }; + +_$ProcessedErrorImpl _$$ProcessedErrorImplFromJson(Map json) => + _$ProcessedErrorImpl( + item: json['item'] as String, + error: json['error'] as String, + ); + +Map _$$ProcessedErrorImplToJson( + _$ProcessedErrorImpl instance) => + { + 'item': instance.item, + 'error': instance.error, + }; diff --git a/lib/models/api/v6/error/error.dart b/lib/models/api/v6/error/error.dart new file mode 100644 index 00000000..956c5023 --- /dev/null +++ b/lib/models/api/v6/error/error.dart @@ -0,0 +1,25 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'error.freezed.dart'; +part 'error.g.dart'; + +@freezed +class Error with _$Error { + factory Error({ + required ErrorDetails error, + }) = _Error; + + factory Error.fromJson(Map json) => _$ErrorFromJson(json); +} + +@freezed +class ErrorDetails with _$ErrorDetails { + factory ErrorDetails({ + required String key, + required String message, + String? hint, + }) = _ErrorDetails; + + factory ErrorDetails.fromJson(Map json) => + _$ErrorDetailsFromJson(json); +} diff --git a/lib/models/api/v6/error/error.freezed.dart b/lib/models/api/v6/error/error.freezed.dart new file mode 100644 index 00000000..5e467977 --- /dev/null +++ b/lib/models/api/v6/error/error.freezed.dart @@ -0,0 +1,359 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'error.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Error _$ErrorFromJson(Map json) { + return _Error.fromJson(json); +} + +/// @nodoc +mixin _$Error { + ErrorDetails get error => throw _privateConstructorUsedError; + + /// Serializes this Error to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ErrorCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ErrorCopyWith<$Res> { + factory $ErrorCopyWith(Error value, $Res Function(Error) then) = + _$ErrorCopyWithImpl<$Res, Error>; + @useResult + $Res call({ErrorDetails error}); + + $ErrorDetailsCopyWith<$Res> get error; +} + +/// @nodoc +class _$ErrorCopyWithImpl<$Res, $Val extends Error> + implements $ErrorCopyWith<$Res> { + _$ErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? error = null, + }) { + return _then(_value.copyWith( + error: null == error + ? _value.error + : error // ignore: cast_nullable_to_non_nullable + as ErrorDetails, + ) as $Val); + } + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ErrorDetailsCopyWith<$Res> get error { + return $ErrorDetailsCopyWith<$Res>(_value.error, (value) { + return _then(_value.copyWith(error: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ErrorImplCopyWith<$Res> implements $ErrorCopyWith<$Res> { + factory _$$ErrorImplCopyWith( + _$ErrorImpl value, $Res Function(_$ErrorImpl) then) = + __$$ErrorImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ErrorDetails error}); + + @override + $ErrorDetailsCopyWith<$Res> get error; +} + +/// @nodoc +class __$$ErrorImplCopyWithImpl<$Res> + extends _$ErrorCopyWithImpl<$Res, _$ErrorImpl> + implements _$$ErrorImplCopyWith<$Res> { + __$$ErrorImplCopyWithImpl( + _$ErrorImpl _value, $Res Function(_$ErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? error = null, + }) { + return _then(_$ErrorImpl( + error: null == error + ? _value.error + : error // ignore: cast_nullable_to_non_nullable + as ErrorDetails, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ErrorImpl implements _Error { + _$ErrorImpl({required this.error}); + + factory _$ErrorImpl.fromJson(Map json) => + _$$ErrorImplFromJson(json); + + @override + final ErrorDetails error; + + @override + String toString() { + return 'Error(error: $error)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ErrorImpl && + (identical(other.error, error) || other.error == error)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, error); + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ErrorImplCopyWith<_$ErrorImpl> get copyWith => + __$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ErrorImplToJson( + this, + ); + } +} + +abstract class _Error implements Error { + factory _Error({required final ErrorDetails error}) = _$ErrorImpl; + + factory _Error.fromJson(Map json) = _$ErrorImpl.fromJson; + + @override + ErrorDetails get error; + + /// Create a copy of Error + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ErrorImplCopyWith<_$ErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +ErrorDetails _$ErrorDetailsFromJson(Map json) { + return _ErrorDetails.fromJson(json); +} + +/// @nodoc +mixin _$ErrorDetails { + String get key => throw _privateConstructorUsedError; + String get message => throw _privateConstructorUsedError; + String? get hint => throw _privateConstructorUsedError; + + /// Serializes this ErrorDetails to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ErrorDetails + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ErrorDetailsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ErrorDetailsCopyWith<$Res> { + factory $ErrorDetailsCopyWith( + ErrorDetails value, $Res Function(ErrorDetails) then) = + _$ErrorDetailsCopyWithImpl<$Res, ErrorDetails>; + @useResult + $Res call({String key, String message, String? hint}); +} + +/// @nodoc +class _$ErrorDetailsCopyWithImpl<$Res, $Val extends ErrorDetails> + implements $ErrorDetailsCopyWith<$Res> { + _$ErrorDetailsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ErrorDetails + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? message = null, + Object? hint = freezed, + }) { + return _then(_value.copyWith( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + hint: freezed == hint + ? _value.hint + : hint // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ErrorDetailsImplCopyWith<$Res> + implements $ErrorDetailsCopyWith<$Res> { + factory _$$ErrorDetailsImplCopyWith( + _$ErrorDetailsImpl value, $Res Function(_$ErrorDetailsImpl) then) = + __$$ErrorDetailsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String key, String message, String? hint}); +} + +/// @nodoc +class __$$ErrorDetailsImplCopyWithImpl<$Res> + extends _$ErrorDetailsCopyWithImpl<$Res, _$ErrorDetailsImpl> + implements _$$ErrorDetailsImplCopyWith<$Res> { + __$$ErrorDetailsImplCopyWithImpl( + _$ErrorDetailsImpl _value, $Res Function(_$ErrorDetailsImpl) _then) + : super(_value, _then); + + /// Create a copy of ErrorDetails + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? message = null, + Object? hint = freezed, + }) { + return _then(_$ErrorDetailsImpl( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + hint: freezed == hint + ? _value.hint + : hint // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ErrorDetailsImpl implements _ErrorDetails { + _$ErrorDetailsImpl({required this.key, required this.message, this.hint}); + + factory _$ErrorDetailsImpl.fromJson(Map json) => + _$$ErrorDetailsImplFromJson(json); + + @override + final String key; + @override + final String message; + @override + final String? hint; + + @override + String toString() { + return 'ErrorDetails(key: $key, message: $message, hint: $hint)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ErrorDetailsImpl && + (identical(other.key, key) || other.key == key) && + (identical(other.message, message) || other.message == message) && + (identical(other.hint, hint) || other.hint == hint)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, key, message, hint); + + /// Create a copy of ErrorDetails + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ErrorDetailsImplCopyWith<_$ErrorDetailsImpl> get copyWith => + __$$ErrorDetailsImplCopyWithImpl<_$ErrorDetailsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ErrorDetailsImplToJson( + this, + ); + } +} + +abstract class _ErrorDetails implements ErrorDetails { + factory _ErrorDetails( + {required final String key, + required final String message, + final String? hint}) = _$ErrorDetailsImpl; + + factory _ErrorDetails.fromJson(Map json) = + _$ErrorDetailsImpl.fromJson; + + @override + String get key; + @override + String get message; + @override + String? get hint; + + /// Create a copy of ErrorDetails + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ErrorDetailsImplCopyWith<_$ErrorDetailsImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/error/error.g.dart b/lib/models/api/v6/error/error.g.dart new file mode 100644 index 00000000..239afc4f --- /dev/null +++ b/lib/models/api/v6/error/error.g.dart @@ -0,0 +1,30 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'error.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ErrorImpl _$$ErrorImplFromJson(Map json) => _$ErrorImpl( + error: ErrorDetails.fromJson(json['error'] as Map), + ); + +Map _$$ErrorImplToJson(_$ErrorImpl instance) => + { + 'error': instance.error, + }; + +_$ErrorDetailsImpl _$$ErrorDetailsImplFromJson(Map json) => + _$ErrorDetailsImpl( + key: json['key'] as String, + message: json['message'] as String, + hint: json['hint'] as String?, + ); + +Map _$$ErrorDetailsImplToJson(_$ErrorDetailsImpl instance) => + { + 'key': instance.key, + 'message': instance.message, + 'hint': instance.hint, + }; diff --git a/lib/models/api/v6/flt/ftl.dart b/lib/models/api/v6/flt/ftl.dart new file mode 100644 index 00000000..47a9525f --- /dev/null +++ b/lib/models/api/v6/flt/ftl.dart @@ -0,0 +1,103 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'ftl.freezed.dart'; +part 'ftl.g.dart'; + +@freezed +class InfoFtl with _$InfoFtl { + const factory InfoFtl({ + required Ftl ftl, + required double took, + }) = _InfoFtl; + + factory InfoFtl.fromJson(Map json) => + _$InfoFtlFromJson(json); +} + +@freezed +class Ftl with _$Ftl { + const factory Ftl({ + required Database database, + @JsonKey(name: 'privacy_level') required int privacyLevel, + required Clients clients, + required int pid, + required int uptime, + @JsonKey(name: '%mem') required double memPercentage, + @JsonKey(name: '%cpu') required double cpuPercentage, + @JsonKey(name: 'allow_destructive') required bool allowDestructive, + required Dnsmasq dnsmasq, + }) = _Ftl; + + factory Ftl.fromJson(Map json) => _$FtlFromJson(json); +} + +@freezed +class Database with _$Database { + const factory Database({ + required int gravity, + required int groups, + required int lists, + required int clients, + required Domains domains, + }) = _Database; + + factory Database.fromJson(Map json) => + _$DatabaseFromJson(json); +} + +@freezed +class Domains with _$Domains { + const factory Domains({ + required int allowed, + required int denied, + }) = _Domains; + + factory Domains.fromJson(Map json) => + _$DomainsFromJson(json); +} + +@freezed +class Clients with _$Clients { + const factory Clients({ + required int total, + required int active, + }) = _Clients; + + factory Clients.fromJson(Map json) => + _$ClientsFromJson(json); +} + +@freezed +class Dnsmasq with _$Dnsmasq { + const factory Dnsmasq({ + @JsonKey(name: 'dns_cache_inserted') required int dnsCacheInserted, + @JsonKey(name: 'dns_cache_live_freed') required int dnsCacheLiveFreed, + @JsonKey(name: 'dns_queries_forwarded') required int dnsQueriesForwarded, + @JsonKey(name: 'dns_auth_answered') required int dnsAuthAnswered, + @JsonKey(name: 'dns_local_answered') required int dnsLocalAnswered, + @JsonKey(name: 'dns_stale_answered') required int dnsStaleAnswered, + @JsonKey(name: 'dns_unanswered') required int dnsUnanswered, + @JsonKey(name: 'bootp') required int bootp, + @JsonKey(name: 'pxe') required int pxe, + @JsonKey(name: 'dhcp_ack') required int dhcpAck, + @JsonKey(name: 'dhcp_decline') required int dhcpDecline, + @JsonKey(name: 'dhcp_discover') required int dhcpDiscover, + @JsonKey(name: 'dhcp_inform') required int dhcpInform, + @JsonKey(name: 'dhcp_nak') required int dhcpNak, + @JsonKey(name: 'dhcp_offer') required int dhcpOffer, + @JsonKey(name: 'dhcp_release') required int dhcpRelease, + @JsonKey(name: 'dhcp_request') required int dhcpRequest, + @JsonKey(name: 'noanswer') required int noAnswer, + @JsonKey(name: 'leases_allocated_4') required int leasesAllocated4, + @JsonKey(name: 'leases_pruned_4') required int leasesPruned4, + @JsonKey(name: 'leases_allocated_6') required int leasesAllocated6, + @JsonKey(name: 'leases_pruned_6') required int leasesPruned6, + @JsonKey(name: 'tcp_connections') required int tcpConnections, + @JsonKey(name: 'dnssec_max_crypto_use') required int dnssecMaxCryptoUse, + @JsonKey(name: 'dnssec_max_sig_fail') required int dnssecMaxSigFail, + @JsonKey(name: 'dnssec_max_work') required int dnssecMaxWork, + }) = _Dnsmasq; + + factory Dnsmasq.fromJson(Map json) => + _$DnsmasqFromJson(json); +} diff --git a/lib/models/api/v6/flt/ftl.freezed.dart b/lib/models/api/v6/flt/ftl.freezed.dart new file mode 100644 index 00000000..8181f90d --- /dev/null +++ b/lib/models/api/v6/flt/ftl.freezed.dart @@ -0,0 +1,1899 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'ftl.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +InfoFtl _$InfoFtlFromJson(Map json) { + return _InfoFtl.fromJson(json); +} + +/// @nodoc +mixin _$InfoFtl { + Ftl get ftl => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this InfoFtl to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $InfoFtlCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $InfoFtlCopyWith<$Res> { + factory $InfoFtlCopyWith(InfoFtl value, $Res Function(InfoFtl) then) = + _$InfoFtlCopyWithImpl<$Res, InfoFtl>; + @useResult + $Res call({Ftl ftl, double took}); + + $FtlCopyWith<$Res> get ftl; +} + +/// @nodoc +class _$InfoFtlCopyWithImpl<$Res, $Val extends InfoFtl> + implements $InfoFtlCopyWith<$Res> { + _$InfoFtlCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ftl = null, + Object? took = null, + }) { + return _then(_value.copyWith( + ftl: null == ftl + ? _value.ftl + : ftl // ignore: cast_nullable_to_non_nullable + as Ftl, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $FtlCopyWith<$Res> get ftl { + return $FtlCopyWith<$Res>(_value.ftl, (value) { + return _then(_value.copyWith(ftl: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$InfoFtlImplCopyWith<$Res> implements $InfoFtlCopyWith<$Res> { + factory _$$InfoFtlImplCopyWith( + _$InfoFtlImpl value, $Res Function(_$InfoFtlImpl) then) = + __$$InfoFtlImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({Ftl ftl, double took}); + + @override + $FtlCopyWith<$Res> get ftl; +} + +/// @nodoc +class __$$InfoFtlImplCopyWithImpl<$Res> + extends _$InfoFtlCopyWithImpl<$Res, _$InfoFtlImpl> + implements _$$InfoFtlImplCopyWith<$Res> { + __$$InfoFtlImplCopyWithImpl( + _$InfoFtlImpl _value, $Res Function(_$InfoFtlImpl) _then) + : super(_value, _then); + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ftl = null, + Object? took = null, + }) { + return _then(_$InfoFtlImpl( + ftl: null == ftl + ? _value.ftl + : ftl // ignore: cast_nullable_to_non_nullable + as Ftl, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$InfoFtlImpl implements _InfoFtl { + const _$InfoFtlImpl({required this.ftl, required this.took}); + + factory _$InfoFtlImpl.fromJson(Map json) => + _$$InfoFtlImplFromJson(json); + + @override + final Ftl ftl; + @override + final double took; + + @override + String toString() { + return 'InfoFtl(ftl: $ftl, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InfoFtlImpl && + (identical(other.ftl, ftl) || other.ftl == ftl) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, ftl, took); + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InfoFtlImplCopyWith<_$InfoFtlImpl> get copyWith => + __$$InfoFtlImplCopyWithImpl<_$InfoFtlImpl>(this, _$identity); + + @override + Map toJson() { + return _$$InfoFtlImplToJson( + this, + ); + } +} + +abstract class _InfoFtl implements InfoFtl { + const factory _InfoFtl({required final Ftl ftl, required final double took}) = + _$InfoFtlImpl; + + factory _InfoFtl.fromJson(Map json) = _$InfoFtlImpl.fromJson; + + @override + Ftl get ftl; + @override + double get took; + + /// Create a copy of InfoFtl + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InfoFtlImplCopyWith<_$InfoFtlImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Ftl _$FtlFromJson(Map json) { + return _Ftl.fromJson(json); +} + +/// @nodoc +mixin _$Ftl { + Database get database => throw _privateConstructorUsedError; + @JsonKey(name: 'privacy_level') + int get privacyLevel => throw _privateConstructorUsedError; + Clients get clients => throw _privateConstructorUsedError; + int get pid => throw _privateConstructorUsedError; + int get uptime => throw _privateConstructorUsedError; + @JsonKey(name: '%mem') + double get memPercentage => throw _privateConstructorUsedError; + @JsonKey(name: '%cpu') + double get cpuPercentage => throw _privateConstructorUsedError; + @JsonKey(name: 'allow_destructive') + bool get allowDestructive => throw _privateConstructorUsedError; + Dnsmasq get dnsmasq => throw _privateConstructorUsedError; + + /// Serializes this Ftl to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $FtlCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FtlCopyWith<$Res> { + factory $FtlCopyWith(Ftl value, $Res Function(Ftl) then) = + _$FtlCopyWithImpl<$Res, Ftl>; + @useResult + $Res call( + {Database database, + @JsonKey(name: 'privacy_level') int privacyLevel, + Clients clients, + int pid, + int uptime, + @JsonKey(name: '%mem') double memPercentage, + @JsonKey(name: '%cpu') double cpuPercentage, + @JsonKey(name: 'allow_destructive') bool allowDestructive, + Dnsmasq dnsmasq}); + + $DatabaseCopyWith<$Res> get database; + $ClientsCopyWith<$Res> get clients; + $DnsmasqCopyWith<$Res> get dnsmasq; +} + +/// @nodoc +class _$FtlCopyWithImpl<$Res, $Val extends Ftl> implements $FtlCopyWith<$Res> { + _$FtlCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? database = null, + Object? privacyLevel = null, + Object? clients = null, + Object? pid = null, + Object? uptime = null, + Object? memPercentage = null, + Object? cpuPercentage = null, + Object? allowDestructive = null, + Object? dnsmasq = null, + }) { + return _then(_value.copyWith( + database: null == database + ? _value.database + : database // ignore: cast_nullable_to_non_nullable + as Database, + privacyLevel: null == privacyLevel + ? _value.privacyLevel + : privacyLevel // ignore: cast_nullable_to_non_nullable + as int, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as Clients, + pid: null == pid + ? _value.pid + : pid // ignore: cast_nullable_to_non_nullable + as int, + uptime: null == uptime + ? _value.uptime + : uptime // ignore: cast_nullable_to_non_nullable + as int, + memPercentage: null == memPercentage + ? _value.memPercentage + : memPercentage // ignore: cast_nullable_to_non_nullable + as double, + cpuPercentage: null == cpuPercentage + ? _value.cpuPercentage + : cpuPercentage // ignore: cast_nullable_to_non_nullable + as double, + allowDestructive: null == allowDestructive + ? _value.allowDestructive + : allowDestructive // ignore: cast_nullable_to_non_nullable + as bool, + dnsmasq: null == dnsmasq + ? _value.dnsmasq + : dnsmasq // ignore: cast_nullable_to_non_nullable + as Dnsmasq, + ) as $Val); + } + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DatabaseCopyWith<$Res> get database { + return $DatabaseCopyWith<$Res>(_value.database, (value) { + return _then(_value.copyWith(database: value) as $Val); + }); + } + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ClientsCopyWith<$Res> get clients { + return $ClientsCopyWith<$Res>(_value.clients, (value) { + return _then(_value.copyWith(clients: value) as $Val); + }); + } + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DnsmasqCopyWith<$Res> get dnsmasq { + return $DnsmasqCopyWith<$Res>(_value.dnsmasq, (value) { + return _then(_value.copyWith(dnsmasq: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$FtlImplCopyWith<$Res> implements $FtlCopyWith<$Res> { + factory _$$FtlImplCopyWith(_$FtlImpl value, $Res Function(_$FtlImpl) then) = + __$$FtlImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Database database, + @JsonKey(name: 'privacy_level') int privacyLevel, + Clients clients, + int pid, + int uptime, + @JsonKey(name: '%mem') double memPercentage, + @JsonKey(name: '%cpu') double cpuPercentage, + @JsonKey(name: 'allow_destructive') bool allowDestructive, + Dnsmasq dnsmasq}); + + @override + $DatabaseCopyWith<$Res> get database; + @override + $ClientsCopyWith<$Res> get clients; + @override + $DnsmasqCopyWith<$Res> get dnsmasq; +} + +/// @nodoc +class __$$FtlImplCopyWithImpl<$Res> extends _$FtlCopyWithImpl<$Res, _$FtlImpl> + implements _$$FtlImplCopyWith<$Res> { + __$$FtlImplCopyWithImpl(_$FtlImpl _value, $Res Function(_$FtlImpl) _then) + : super(_value, _then); + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? database = null, + Object? privacyLevel = null, + Object? clients = null, + Object? pid = null, + Object? uptime = null, + Object? memPercentage = null, + Object? cpuPercentage = null, + Object? allowDestructive = null, + Object? dnsmasq = null, + }) { + return _then(_$FtlImpl( + database: null == database + ? _value.database + : database // ignore: cast_nullable_to_non_nullable + as Database, + privacyLevel: null == privacyLevel + ? _value.privacyLevel + : privacyLevel // ignore: cast_nullable_to_non_nullable + as int, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as Clients, + pid: null == pid + ? _value.pid + : pid // ignore: cast_nullable_to_non_nullable + as int, + uptime: null == uptime + ? _value.uptime + : uptime // ignore: cast_nullable_to_non_nullable + as int, + memPercentage: null == memPercentage + ? _value.memPercentage + : memPercentage // ignore: cast_nullable_to_non_nullable + as double, + cpuPercentage: null == cpuPercentage + ? _value.cpuPercentage + : cpuPercentage // ignore: cast_nullable_to_non_nullable + as double, + allowDestructive: null == allowDestructive + ? _value.allowDestructive + : allowDestructive // ignore: cast_nullable_to_non_nullable + as bool, + dnsmasq: null == dnsmasq + ? _value.dnsmasq + : dnsmasq // ignore: cast_nullable_to_non_nullable + as Dnsmasq, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$FtlImpl implements _Ftl { + const _$FtlImpl( + {required this.database, + @JsonKey(name: 'privacy_level') required this.privacyLevel, + required this.clients, + required this.pid, + required this.uptime, + @JsonKey(name: '%mem') required this.memPercentage, + @JsonKey(name: '%cpu') required this.cpuPercentage, + @JsonKey(name: 'allow_destructive') required this.allowDestructive, + required this.dnsmasq}); + + factory _$FtlImpl.fromJson(Map json) => + _$$FtlImplFromJson(json); + + @override + final Database database; + @override + @JsonKey(name: 'privacy_level') + final int privacyLevel; + @override + final Clients clients; + @override + final int pid; + @override + final int uptime; + @override + @JsonKey(name: '%mem') + final double memPercentage; + @override + @JsonKey(name: '%cpu') + final double cpuPercentage; + @override + @JsonKey(name: 'allow_destructive') + final bool allowDestructive; + @override + final Dnsmasq dnsmasq; + + @override + String toString() { + return 'Ftl(database: $database, privacyLevel: $privacyLevel, clients: $clients, pid: $pid, uptime: $uptime, memPercentage: $memPercentage, cpuPercentage: $cpuPercentage, allowDestructive: $allowDestructive, dnsmasq: $dnsmasq)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FtlImpl && + (identical(other.database, database) || + other.database == database) && + (identical(other.privacyLevel, privacyLevel) || + other.privacyLevel == privacyLevel) && + (identical(other.clients, clients) || other.clients == clients) && + (identical(other.pid, pid) || other.pid == pid) && + (identical(other.uptime, uptime) || other.uptime == uptime) && + (identical(other.memPercentage, memPercentage) || + other.memPercentage == memPercentage) && + (identical(other.cpuPercentage, cpuPercentage) || + other.cpuPercentage == cpuPercentage) && + (identical(other.allowDestructive, allowDestructive) || + other.allowDestructive == allowDestructive) && + (identical(other.dnsmasq, dnsmasq) || other.dnsmasq == dnsmasq)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, database, privacyLevel, clients, + pid, uptime, memPercentage, cpuPercentage, allowDestructive, dnsmasq); + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$FtlImplCopyWith<_$FtlImpl> get copyWith => + __$$FtlImplCopyWithImpl<_$FtlImpl>(this, _$identity); + + @override + Map toJson() { + return _$$FtlImplToJson( + this, + ); + } +} + +abstract class _Ftl implements Ftl { + const factory _Ftl( + {required final Database database, + @JsonKey(name: 'privacy_level') required final int privacyLevel, + required final Clients clients, + required final int pid, + required final int uptime, + @JsonKey(name: '%mem') required final double memPercentage, + @JsonKey(name: '%cpu') required final double cpuPercentage, + @JsonKey(name: 'allow_destructive') required final bool allowDestructive, + required final Dnsmasq dnsmasq}) = _$FtlImpl; + + factory _Ftl.fromJson(Map json) = _$FtlImpl.fromJson; + + @override + Database get database; + @override + @JsonKey(name: 'privacy_level') + int get privacyLevel; + @override + Clients get clients; + @override + int get pid; + @override + int get uptime; + @override + @JsonKey(name: '%mem') + double get memPercentage; + @override + @JsonKey(name: '%cpu') + double get cpuPercentage; + @override + @JsonKey(name: 'allow_destructive') + bool get allowDestructive; + @override + Dnsmasq get dnsmasq; + + /// Create a copy of Ftl + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FtlImplCopyWith<_$FtlImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Database _$DatabaseFromJson(Map json) { + return _Database.fromJson(json); +} + +/// @nodoc +mixin _$Database { + int get gravity => throw _privateConstructorUsedError; + int get groups => throw _privateConstructorUsedError; + int get lists => throw _privateConstructorUsedError; + int get clients => throw _privateConstructorUsedError; + Domains get domains => throw _privateConstructorUsedError; + + /// Serializes this Database to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DatabaseCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DatabaseCopyWith<$Res> { + factory $DatabaseCopyWith(Database value, $Res Function(Database) then) = + _$DatabaseCopyWithImpl<$Res, Database>; + @useResult + $Res call({int gravity, int groups, int lists, int clients, Domains domains}); + + $DomainsCopyWith<$Res> get domains; +} + +/// @nodoc +class _$DatabaseCopyWithImpl<$Res, $Val extends Database> + implements $DatabaseCopyWith<$Res> { + _$DatabaseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? gravity = null, + Object? groups = null, + Object? lists = null, + Object? clients = null, + Object? domains = null, + }) { + return _then(_value.copyWith( + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as int, + groups: null == groups + ? _value.groups + : groups // ignore: cast_nullable_to_non_nullable + as int, + lists: null == lists + ? _value.lists + : lists // ignore: cast_nullable_to_non_nullable + as int, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as int, + domains: null == domains + ? _value.domains + : domains // ignore: cast_nullable_to_non_nullable + as Domains, + ) as $Val); + } + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DomainsCopyWith<$Res> get domains { + return $DomainsCopyWith<$Res>(_value.domains, (value) { + return _then(_value.copyWith(domains: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$DatabaseImplCopyWith<$Res> + implements $DatabaseCopyWith<$Res> { + factory _$$DatabaseImplCopyWith( + _$DatabaseImpl value, $Res Function(_$DatabaseImpl) then) = + __$$DatabaseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int gravity, int groups, int lists, int clients, Domains domains}); + + @override + $DomainsCopyWith<$Res> get domains; +} + +/// @nodoc +class __$$DatabaseImplCopyWithImpl<$Res> + extends _$DatabaseCopyWithImpl<$Res, _$DatabaseImpl> + implements _$$DatabaseImplCopyWith<$Res> { + __$$DatabaseImplCopyWithImpl( + _$DatabaseImpl _value, $Res Function(_$DatabaseImpl) _then) + : super(_value, _then); + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? gravity = null, + Object? groups = null, + Object? lists = null, + Object? clients = null, + Object? domains = null, + }) { + return _then(_$DatabaseImpl( + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as int, + groups: null == groups + ? _value.groups + : groups // ignore: cast_nullable_to_non_nullable + as int, + lists: null == lists + ? _value.lists + : lists // ignore: cast_nullable_to_non_nullable + as int, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as int, + domains: null == domains + ? _value.domains + : domains // ignore: cast_nullable_to_non_nullable + as Domains, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DatabaseImpl implements _Database { + const _$DatabaseImpl( + {required this.gravity, + required this.groups, + required this.lists, + required this.clients, + required this.domains}); + + factory _$DatabaseImpl.fromJson(Map json) => + _$$DatabaseImplFromJson(json); + + @override + final int gravity; + @override + final int groups; + @override + final int lists; + @override + final int clients; + @override + final Domains domains; + + @override + String toString() { + return 'Database(gravity: $gravity, groups: $groups, lists: $lists, clients: $clients, domains: $domains)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DatabaseImpl && + (identical(other.gravity, gravity) || other.gravity == gravity) && + (identical(other.groups, groups) || other.groups == groups) && + (identical(other.lists, lists) || other.lists == lists) && + (identical(other.clients, clients) || other.clients == clients) && + (identical(other.domains, domains) || other.domains == domains)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, gravity, groups, lists, clients, domains); + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DatabaseImplCopyWith<_$DatabaseImpl> get copyWith => + __$$DatabaseImplCopyWithImpl<_$DatabaseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DatabaseImplToJson( + this, + ); + } +} + +abstract class _Database implements Database { + const factory _Database( + {required final int gravity, + required final int groups, + required final int lists, + required final int clients, + required final Domains domains}) = _$DatabaseImpl; + + factory _Database.fromJson(Map json) = + _$DatabaseImpl.fromJson; + + @override + int get gravity; + @override + int get groups; + @override + int get lists; + @override + int get clients; + @override + Domains get domains; + + /// Create a copy of Database + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DatabaseImplCopyWith<_$DatabaseImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Domains _$DomainsFromJson(Map json) { + return _Domains.fromJson(json); +} + +/// @nodoc +mixin _$Domains { + int get allowed => throw _privateConstructorUsedError; + int get denied => throw _privateConstructorUsedError; + + /// Serializes this Domains to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DomainsCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DomainsCopyWith<$Res> { + factory $DomainsCopyWith(Domains value, $Res Function(Domains) then) = + _$DomainsCopyWithImpl<$Res, Domains>; + @useResult + $Res call({int allowed, int denied}); +} + +/// @nodoc +class _$DomainsCopyWithImpl<$Res, $Val extends Domains> + implements $DomainsCopyWith<$Res> { + _$DomainsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? allowed = null, + Object? denied = null, + }) { + return _then(_value.copyWith( + allowed: null == allowed + ? _value.allowed + : allowed // ignore: cast_nullable_to_non_nullable + as int, + denied: null == denied + ? _value.denied + : denied // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DomainsImplCopyWith<$Res> implements $DomainsCopyWith<$Res> { + factory _$$DomainsImplCopyWith( + _$DomainsImpl value, $Res Function(_$DomainsImpl) then) = + __$$DomainsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int allowed, int denied}); +} + +/// @nodoc +class __$$DomainsImplCopyWithImpl<$Res> + extends _$DomainsCopyWithImpl<$Res, _$DomainsImpl> + implements _$$DomainsImplCopyWith<$Res> { + __$$DomainsImplCopyWithImpl( + _$DomainsImpl _value, $Res Function(_$DomainsImpl) _then) + : super(_value, _then); + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? allowed = null, + Object? denied = null, + }) { + return _then(_$DomainsImpl( + allowed: null == allowed + ? _value.allowed + : allowed // ignore: cast_nullable_to_non_nullable + as int, + denied: null == denied + ? _value.denied + : denied // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DomainsImpl implements _Domains { + const _$DomainsImpl({required this.allowed, required this.denied}); + + factory _$DomainsImpl.fromJson(Map json) => + _$$DomainsImplFromJson(json); + + @override + final int allowed; + @override + final int denied; + + @override + String toString() { + return 'Domains(allowed: $allowed, denied: $denied)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DomainsImpl && + (identical(other.allowed, allowed) || other.allowed == allowed) && + (identical(other.denied, denied) || other.denied == denied)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, allowed, denied); + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DomainsImplCopyWith<_$DomainsImpl> get copyWith => + __$$DomainsImplCopyWithImpl<_$DomainsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DomainsImplToJson( + this, + ); + } +} + +abstract class _Domains implements Domains { + const factory _Domains( + {required final int allowed, required final int denied}) = _$DomainsImpl; + + factory _Domains.fromJson(Map json) = _$DomainsImpl.fromJson; + + @override + int get allowed; + @override + int get denied; + + /// Create a copy of Domains + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DomainsImplCopyWith<_$DomainsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Clients _$ClientsFromJson(Map json) { + return _Clients.fromJson(json); +} + +/// @nodoc +mixin _$Clients { + int get total => throw _privateConstructorUsedError; + int get active => throw _privateConstructorUsedError; + + /// Serializes this Clients to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ClientsCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ClientsCopyWith<$Res> { + factory $ClientsCopyWith(Clients value, $Res Function(Clients) then) = + _$ClientsCopyWithImpl<$Res, Clients>; + @useResult + $Res call({int total, int active}); +} + +/// @nodoc +class _$ClientsCopyWithImpl<$Res, $Val extends Clients> + implements $ClientsCopyWith<$Res> { + _$ClientsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? total = null, + Object? active = null, + }) { + return _then(_value.copyWith( + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + active: null == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ClientsImplCopyWith<$Res> implements $ClientsCopyWith<$Res> { + factory _$$ClientsImplCopyWith( + _$ClientsImpl value, $Res Function(_$ClientsImpl) then) = + __$$ClientsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int total, int active}); +} + +/// @nodoc +class __$$ClientsImplCopyWithImpl<$Res> + extends _$ClientsCopyWithImpl<$Res, _$ClientsImpl> + implements _$$ClientsImplCopyWith<$Res> { + __$$ClientsImplCopyWithImpl( + _$ClientsImpl _value, $Res Function(_$ClientsImpl) _then) + : super(_value, _then); + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? total = null, + Object? active = null, + }) { + return _then(_$ClientsImpl( + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + active: null == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ClientsImpl implements _Clients { + const _$ClientsImpl({required this.total, required this.active}); + + factory _$ClientsImpl.fromJson(Map json) => + _$$ClientsImplFromJson(json); + + @override + final int total; + @override + final int active; + + @override + String toString() { + return 'Clients(total: $total, active: $active)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ClientsImpl && + (identical(other.total, total) || other.total == total) && + (identical(other.active, active) || other.active == active)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, total, active); + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ClientsImplCopyWith<_$ClientsImpl> get copyWith => + __$$ClientsImplCopyWithImpl<_$ClientsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ClientsImplToJson( + this, + ); + } +} + +abstract class _Clients implements Clients { + const factory _Clients( + {required final int total, required final int active}) = _$ClientsImpl; + + factory _Clients.fromJson(Map json) = _$ClientsImpl.fromJson; + + @override + int get total; + @override + int get active; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ClientsImplCopyWith<_$ClientsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Dnsmasq _$DnsmasqFromJson(Map json) { + return _Dnsmasq.fromJson(json); +} + +/// @nodoc +mixin _$Dnsmasq { + @JsonKey(name: 'dns_cache_inserted') + int get dnsCacheInserted => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_cache_live_freed') + int get dnsCacheLiveFreed => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_queries_forwarded') + int get dnsQueriesForwarded => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_auth_answered') + int get dnsAuthAnswered => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_local_answered') + int get dnsLocalAnswered => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_stale_answered') + int get dnsStaleAnswered => throw _privateConstructorUsedError; + @JsonKey(name: 'dns_unanswered') + int get dnsUnanswered => throw _privateConstructorUsedError; + @JsonKey(name: 'bootp') + int get bootp => throw _privateConstructorUsedError; + @JsonKey(name: 'pxe') + int get pxe => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_ack') + int get dhcpAck => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_decline') + int get dhcpDecline => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_discover') + int get dhcpDiscover => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_inform') + int get dhcpInform => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_nak') + int get dhcpNak => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_offer') + int get dhcpOffer => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_release') + int get dhcpRelease => throw _privateConstructorUsedError; + @JsonKey(name: 'dhcp_request') + int get dhcpRequest => throw _privateConstructorUsedError; + @JsonKey(name: 'noanswer') + int get noAnswer => throw _privateConstructorUsedError; + @JsonKey(name: 'leases_allocated_4') + int get leasesAllocated4 => throw _privateConstructorUsedError; + @JsonKey(name: 'leases_pruned_4') + int get leasesPruned4 => throw _privateConstructorUsedError; + @JsonKey(name: 'leases_allocated_6') + int get leasesAllocated6 => throw _privateConstructorUsedError; + @JsonKey(name: 'leases_pruned_6') + int get leasesPruned6 => throw _privateConstructorUsedError; + @JsonKey(name: 'tcp_connections') + int get tcpConnections => throw _privateConstructorUsedError; + @JsonKey(name: 'dnssec_max_crypto_use') + int get dnssecMaxCryptoUse => throw _privateConstructorUsedError; + @JsonKey(name: 'dnssec_max_sig_fail') + int get dnssecMaxSigFail => throw _privateConstructorUsedError; + @JsonKey(name: 'dnssec_max_work') + int get dnssecMaxWork => throw _privateConstructorUsedError; + + /// Serializes this Dnsmasq to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Dnsmasq + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DnsmasqCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DnsmasqCopyWith<$Res> { + factory $DnsmasqCopyWith(Dnsmasq value, $Res Function(Dnsmasq) then) = + _$DnsmasqCopyWithImpl<$Res, Dnsmasq>; + @useResult + $Res call( + {@JsonKey(name: 'dns_cache_inserted') int dnsCacheInserted, + @JsonKey(name: 'dns_cache_live_freed') int dnsCacheLiveFreed, + @JsonKey(name: 'dns_queries_forwarded') int dnsQueriesForwarded, + @JsonKey(name: 'dns_auth_answered') int dnsAuthAnswered, + @JsonKey(name: 'dns_local_answered') int dnsLocalAnswered, + @JsonKey(name: 'dns_stale_answered') int dnsStaleAnswered, + @JsonKey(name: 'dns_unanswered') int dnsUnanswered, + @JsonKey(name: 'bootp') int bootp, + @JsonKey(name: 'pxe') int pxe, + @JsonKey(name: 'dhcp_ack') int dhcpAck, + @JsonKey(name: 'dhcp_decline') int dhcpDecline, + @JsonKey(name: 'dhcp_discover') int dhcpDiscover, + @JsonKey(name: 'dhcp_inform') int dhcpInform, + @JsonKey(name: 'dhcp_nak') int dhcpNak, + @JsonKey(name: 'dhcp_offer') int dhcpOffer, + @JsonKey(name: 'dhcp_release') int dhcpRelease, + @JsonKey(name: 'dhcp_request') int dhcpRequest, + @JsonKey(name: 'noanswer') int noAnswer, + @JsonKey(name: 'leases_allocated_4') int leasesAllocated4, + @JsonKey(name: 'leases_pruned_4') int leasesPruned4, + @JsonKey(name: 'leases_allocated_6') int leasesAllocated6, + @JsonKey(name: 'leases_pruned_6') int leasesPruned6, + @JsonKey(name: 'tcp_connections') int tcpConnections, + @JsonKey(name: 'dnssec_max_crypto_use') int dnssecMaxCryptoUse, + @JsonKey(name: 'dnssec_max_sig_fail') int dnssecMaxSigFail, + @JsonKey(name: 'dnssec_max_work') int dnssecMaxWork}); +} + +/// @nodoc +class _$DnsmasqCopyWithImpl<$Res, $Val extends Dnsmasq> + implements $DnsmasqCopyWith<$Res> { + _$DnsmasqCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Dnsmasq + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? dnsCacheInserted = null, + Object? dnsCacheLiveFreed = null, + Object? dnsQueriesForwarded = null, + Object? dnsAuthAnswered = null, + Object? dnsLocalAnswered = null, + Object? dnsStaleAnswered = null, + Object? dnsUnanswered = null, + Object? bootp = null, + Object? pxe = null, + Object? dhcpAck = null, + Object? dhcpDecline = null, + Object? dhcpDiscover = null, + Object? dhcpInform = null, + Object? dhcpNak = null, + Object? dhcpOffer = null, + Object? dhcpRelease = null, + Object? dhcpRequest = null, + Object? noAnswer = null, + Object? leasesAllocated4 = null, + Object? leasesPruned4 = null, + Object? leasesAllocated6 = null, + Object? leasesPruned6 = null, + Object? tcpConnections = null, + Object? dnssecMaxCryptoUse = null, + Object? dnssecMaxSigFail = null, + Object? dnssecMaxWork = null, + }) { + return _then(_value.copyWith( + dnsCacheInserted: null == dnsCacheInserted + ? _value.dnsCacheInserted + : dnsCacheInserted // ignore: cast_nullable_to_non_nullable + as int, + dnsCacheLiveFreed: null == dnsCacheLiveFreed + ? _value.dnsCacheLiveFreed + : dnsCacheLiveFreed // ignore: cast_nullable_to_non_nullable + as int, + dnsQueriesForwarded: null == dnsQueriesForwarded + ? _value.dnsQueriesForwarded + : dnsQueriesForwarded // ignore: cast_nullable_to_non_nullable + as int, + dnsAuthAnswered: null == dnsAuthAnswered + ? _value.dnsAuthAnswered + : dnsAuthAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsLocalAnswered: null == dnsLocalAnswered + ? _value.dnsLocalAnswered + : dnsLocalAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsStaleAnswered: null == dnsStaleAnswered + ? _value.dnsStaleAnswered + : dnsStaleAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsUnanswered: null == dnsUnanswered + ? _value.dnsUnanswered + : dnsUnanswered // ignore: cast_nullable_to_non_nullable + as int, + bootp: null == bootp + ? _value.bootp + : bootp // ignore: cast_nullable_to_non_nullable + as int, + pxe: null == pxe + ? _value.pxe + : pxe // ignore: cast_nullable_to_non_nullable + as int, + dhcpAck: null == dhcpAck + ? _value.dhcpAck + : dhcpAck // ignore: cast_nullable_to_non_nullable + as int, + dhcpDecline: null == dhcpDecline + ? _value.dhcpDecline + : dhcpDecline // ignore: cast_nullable_to_non_nullable + as int, + dhcpDiscover: null == dhcpDiscover + ? _value.dhcpDiscover + : dhcpDiscover // ignore: cast_nullable_to_non_nullable + as int, + dhcpInform: null == dhcpInform + ? _value.dhcpInform + : dhcpInform // ignore: cast_nullable_to_non_nullable + as int, + dhcpNak: null == dhcpNak + ? _value.dhcpNak + : dhcpNak // ignore: cast_nullable_to_non_nullable + as int, + dhcpOffer: null == dhcpOffer + ? _value.dhcpOffer + : dhcpOffer // ignore: cast_nullable_to_non_nullable + as int, + dhcpRelease: null == dhcpRelease + ? _value.dhcpRelease + : dhcpRelease // ignore: cast_nullable_to_non_nullable + as int, + dhcpRequest: null == dhcpRequest + ? _value.dhcpRequest + : dhcpRequest // ignore: cast_nullable_to_non_nullable + as int, + noAnswer: null == noAnswer + ? _value.noAnswer + : noAnswer // ignore: cast_nullable_to_non_nullable + as int, + leasesAllocated4: null == leasesAllocated4 + ? _value.leasesAllocated4 + : leasesAllocated4 // ignore: cast_nullable_to_non_nullable + as int, + leasesPruned4: null == leasesPruned4 + ? _value.leasesPruned4 + : leasesPruned4 // ignore: cast_nullable_to_non_nullable + as int, + leasesAllocated6: null == leasesAllocated6 + ? _value.leasesAllocated6 + : leasesAllocated6 // ignore: cast_nullable_to_non_nullable + as int, + leasesPruned6: null == leasesPruned6 + ? _value.leasesPruned6 + : leasesPruned6 // ignore: cast_nullable_to_non_nullable + as int, + tcpConnections: null == tcpConnections + ? _value.tcpConnections + : tcpConnections // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxCryptoUse: null == dnssecMaxCryptoUse + ? _value.dnssecMaxCryptoUse + : dnssecMaxCryptoUse // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxSigFail: null == dnssecMaxSigFail + ? _value.dnssecMaxSigFail + : dnssecMaxSigFail // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxWork: null == dnssecMaxWork + ? _value.dnssecMaxWork + : dnssecMaxWork // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DnsmasqImplCopyWith<$Res> implements $DnsmasqCopyWith<$Res> { + factory _$$DnsmasqImplCopyWith( + _$DnsmasqImpl value, $Res Function(_$DnsmasqImpl) then) = + __$$DnsmasqImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'dns_cache_inserted') int dnsCacheInserted, + @JsonKey(name: 'dns_cache_live_freed') int dnsCacheLiveFreed, + @JsonKey(name: 'dns_queries_forwarded') int dnsQueriesForwarded, + @JsonKey(name: 'dns_auth_answered') int dnsAuthAnswered, + @JsonKey(name: 'dns_local_answered') int dnsLocalAnswered, + @JsonKey(name: 'dns_stale_answered') int dnsStaleAnswered, + @JsonKey(name: 'dns_unanswered') int dnsUnanswered, + @JsonKey(name: 'bootp') int bootp, + @JsonKey(name: 'pxe') int pxe, + @JsonKey(name: 'dhcp_ack') int dhcpAck, + @JsonKey(name: 'dhcp_decline') int dhcpDecline, + @JsonKey(name: 'dhcp_discover') int dhcpDiscover, + @JsonKey(name: 'dhcp_inform') int dhcpInform, + @JsonKey(name: 'dhcp_nak') int dhcpNak, + @JsonKey(name: 'dhcp_offer') int dhcpOffer, + @JsonKey(name: 'dhcp_release') int dhcpRelease, + @JsonKey(name: 'dhcp_request') int dhcpRequest, + @JsonKey(name: 'noanswer') int noAnswer, + @JsonKey(name: 'leases_allocated_4') int leasesAllocated4, + @JsonKey(name: 'leases_pruned_4') int leasesPruned4, + @JsonKey(name: 'leases_allocated_6') int leasesAllocated6, + @JsonKey(name: 'leases_pruned_6') int leasesPruned6, + @JsonKey(name: 'tcp_connections') int tcpConnections, + @JsonKey(name: 'dnssec_max_crypto_use') int dnssecMaxCryptoUse, + @JsonKey(name: 'dnssec_max_sig_fail') int dnssecMaxSigFail, + @JsonKey(name: 'dnssec_max_work') int dnssecMaxWork}); +} + +/// @nodoc +class __$$DnsmasqImplCopyWithImpl<$Res> + extends _$DnsmasqCopyWithImpl<$Res, _$DnsmasqImpl> + implements _$$DnsmasqImplCopyWith<$Res> { + __$$DnsmasqImplCopyWithImpl( + _$DnsmasqImpl _value, $Res Function(_$DnsmasqImpl) _then) + : super(_value, _then); + + /// Create a copy of Dnsmasq + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? dnsCacheInserted = null, + Object? dnsCacheLiveFreed = null, + Object? dnsQueriesForwarded = null, + Object? dnsAuthAnswered = null, + Object? dnsLocalAnswered = null, + Object? dnsStaleAnswered = null, + Object? dnsUnanswered = null, + Object? bootp = null, + Object? pxe = null, + Object? dhcpAck = null, + Object? dhcpDecline = null, + Object? dhcpDiscover = null, + Object? dhcpInform = null, + Object? dhcpNak = null, + Object? dhcpOffer = null, + Object? dhcpRelease = null, + Object? dhcpRequest = null, + Object? noAnswer = null, + Object? leasesAllocated4 = null, + Object? leasesPruned4 = null, + Object? leasesAllocated6 = null, + Object? leasesPruned6 = null, + Object? tcpConnections = null, + Object? dnssecMaxCryptoUse = null, + Object? dnssecMaxSigFail = null, + Object? dnssecMaxWork = null, + }) { + return _then(_$DnsmasqImpl( + dnsCacheInserted: null == dnsCacheInserted + ? _value.dnsCacheInserted + : dnsCacheInserted // ignore: cast_nullable_to_non_nullable + as int, + dnsCacheLiveFreed: null == dnsCacheLiveFreed + ? _value.dnsCacheLiveFreed + : dnsCacheLiveFreed // ignore: cast_nullable_to_non_nullable + as int, + dnsQueriesForwarded: null == dnsQueriesForwarded + ? _value.dnsQueriesForwarded + : dnsQueriesForwarded // ignore: cast_nullable_to_non_nullable + as int, + dnsAuthAnswered: null == dnsAuthAnswered + ? _value.dnsAuthAnswered + : dnsAuthAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsLocalAnswered: null == dnsLocalAnswered + ? _value.dnsLocalAnswered + : dnsLocalAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsStaleAnswered: null == dnsStaleAnswered + ? _value.dnsStaleAnswered + : dnsStaleAnswered // ignore: cast_nullable_to_non_nullable + as int, + dnsUnanswered: null == dnsUnanswered + ? _value.dnsUnanswered + : dnsUnanswered // ignore: cast_nullable_to_non_nullable + as int, + bootp: null == bootp + ? _value.bootp + : bootp // ignore: cast_nullable_to_non_nullable + as int, + pxe: null == pxe + ? _value.pxe + : pxe // ignore: cast_nullable_to_non_nullable + as int, + dhcpAck: null == dhcpAck + ? _value.dhcpAck + : dhcpAck // ignore: cast_nullable_to_non_nullable + as int, + dhcpDecline: null == dhcpDecline + ? _value.dhcpDecline + : dhcpDecline // ignore: cast_nullable_to_non_nullable + as int, + dhcpDiscover: null == dhcpDiscover + ? _value.dhcpDiscover + : dhcpDiscover // ignore: cast_nullable_to_non_nullable + as int, + dhcpInform: null == dhcpInform + ? _value.dhcpInform + : dhcpInform // ignore: cast_nullable_to_non_nullable + as int, + dhcpNak: null == dhcpNak + ? _value.dhcpNak + : dhcpNak // ignore: cast_nullable_to_non_nullable + as int, + dhcpOffer: null == dhcpOffer + ? _value.dhcpOffer + : dhcpOffer // ignore: cast_nullable_to_non_nullable + as int, + dhcpRelease: null == dhcpRelease + ? _value.dhcpRelease + : dhcpRelease // ignore: cast_nullable_to_non_nullable + as int, + dhcpRequest: null == dhcpRequest + ? _value.dhcpRequest + : dhcpRequest // ignore: cast_nullable_to_non_nullable + as int, + noAnswer: null == noAnswer + ? _value.noAnswer + : noAnswer // ignore: cast_nullable_to_non_nullable + as int, + leasesAllocated4: null == leasesAllocated4 + ? _value.leasesAllocated4 + : leasesAllocated4 // ignore: cast_nullable_to_non_nullable + as int, + leasesPruned4: null == leasesPruned4 + ? _value.leasesPruned4 + : leasesPruned4 // ignore: cast_nullable_to_non_nullable + as int, + leasesAllocated6: null == leasesAllocated6 + ? _value.leasesAllocated6 + : leasesAllocated6 // ignore: cast_nullable_to_non_nullable + as int, + leasesPruned6: null == leasesPruned6 + ? _value.leasesPruned6 + : leasesPruned6 // ignore: cast_nullable_to_non_nullable + as int, + tcpConnections: null == tcpConnections + ? _value.tcpConnections + : tcpConnections // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxCryptoUse: null == dnssecMaxCryptoUse + ? _value.dnssecMaxCryptoUse + : dnssecMaxCryptoUse // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxSigFail: null == dnssecMaxSigFail + ? _value.dnssecMaxSigFail + : dnssecMaxSigFail // ignore: cast_nullable_to_non_nullable + as int, + dnssecMaxWork: null == dnssecMaxWork + ? _value.dnssecMaxWork + : dnssecMaxWork // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DnsmasqImpl implements _Dnsmasq { + const _$DnsmasqImpl( + {@JsonKey(name: 'dns_cache_inserted') required this.dnsCacheInserted, + @JsonKey(name: 'dns_cache_live_freed') required this.dnsCacheLiveFreed, + @JsonKey(name: 'dns_queries_forwarded') required this.dnsQueriesForwarded, + @JsonKey(name: 'dns_auth_answered') required this.dnsAuthAnswered, + @JsonKey(name: 'dns_local_answered') required this.dnsLocalAnswered, + @JsonKey(name: 'dns_stale_answered') required this.dnsStaleAnswered, + @JsonKey(name: 'dns_unanswered') required this.dnsUnanswered, + @JsonKey(name: 'bootp') required this.bootp, + @JsonKey(name: 'pxe') required this.pxe, + @JsonKey(name: 'dhcp_ack') required this.dhcpAck, + @JsonKey(name: 'dhcp_decline') required this.dhcpDecline, + @JsonKey(name: 'dhcp_discover') required this.dhcpDiscover, + @JsonKey(name: 'dhcp_inform') required this.dhcpInform, + @JsonKey(name: 'dhcp_nak') required this.dhcpNak, + @JsonKey(name: 'dhcp_offer') required this.dhcpOffer, + @JsonKey(name: 'dhcp_release') required this.dhcpRelease, + @JsonKey(name: 'dhcp_request') required this.dhcpRequest, + @JsonKey(name: 'noanswer') required this.noAnswer, + @JsonKey(name: 'leases_allocated_4') required this.leasesAllocated4, + @JsonKey(name: 'leases_pruned_4') required this.leasesPruned4, + @JsonKey(name: 'leases_allocated_6') required this.leasesAllocated6, + @JsonKey(name: 'leases_pruned_6') required this.leasesPruned6, + @JsonKey(name: 'tcp_connections') required this.tcpConnections, + @JsonKey(name: 'dnssec_max_crypto_use') required this.dnssecMaxCryptoUse, + @JsonKey(name: 'dnssec_max_sig_fail') required this.dnssecMaxSigFail, + @JsonKey(name: 'dnssec_max_work') required this.dnssecMaxWork}); + + factory _$DnsmasqImpl.fromJson(Map json) => + _$$DnsmasqImplFromJson(json); + + @override + @JsonKey(name: 'dns_cache_inserted') + final int dnsCacheInserted; + @override + @JsonKey(name: 'dns_cache_live_freed') + final int dnsCacheLiveFreed; + @override + @JsonKey(name: 'dns_queries_forwarded') + final int dnsQueriesForwarded; + @override + @JsonKey(name: 'dns_auth_answered') + final int dnsAuthAnswered; + @override + @JsonKey(name: 'dns_local_answered') + final int dnsLocalAnswered; + @override + @JsonKey(name: 'dns_stale_answered') + final int dnsStaleAnswered; + @override + @JsonKey(name: 'dns_unanswered') + final int dnsUnanswered; + @override + @JsonKey(name: 'bootp') + final int bootp; + @override + @JsonKey(name: 'pxe') + final int pxe; + @override + @JsonKey(name: 'dhcp_ack') + final int dhcpAck; + @override + @JsonKey(name: 'dhcp_decline') + final int dhcpDecline; + @override + @JsonKey(name: 'dhcp_discover') + final int dhcpDiscover; + @override + @JsonKey(name: 'dhcp_inform') + final int dhcpInform; + @override + @JsonKey(name: 'dhcp_nak') + final int dhcpNak; + @override + @JsonKey(name: 'dhcp_offer') + final int dhcpOffer; + @override + @JsonKey(name: 'dhcp_release') + final int dhcpRelease; + @override + @JsonKey(name: 'dhcp_request') + final int dhcpRequest; + @override + @JsonKey(name: 'noanswer') + final int noAnswer; + @override + @JsonKey(name: 'leases_allocated_4') + final int leasesAllocated4; + @override + @JsonKey(name: 'leases_pruned_4') + final int leasesPruned4; + @override + @JsonKey(name: 'leases_allocated_6') + final int leasesAllocated6; + @override + @JsonKey(name: 'leases_pruned_6') + final int leasesPruned6; + @override + @JsonKey(name: 'tcp_connections') + final int tcpConnections; + @override + @JsonKey(name: 'dnssec_max_crypto_use') + final int dnssecMaxCryptoUse; + @override + @JsonKey(name: 'dnssec_max_sig_fail') + final int dnssecMaxSigFail; + @override + @JsonKey(name: 'dnssec_max_work') + final int dnssecMaxWork; + + @override + String toString() { + return 'Dnsmasq(dnsCacheInserted: $dnsCacheInserted, dnsCacheLiveFreed: $dnsCacheLiveFreed, dnsQueriesForwarded: $dnsQueriesForwarded, dnsAuthAnswered: $dnsAuthAnswered, dnsLocalAnswered: $dnsLocalAnswered, dnsStaleAnswered: $dnsStaleAnswered, dnsUnanswered: $dnsUnanswered, bootp: $bootp, pxe: $pxe, dhcpAck: $dhcpAck, dhcpDecline: $dhcpDecline, dhcpDiscover: $dhcpDiscover, dhcpInform: $dhcpInform, dhcpNak: $dhcpNak, dhcpOffer: $dhcpOffer, dhcpRelease: $dhcpRelease, dhcpRequest: $dhcpRequest, noAnswer: $noAnswer, leasesAllocated4: $leasesAllocated4, leasesPruned4: $leasesPruned4, leasesAllocated6: $leasesAllocated6, leasesPruned6: $leasesPruned6, tcpConnections: $tcpConnections, dnssecMaxCryptoUse: $dnssecMaxCryptoUse, dnssecMaxSigFail: $dnssecMaxSigFail, dnssecMaxWork: $dnssecMaxWork)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DnsmasqImpl && + (identical(other.dnsCacheInserted, dnsCacheInserted) || + other.dnsCacheInserted == dnsCacheInserted) && + (identical(other.dnsCacheLiveFreed, dnsCacheLiveFreed) || + other.dnsCacheLiveFreed == dnsCacheLiveFreed) && + (identical(other.dnsQueriesForwarded, dnsQueriesForwarded) || + other.dnsQueriesForwarded == dnsQueriesForwarded) && + (identical(other.dnsAuthAnswered, dnsAuthAnswered) || + other.dnsAuthAnswered == dnsAuthAnswered) && + (identical(other.dnsLocalAnswered, dnsLocalAnswered) || + other.dnsLocalAnswered == dnsLocalAnswered) && + (identical(other.dnsStaleAnswered, dnsStaleAnswered) || + other.dnsStaleAnswered == dnsStaleAnswered) && + (identical(other.dnsUnanswered, dnsUnanswered) || + other.dnsUnanswered == dnsUnanswered) && + (identical(other.bootp, bootp) || other.bootp == bootp) && + (identical(other.pxe, pxe) || other.pxe == pxe) && + (identical(other.dhcpAck, dhcpAck) || other.dhcpAck == dhcpAck) && + (identical(other.dhcpDecline, dhcpDecline) || + other.dhcpDecline == dhcpDecline) && + (identical(other.dhcpDiscover, dhcpDiscover) || + other.dhcpDiscover == dhcpDiscover) && + (identical(other.dhcpInform, dhcpInform) || + other.dhcpInform == dhcpInform) && + (identical(other.dhcpNak, dhcpNak) || other.dhcpNak == dhcpNak) && + (identical(other.dhcpOffer, dhcpOffer) || + other.dhcpOffer == dhcpOffer) && + (identical(other.dhcpRelease, dhcpRelease) || + other.dhcpRelease == dhcpRelease) && + (identical(other.dhcpRequest, dhcpRequest) || + other.dhcpRequest == dhcpRequest) && + (identical(other.noAnswer, noAnswer) || + other.noAnswer == noAnswer) && + (identical(other.leasesAllocated4, leasesAllocated4) || + other.leasesAllocated4 == leasesAllocated4) && + (identical(other.leasesPruned4, leasesPruned4) || + other.leasesPruned4 == leasesPruned4) && + (identical(other.leasesAllocated6, leasesAllocated6) || + other.leasesAllocated6 == leasesAllocated6) && + (identical(other.leasesPruned6, leasesPruned6) || + other.leasesPruned6 == leasesPruned6) && + (identical(other.tcpConnections, tcpConnections) || + other.tcpConnections == tcpConnections) && + (identical(other.dnssecMaxCryptoUse, dnssecMaxCryptoUse) || + other.dnssecMaxCryptoUse == dnssecMaxCryptoUse) && + (identical(other.dnssecMaxSigFail, dnssecMaxSigFail) || + other.dnssecMaxSigFail == dnssecMaxSigFail) && + (identical(other.dnssecMaxWork, dnssecMaxWork) || + other.dnssecMaxWork == dnssecMaxWork)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hashAll([ + runtimeType, + dnsCacheInserted, + dnsCacheLiveFreed, + dnsQueriesForwarded, + dnsAuthAnswered, + dnsLocalAnswered, + dnsStaleAnswered, + dnsUnanswered, + bootp, + pxe, + dhcpAck, + dhcpDecline, + dhcpDiscover, + dhcpInform, + dhcpNak, + dhcpOffer, + dhcpRelease, + dhcpRequest, + noAnswer, + leasesAllocated4, + leasesPruned4, + leasesAllocated6, + leasesPruned6, + tcpConnections, + dnssecMaxCryptoUse, + dnssecMaxSigFail, + dnssecMaxWork + ]); + + /// Create a copy of Dnsmasq + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DnsmasqImplCopyWith<_$DnsmasqImpl> get copyWith => + __$$DnsmasqImplCopyWithImpl<_$DnsmasqImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DnsmasqImplToJson( + this, + ); + } +} + +abstract class _Dnsmasq implements Dnsmasq { + const factory _Dnsmasq( + {@JsonKey(name: 'dns_cache_inserted') required final int dnsCacheInserted, + @JsonKey(name: 'dns_cache_live_freed') + required final int dnsCacheLiveFreed, + @JsonKey(name: 'dns_queries_forwarded') + required final int dnsQueriesForwarded, + @JsonKey(name: 'dns_auth_answered') required final int dnsAuthAnswered, + @JsonKey(name: 'dns_local_answered') required final int dnsLocalAnswered, + @JsonKey(name: 'dns_stale_answered') required final int dnsStaleAnswered, + @JsonKey(name: 'dns_unanswered') required final int dnsUnanswered, + @JsonKey(name: 'bootp') required final int bootp, + @JsonKey(name: 'pxe') required final int pxe, + @JsonKey(name: 'dhcp_ack') required final int dhcpAck, + @JsonKey(name: 'dhcp_decline') required final int dhcpDecline, + @JsonKey(name: 'dhcp_discover') required final int dhcpDiscover, + @JsonKey(name: 'dhcp_inform') required final int dhcpInform, + @JsonKey(name: 'dhcp_nak') required final int dhcpNak, + @JsonKey(name: 'dhcp_offer') required final int dhcpOffer, + @JsonKey(name: 'dhcp_release') required final int dhcpRelease, + @JsonKey(name: 'dhcp_request') required final int dhcpRequest, + @JsonKey(name: 'noanswer') required final int noAnswer, + @JsonKey(name: 'leases_allocated_4') required final int leasesAllocated4, + @JsonKey(name: 'leases_pruned_4') required final int leasesPruned4, + @JsonKey(name: 'leases_allocated_6') required final int leasesAllocated6, + @JsonKey(name: 'leases_pruned_6') required final int leasesPruned6, + @JsonKey(name: 'tcp_connections') required final int tcpConnections, + @JsonKey(name: 'dnssec_max_crypto_use') + required final int dnssecMaxCryptoUse, + @JsonKey(name: 'dnssec_max_sig_fail') required final int dnssecMaxSigFail, + @JsonKey(name: 'dnssec_max_work') + required final int dnssecMaxWork}) = _$DnsmasqImpl; + + factory _Dnsmasq.fromJson(Map json) = _$DnsmasqImpl.fromJson; + + @override + @JsonKey(name: 'dns_cache_inserted') + int get dnsCacheInserted; + @override + @JsonKey(name: 'dns_cache_live_freed') + int get dnsCacheLiveFreed; + @override + @JsonKey(name: 'dns_queries_forwarded') + int get dnsQueriesForwarded; + @override + @JsonKey(name: 'dns_auth_answered') + int get dnsAuthAnswered; + @override + @JsonKey(name: 'dns_local_answered') + int get dnsLocalAnswered; + @override + @JsonKey(name: 'dns_stale_answered') + int get dnsStaleAnswered; + @override + @JsonKey(name: 'dns_unanswered') + int get dnsUnanswered; + @override + @JsonKey(name: 'bootp') + int get bootp; + @override + @JsonKey(name: 'pxe') + int get pxe; + @override + @JsonKey(name: 'dhcp_ack') + int get dhcpAck; + @override + @JsonKey(name: 'dhcp_decline') + int get dhcpDecline; + @override + @JsonKey(name: 'dhcp_discover') + int get dhcpDiscover; + @override + @JsonKey(name: 'dhcp_inform') + int get dhcpInform; + @override + @JsonKey(name: 'dhcp_nak') + int get dhcpNak; + @override + @JsonKey(name: 'dhcp_offer') + int get dhcpOffer; + @override + @JsonKey(name: 'dhcp_release') + int get dhcpRelease; + @override + @JsonKey(name: 'dhcp_request') + int get dhcpRequest; + @override + @JsonKey(name: 'noanswer') + int get noAnswer; + @override + @JsonKey(name: 'leases_allocated_4') + int get leasesAllocated4; + @override + @JsonKey(name: 'leases_pruned_4') + int get leasesPruned4; + @override + @JsonKey(name: 'leases_allocated_6') + int get leasesAllocated6; + @override + @JsonKey(name: 'leases_pruned_6') + int get leasesPruned6; + @override + @JsonKey(name: 'tcp_connections') + int get tcpConnections; + @override + @JsonKey(name: 'dnssec_max_crypto_use') + int get dnssecMaxCryptoUse; + @override + @JsonKey(name: 'dnssec_max_sig_fail') + int get dnssecMaxSigFail; + @override + @JsonKey(name: 'dnssec_max_work') + int get dnssecMaxWork; + + /// Create a copy of Dnsmasq + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DnsmasqImplCopyWith<_$DnsmasqImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/flt/ftl.g.dart b/lib/models/api/v6/flt/ftl.g.dart new file mode 100644 index 00000000..f328b659 --- /dev/null +++ b/lib/models/api/v6/flt/ftl.g.dart @@ -0,0 +1,145 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'ftl.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$InfoFtlImpl _$$InfoFtlImplFromJson(Map json) => + _$InfoFtlImpl( + ftl: Ftl.fromJson(json['ftl'] as Map), + took: (json['took'] as num).toDouble(), + ); + +Map _$$InfoFtlImplToJson(_$InfoFtlImpl instance) => + { + 'ftl': instance.ftl, + 'took': instance.took, + }; + +_$FtlImpl _$$FtlImplFromJson(Map json) => _$FtlImpl( + database: Database.fromJson(json['database'] as Map), + privacyLevel: (json['privacy_level'] as num).toInt(), + clients: Clients.fromJson(json['clients'] as Map), + pid: (json['pid'] as num).toInt(), + uptime: (json['uptime'] as num).toInt(), + memPercentage: (json['%mem'] as num).toDouble(), + cpuPercentage: (json['%cpu'] as num).toDouble(), + allowDestructive: json['allow_destructive'] as bool, + dnsmasq: Dnsmasq.fromJson(json['dnsmasq'] as Map), + ); + +Map _$$FtlImplToJson(_$FtlImpl instance) => { + 'database': instance.database, + 'privacy_level': instance.privacyLevel, + 'clients': instance.clients, + 'pid': instance.pid, + 'uptime': instance.uptime, + '%mem': instance.memPercentage, + '%cpu': instance.cpuPercentage, + 'allow_destructive': instance.allowDestructive, + 'dnsmasq': instance.dnsmasq, + }; + +_$DatabaseImpl _$$DatabaseImplFromJson(Map json) => + _$DatabaseImpl( + gravity: (json['gravity'] as num).toInt(), + groups: (json['groups'] as num).toInt(), + lists: (json['lists'] as num).toInt(), + clients: (json['clients'] as num).toInt(), + domains: Domains.fromJson(json['domains'] as Map), + ); + +Map _$$DatabaseImplToJson(_$DatabaseImpl instance) => + { + 'gravity': instance.gravity, + 'groups': instance.groups, + 'lists': instance.lists, + 'clients': instance.clients, + 'domains': instance.domains, + }; + +_$DomainsImpl _$$DomainsImplFromJson(Map json) => + _$DomainsImpl( + allowed: (json['allowed'] as num).toInt(), + denied: (json['denied'] as num).toInt(), + ); + +Map _$$DomainsImplToJson(_$DomainsImpl instance) => + { + 'allowed': instance.allowed, + 'denied': instance.denied, + }; + +_$ClientsImpl _$$ClientsImplFromJson(Map json) => + _$ClientsImpl( + total: (json['total'] as num).toInt(), + active: (json['active'] as num).toInt(), + ); + +Map _$$ClientsImplToJson(_$ClientsImpl instance) => + { + 'total': instance.total, + 'active': instance.active, + }; + +_$DnsmasqImpl _$$DnsmasqImplFromJson(Map json) => + _$DnsmasqImpl( + dnsCacheInserted: (json['dns_cache_inserted'] as num).toInt(), + dnsCacheLiveFreed: (json['dns_cache_live_freed'] as num).toInt(), + dnsQueriesForwarded: (json['dns_queries_forwarded'] as num).toInt(), + dnsAuthAnswered: (json['dns_auth_answered'] as num).toInt(), + dnsLocalAnswered: (json['dns_local_answered'] as num).toInt(), + dnsStaleAnswered: (json['dns_stale_answered'] as num).toInt(), + dnsUnanswered: (json['dns_unanswered'] as num).toInt(), + bootp: (json['bootp'] as num).toInt(), + pxe: (json['pxe'] as num).toInt(), + dhcpAck: (json['dhcp_ack'] as num).toInt(), + dhcpDecline: (json['dhcp_decline'] as num).toInt(), + dhcpDiscover: (json['dhcp_discover'] as num).toInt(), + dhcpInform: (json['dhcp_inform'] as num).toInt(), + dhcpNak: (json['dhcp_nak'] as num).toInt(), + dhcpOffer: (json['dhcp_offer'] as num).toInt(), + dhcpRelease: (json['dhcp_release'] as num).toInt(), + dhcpRequest: (json['dhcp_request'] as num).toInt(), + noAnswer: (json['noanswer'] as num).toInt(), + leasesAllocated4: (json['leases_allocated_4'] as num).toInt(), + leasesPruned4: (json['leases_pruned_4'] as num).toInt(), + leasesAllocated6: (json['leases_allocated_6'] as num).toInt(), + leasesPruned6: (json['leases_pruned_6'] as num).toInt(), + tcpConnections: (json['tcp_connections'] as num).toInt(), + dnssecMaxCryptoUse: (json['dnssec_max_crypto_use'] as num).toInt(), + dnssecMaxSigFail: (json['dnssec_max_sig_fail'] as num).toInt(), + dnssecMaxWork: (json['dnssec_max_work'] as num).toInt(), + ); + +Map _$$DnsmasqImplToJson(_$DnsmasqImpl instance) => + { + 'dns_cache_inserted': instance.dnsCacheInserted, + 'dns_cache_live_freed': instance.dnsCacheLiveFreed, + 'dns_queries_forwarded': instance.dnsQueriesForwarded, + 'dns_auth_answered': instance.dnsAuthAnswered, + 'dns_local_answered': instance.dnsLocalAnswered, + 'dns_stale_answered': instance.dnsStaleAnswered, + 'dns_unanswered': instance.dnsUnanswered, + 'bootp': instance.bootp, + 'pxe': instance.pxe, + 'dhcp_ack': instance.dhcpAck, + 'dhcp_decline': instance.dhcpDecline, + 'dhcp_discover': instance.dhcpDiscover, + 'dhcp_inform': instance.dhcpInform, + 'dhcp_nak': instance.dhcpNak, + 'dhcp_offer': instance.dhcpOffer, + 'dhcp_release': instance.dhcpRelease, + 'dhcp_request': instance.dhcpRequest, + 'noanswer': instance.noAnswer, + 'leases_allocated_4': instance.leasesAllocated4, + 'leases_pruned_4': instance.leasesPruned4, + 'leases_allocated_6': instance.leasesAllocated6, + 'leases_pruned_6': instance.leasesPruned6, + 'tcp_connections': instance.tcpConnections, + 'dnssec_max_crypto_use': instance.dnssecMaxCryptoUse, + 'dnssec_max_sig_fail': instance.dnssecMaxSigFail, + 'dnssec_max_work': instance.dnssecMaxWork, + }; diff --git a/lib/models/api/v6/metrics/history.dart b/lib/models/api/v6/metrics/history.dart new file mode 100644 index 00000000..69a89550 --- /dev/null +++ b/lib/models/api/v6/metrics/history.dart @@ -0,0 +1,64 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'history.freezed.dart'; +part 'history.g.dart'; + +// api/history +@freezed +class History with _$History { + const factory History({ + required List history, + required double took, + }) = _History; + + factory History.fromJson(Map json) => + _$HistoryFromJson(json); +} + +@freezed +class HistoryData with _$HistoryData { + const factory HistoryData({ + required double timestamp, + required int total, + required int cached, + required int blocked, + required int forwarded, + }) = _HistoryData; + + factory HistoryData.fromJson(Map json) => + _$HistoryDataFromJson(json); +} + +// api/history/clients +@freezed +class HistoryClients with _$HistoryClients { + const factory HistoryClients({ + required Map clients, + required List history, + required double took, + }) = _HistoryClients; + + factory HistoryClients.fromJson(Map json) => + _$HistoryClientsFromJson(json); +} + +@freezed +class Client with _$Client { + const factory Client({ + required String? name, // Nullable since "name" can be null + required int total, + }) = _Client; + + factory Client.fromJson(Map json) => _$ClientFromJson(json); +} + +@freezed +class HistoryEntry with _$HistoryEntry { + const factory HistoryEntry({ + required double timestamp, + required Map data, + }) = _HistoryEntry; + + factory HistoryEntry.fromJson(Map json) => + _$HistoryEntryFromJson(json); +} diff --git a/lib/models/api/v6/metrics/history.freezed.dart b/lib/models/api/v6/metrics/history.freezed.dart new file mode 100644 index 00000000..be9eab1e --- /dev/null +++ b/lib/models/api/v6/metrics/history.freezed.dart @@ -0,0 +1,963 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'history.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +History _$HistoryFromJson(Map json) { + return _History.fromJson(json); +} + +/// @nodoc +mixin _$History { + List get history => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this History to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of History + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $HistoryCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HistoryCopyWith<$Res> { + factory $HistoryCopyWith(History value, $Res Function(History) then) = + _$HistoryCopyWithImpl<$Res, History>; + @useResult + $Res call({List history, double took}); +} + +/// @nodoc +class _$HistoryCopyWithImpl<$Res, $Val extends History> + implements $HistoryCopyWith<$Res> { + _$HistoryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of History + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? history = null, + Object? took = null, + }) { + return _then(_value.copyWith( + history: null == history + ? _value.history + : history // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$HistoryImplCopyWith<$Res> implements $HistoryCopyWith<$Res> { + factory _$$HistoryImplCopyWith( + _$HistoryImpl value, $Res Function(_$HistoryImpl) then) = + __$$HistoryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List history, double took}); +} + +/// @nodoc +class __$$HistoryImplCopyWithImpl<$Res> + extends _$HistoryCopyWithImpl<$Res, _$HistoryImpl> + implements _$$HistoryImplCopyWith<$Res> { + __$$HistoryImplCopyWithImpl( + _$HistoryImpl _value, $Res Function(_$HistoryImpl) _then) + : super(_value, _then); + + /// Create a copy of History + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? history = null, + Object? took = null, + }) { + return _then(_$HistoryImpl( + history: null == history + ? _value._history + : history // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$HistoryImpl implements _History { + const _$HistoryImpl( + {required final List history, required this.took}) + : _history = history; + + factory _$HistoryImpl.fromJson(Map json) => + _$$HistoryImplFromJson(json); + + final List _history; + @override + List get history { + if (_history is EqualUnmodifiableListView) return _history; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_history); + } + + @override + final double took; + + @override + String toString() { + return 'History(history: $history, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HistoryImpl && + const DeepCollectionEquality().equals(other._history, _history) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_history), took); + + /// Create a copy of History + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HistoryImplCopyWith<_$HistoryImpl> get copyWith => + __$$HistoryImplCopyWithImpl<_$HistoryImpl>(this, _$identity); + + @override + Map toJson() { + return _$$HistoryImplToJson( + this, + ); + } +} + +abstract class _History implements History { + const factory _History( + {required final List history, + required final double took}) = _$HistoryImpl; + + factory _History.fromJson(Map json) = _$HistoryImpl.fromJson; + + @override + List get history; + @override + double get took; + + /// Create a copy of History + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HistoryImplCopyWith<_$HistoryImpl> get copyWith => + throw _privateConstructorUsedError; +} + +HistoryData _$HistoryDataFromJson(Map json) { + return _HistoryData.fromJson(json); +} + +/// @nodoc +mixin _$HistoryData { + double get timestamp => throw _privateConstructorUsedError; + int get total => throw _privateConstructorUsedError; + int get cached => throw _privateConstructorUsedError; + int get blocked => throw _privateConstructorUsedError; + int get forwarded => throw _privateConstructorUsedError; + + /// Serializes this HistoryData to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of HistoryData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $HistoryDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HistoryDataCopyWith<$Res> { + factory $HistoryDataCopyWith( + HistoryData value, $Res Function(HistoryData) then) = + _$HistoryDataCopyWithImpl<$Res, HistoryData>; + @useResult + $Res call( + {double timestamp, int total, int cached, int blocked, int forwarded}); +} + +/// @nodoc +class _$HistoryDataCopyWithImpl<$Res, $Val extends HistoryData> + implements $HistoryDataCopyWith<$Res> { + _$HistoryDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of HistoryData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? timestamp = null, + Object? total = null, + Object? cached = null, + Object? blocked = null, + Object? forwarded = null, + }) { + return _then(_value.copyWith( + timestamp: null == timestamp + ? _value.timestamp + : timestamp // ignore: cast_nullable_to_non_nullable + as double, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + cached: null == cached + ? _value.cached + : cached // ignore: cast_nullable_to_non_nullable + as int, + blocked: null == blocked + ? _value.blocked + : blocked // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$HistoryDataImplCopyWith<$Res> + implements $HistoryDataCopyWith<$Res> { + factory _$$HistoryDataImplCopyWith( + _$HistoryDataImpl value, $Res Function(_$HistoryDataImpl) then) = + __$$HistoryDataImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {double timestamp, int total, int cached, int blocked, int forwarded}); +} + +/// @nodoc +class __$$HistoryDataImplCopyWithImpl<$Res> + extends _$HistoryDataCopyWithImpl<$Res, _$HistoryDataImpl> + implements _$$HistoryDataImplCopyWith<$Res> { + __$$HistoryDataImplCopyWithImpl( + _$HistoryDataImpl _value, $Res Function(_$HistoryDataImpl) _then) + : super(_value, _then); + + /// Create a copy of HistoryData + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? timestamp = null, + Object? total = null, + Object? cached = null, + Object? blocked = null, + Object? forwarded = null, + }) { + return _then(_$HistoryDataImpl( + timestamp: null == timestamp + ? _value.timestamp + : timestamp // ignore: cast_nullable_to_non_nullable + as double, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + cached: null == cached + ? _value.cached + : cached // ignore: cast_nullable_to_non_nullable + as int, + blocked: null == blocked + ? _value.blocked + : blocked // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$HistoryDataImpl implements _HistoryData { + const _$HistoryDataImpl( + {required this.timestamp, + required this.total, + required this.cached, + required this.blocked, + required this.forwarded}); + + factory _$HistoryDataImpl.fromJson(Map json) => + _$$HistoryDataImplFromJson(json); + + @override + final double timestamp; + @override + final int total; + @override + final int cached; + @override + final int blocked; + @override + final int forwarded; + + @override + String toString() { + return 'HistoryData(timestamp: $timestamp, total: $total, cached: $cached, blocked: $blocked, forwarded: $forwarded)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HistoryDataImpl && + (identical(other.timestamp, timestamp) || + other.timestamp == timestamp) && + (identical(other.total, total) || other.total == total) && + (identical(other.cached, cached) || other.cached == cached) && + (identical(other.blocked, blocked) || other.blocked == blocked) && + (identical(other.forwarded, forwarded) || + other.forwarded == forwarded)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, timestamp, total, cached, blocked, forwarded); + + /// Create a copy of HistoryData + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HistoryDataImplCopyWith<_$HistoryDataImpl> get copyWith => + __$$HistoryDataImplCopyWithImpl<_$HistoryDataImpl>(this, _$identity); + + @override + Map toJson() { + return _$$HistoryDataImplToJson( + this, + ); + } +} + +abstract class _HistoryData implements HistoryData { + const factory _HistoryData( + {required final double timestamp, + required final int total, + required final int cached, + required final int blocked, + required final int forwarded}) = _$HistoryDataImpl; + + factory _HistoryData.fromJson(Map json) = + _$HistoryDataImpl.fromJson; + + @override + double get timestamp; + @override + int get total; + @override + int get cached; + @override + int get blocked; + @override + int get forwarded; + + /// Create a copy of HistoryData + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HistoryDataImplCopyWith<_$HistoryDataImpl> get copyWith => + throw _privateConstructorUsedError; +} + +HistoryClients _$HistoryClientsFromJson(Map json) { + return _HistoryClients.fromJson(json); +} + +/// @nodoc +mixin _$HistoryClients { + Map get clients => throw _privateConstructorUsedError; + List get history => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this HistoryClients to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of HistoryClients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $HistoryClientsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HistoryClientsCopyWith<$Res> { + factory $HistoryClientsCopyWith( + HistoryClients value, $Res Function(HistoryClients) then) = + _$HistoryClientsCopyWithImpl<$Res, HistoryClients>; + @useResult + $Res call( + {Map clients, List history, double took}); +} + +/// @nodoc +class _$HistoryClientsCopyWithImpl<$Res, $Val extends HistoryClients> + implements $HistoryClientsCopyWith<$Res> { + _$HistoryClientsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of HistoryClients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? clients = null, + Object? history = null, + Object? took = null, + }) { + return _then(_value.copyWith( + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as Map, + history: null == history + ? _value.history + : history // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$HistoryClientsImplCopyWith<$Res> + implements $HistoryClientsCopyWith<$Res> { + factory _$$HistoryClientsImplCopyWith(_$HistoryClientsImpl value, + $Res Function(_$HistoryClientsImpl) then) = + __$$HistoryClientsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Map clients, List history, double took}); +} + +/// @nodoc +class __$$HistoryClientsImplCopyWithImpl<$Res> + extends _$HistoryClientsCopyWithImpl<$Res, _$HistoryClientsImpl> + implements _$$HistoryClientsImplCopyWith<$Res> { + __$$HistoryClientsImplCopyWithImpl( + _$HistoryClientsImpl _value, $Res Function(_$HistoryClientsImpl) _then) + : super(_value, _then); + + /// Create a copy of HistoryClients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? clients = null, + Object? history = null, + Object? took = null, + }) { + return _then(_$HistoryClientsImpl( + clients: null == clients + ? _value._clients + : clients // ignore: cast_nullable_to_non_nullable + as Map, + history: null == history + ? _value._history + : history // ignore: cast_nullable_to_non_nullable + as List, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$HistoryClientsImpl implements _HistoryClients { + const _$HistoryClientsImpl( + {required final Map clients, + required final List history, + required this.took}) + : _clients = clients, + _history = history; + + factory _$HistoryClientsImpl.fromJson(Map json) => + _$$HistoryClientsImplFromJson(json); + + final Map _clients; + @override + Map get clients { + if (_clients is EqualUnmodifiableMapView) return _clients; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_clients); + } + + final List _history; + @override + List get history { + if (_history is EqualUnmodifiableListView) return _history; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_history); + } + + @override + final double took; + + @override + String toString() { + return 'HistoryClients(clients: $clients, history: $history, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HistoryClientsImpl && + const DeepCollectionEquality().equals(other._clients, _clients) && + const DeepCollectionEquality().equals(other._history, _history) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_clients), + const DeepCollectionEquality().hash(_history), + took); + + /// Create a copy of HistoryClients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HistoryClientsImplCopyWith<_$HistoryClientsImpl> get copyWith => + __$$HistoryClientsImplCopyWithImpl<_$HistoryClientsImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$HistoryClientsImplToJson( + this, + ); + } +} + +abstract class _HistoryClients implements HistoryClients { + const factory _HistoryClients( + {required final Map clients, + required final List history, + required final double took}) = _$HistoryClientsImpl; + + factory _HistoryClients.fromJson(Map json) = + _$HistoryClientsImpl.fromJson; + + @override + Map get clients; + @override + List get history; + @override + double get took; + + /// Create a copy of HistoryClients + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HistoryClientsImplCopyWith<_$HistoryClientsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Client _$ClientFromJson(Map json) { + return _Client.fromJson(json); +} + +/// @nodoc +mixin _$Client { + String? get name => + throw _privateConstructorUsedError; // Nullable since "name" can be null + int get total => throw _privateConstructorUsedError; + + /// Serializes this Client to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ClientCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ClientCopyWith<$Res> { + factory $ClientCopyWith(Client value, $Res Function(Client) then) = + _$ClientCopyWithImpl<$Res, Client>; + @useResult + $Res call({String? name, int total}); +} + +/// @nodoc +class _$ClientCopyWithImpl<$Res, $Val extends Client> + implements $ClientCopyWith<$Res> { + _$ClientCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? total = null, + }) { + return _then(_value.copyWith( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ClientImplCopyWith<$Res> implements $ClientCopyWith<$Res> { + factory _$$ClientImplCopyWith( + _$ClientImpl value, $Res Function(_$ClientImpl) then) = + __$$ClientImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String? name, int total}); +} + +/// @nodoc +class __$$ClientImplCopyWithImpl<$Res> + extends _$ClientCopyWithImpl<$Res, _$ClientImpl> + implements _$$ClientImplCopyWith<$Res> { + __$$ClientImplCopyWithImpl( + _$ClientImpl _value, $Res Function(_$ClientImpl) _then) + : super(_value, _then); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? total = null, + }) { + return _then(_$ClientImpl( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ClientImpl implements _Client { + const _$ClientImpl({required this.name, required this.total}); + + factory _$ClientImpl.fromJson(Map json) => + _$$ClientImplFromJson(json); + + @override + final String? name; +// Nullable since "name" can be null + @override + final int total; + + @override + String toString() { + return 'Client(name: $name, total: $total)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ClientImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.total, total) || other.total == total)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, name, total); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + __$$ClientImplCopyWithImpl<_$ClientImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ClientImplToJson( + this, + ); + } +} + +abstract class _Client implements Client { + const factory _Client( + {required final String? name, required final int total}) = _$ClientImpl; + + factory _Client.fromJson(Map json) = _$ClientImpl.fromJson; + + @override + String? get name; // Nullable since "name" can be null + @override + int get total; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + throw _privateConstructorUsedError; +} + +HistoryEntry _$HistoryEntryFromJson(Map json) { + return _HistoryEntry.fromJson(json); +} + +/// @nodoc +mixin _$HistoryEntry { + double get timestamp => throw _privateConstructorUsedError; + Map get data => throw _privateConstructorUsedError; + + /// Serializes this HistoryEntry to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of HistoryEntry + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $HistoryEntryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HistoryEntryCopyWith<$Res> { + factory $HistoryEntryCopyWith( + HistoryEntry value, $Res Function(HistoryEntry) then) = + _$HistoryEntryCopyWithImpl<$Res, HistoryEntry>; + @useResult + $Res call({double timestamp, Map data}); +} + +/// @nodoc +class _$HistoryEntryCopyWithImpl<$Res, $Val extends HistoryEntry> + implements $HistoryEntryCopyWith<$Res> { + _$HistoryEntryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of HistoryEntry + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? timestamp = null, + Object? data = null, + }) { + return _then(_value.copyWith( + timestamp: null == timestamp + ? _value.timestamp + : timestamp // ignore: cast_nullable_to_non_nullable + as double, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as Map, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$HistoryEntryImplCopyWith<$Res> + implements $HistoryEntryCopyWith<$Res> { + factory _$$HistoryEntryImplCopyWith( + _$HistoryEntryImpl value, $Res Function(_$HistoryEntryImpl) then) = + __$$HistoryEntryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({double timestamp, Map data}); +} + +/// @nodoc +class __$$HistoryEntryImplCopyWithImpl<$Res> + extends _$HistoryEntryCopyWithImpl<$Res, _$HistoryEntryImpl> + implements _$$HistoryEntryImplCopyWith<$Res> { + __$$HistoryEntryImplCopyWithImpl( + _$HistoryEntryImpl _value, $Res Function(_$HistoryEntryImpl) _then) + : super(_value, _then); + + /// Create a copy of HistoryEntry + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? timestamp = null, + Object? data = null, + }) { + return _then(_$HistoryEntryImpl( + timestamp: null == timestamp + ? _value.timestamp + : timestamp // ignore: cast_nullable_to_non_nullable + as double, + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$HistoryEntryImpl implements _HistoryEntry { + const _$HistoryEntryImpl( + {required this.timestamp, required final Map data}) + : _data = data; + + factory _$HistoryEntryImpl.fromJson(Map json) => + _$$HistoryEntryImplFromJson(json); + + @override + final double timestamp; + final Map _data; + @override + Map get data { + if (_data is EqualUnmodifiableMapView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_data); + } + + @override + String toString() { + return 'HistoryEntry(timestamp: $timestamp, data: $data)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HistoryEntryImpl && + (identical(other.timestamp, timestamp) || + other.timestamp == timestamp) && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, timestamp, const DeepCollectionEquality().hash(_data)); + + /// Create a copy of HistoryEntry + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HistoryEntryImplCopyWith<_$HistoryEntryImpl> get copyWith => + __$$HistoryEntryImplCopyWithImpl<_$HistoryEntryImpl>(this, _$identity); + + @override + Map toJson() { + return _$$HistoryEntryImplToJson( + this, + ); + } +} + +abstract class _HistoryEntry implements HistoryEntry { + const factory _HistoryEntry( + {required final double timestamp, + required final Map data}) = _$HistoryEntryImpl; + + factory _HistoryEntry.fromJson(Map json) = + _$HistoryEntryImpl.fromJson; + + @override + double get timestamp; + @override + Map get data; + + /// Create a copy of HistoryEntry + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HistoryEntryImplCopyWith<_$HistoryEntryImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/metrics/history.g.dart b/lib/models/api/v6/metrics/history.g.dart new file mode 100644 index 00000000..007be02e --- /dev/null +++ b/lib/models/api/v6/metrics/history.g.dart @@ -0,0 +1,81 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'history.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$HistoryImpl _$$HistoryImplFromJson(Map json) => + _$HistoryImpl( + history: (json['history'] as List) + .map((e) => HistoryData.fromJson(e as Map)) + .toList(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$HistoryImplToJson(_$HistoryImpl instance) => + { + 'history': instance.history, + 'took': instance.took, + }; + +_$HistoryDataImpl _$$HistoryDataImplFromJson(Map json) => + _$HistoryDataImpl( + timestamp: (json['timestamp'] as num).toDouble(), + total: (json['total'] as num).toInt(), + cached: (json['cached'] as num).toInt(), + blocked: (json['blocked'] as num).toInt(), + forwarded: (json['forwarded'] as num).toInt(), + ); + +Map _$$HistoryDataImplToJson(_$HistoryDataImpl instance) => + { + 'timestamp': instance.timestamp, + 'total': instance.total, + 'cached': instance.cached, + 'blocked': instance.blocked, + 'forwarded': instance.forwarded, + }; + +_$HistoryClientsImpl _$$HistoryClientsImplFromJson(Map json) => + _$HistoryClientsImpl( + clients: (json['clients'] as Map).map( + (k, e) => MapEntry(k, Client.fromJson(e as Map)), + ), + history: (json['history'] as List) + .map((e) => HistoryEntry.fromJson(e as Map)) + .toList(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$HistoryClientsImplToJson( + _$HistoryClientsImpl instance) => + { + 'clients': instance.clients, + 'history': instance.history, + 'took': instance.took, + }; + +_$ClientImpl _$$ClientImplFromJson(Map json) => _$ClientImpl( + name: json['name'] as String?, + total: (json['total'] as num).toInt(), + ); + +Map _$$ClientImplToJson(_$ClientImpl instance) => + { + 'name': instance.name, + 'total': instance.total, + }; + +_$HistoryEntryImpl _$$HistoryEntryImplFromJson(Map json) => + _$HistoryEntryImpl( + timestamp: (json['timestamp'] as num).toDouble(), + data: Map.from(json['data'] as Map), + ); + +Map _$$HistoryEntryImplToJson(_$HistoryEntryImpl instance) => + { + 'timestamp': instance.timestamp, + 'data': instance.data, + }; diff --git a/lib/models/api/v6/metrics/query.dart b/lib/models/api/v6/metrics/query.dart new file mode 100644 index 00000000..d5db2b66 --- /dev/null +++ b/lib/models/api/v6/metrics/query.dart @@ -0,0 +1,58 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'query.freezed.dart'; +part 'query.g.dart'; + +@freezed +class Queries with _$Queries { + const factory Queries({ + required List queries, + required int cursor, + required int recordsTotal, + required int recordsFiltered, + required int draw, + required double took, + }) = _Queries; + + factory Queries.fromJson(Map json) => + _$QueriesFromJson(json); +} + +@freezed +class Query with _$Query { + const factory Query({ + required int id, + required double time, + required String type, + required String domain, + String? cname, + String? status, + required Client client, + String? dnssec, + required Reply reply, + @JsonKey(name: 'list_id') int? listId, + String? upstream, + }) = _Query; + + factory Query.fromJson(Map json) => _$QueryFromJson(json); +} + +@freezed +class Client with _$Client { + const factory Client({ + required String ip, + String? name, + }) = _Client; + + factory Client.fromJson(Map json) => _$ClientFromJson(json); +} + +@freezed +class Reply with _$Reply { + const factory Reply({ + String? type, + required double time, + }) = _Reply; + + factory Reply.fromJson(Map json) => _$ReplyFromJson(json); +} diff --git a/lib/models/api/v6/metrics/query.freezed.dart b/lib/models/api/v6/metrics/query.freezed.dart new file mode 100644 index 00000000..1d2308d6 --- /dev/null +++ b/lib/models/api/v6/metrics/query.freezed.dart @@ -0,0 +1,986 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'query.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Queries _$QueriesFromJson(Map json) { + return _Queries.fromJson(json); +} + +/// @nodoc +mixin _$Queries { + List get queries => throw _privateConstructorUsedError; + int get cursor => throw _privateConstructorUsedError; + int get recordsTotal => throw _privateConstructorUsedError; + int get recordsFiltered => throw _privateConstructorUsedError; + int get draw => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this Queries to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $QueriesCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $QueriesCopyWith<$Res> { + factory $QueriesCopyWith(Queries value, $Res Function(Queries) then) = + _$QueriesCopyWithImpl<$Res, Queries>; + @useResult + $Res call( + {List queries, + int cursor, + int recordsTotal, + int recordsFiltered, + int draw, + double took}); +} + +/// @nodoc +class _$QueriesCopyWithImpl<$Res, $Val extends Queries> + implements $QueriesCopyWith<$Res> { + _$QueriesCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? queries = null, + Object? cursor = null, + Object? recordsTotal = null, + Object? recordsFiltered = null, + Object? draw = null, + Object? took = null, + }) { + return _then(_value.copyWith( + queries: null == queries + ? _value.queries + : queries // ignore: cast_nullable_to_non_nullable + as List, + cursor: null == cursor + ? _value.cursor + : cursor // ignore: cast_nullable_to_non_nullable + as int, + recordsTotal: null == recordsTotal + ? _value.recordsTotal + : recordsTotal // ignore: cast_nullable_to_non_nullable + as int, + recordsFiltered: null == recordsFiltered + ? _value.recordsFiltered + : recordsFiltered // ignore: cast_nullable_to_non_nullable + as int, + draw: null == draw + ? _value.draw + : draw // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$QueriesImplCopyWith<$Res> implements $QueriesCopyWith<$Res> { + factory _$$QueriesImplCopyWith( + _$QueriesImpl value, $Res Function(_$QueriesImpl) then) = + __$$QueriesImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List queries, + int cursor, + int recordsTotal, + int recordsFiltered, + int draw, + double took}); +} + +/// @nodoc +class __$$QueriesImplCopyWithImpl<$Res> + extends _$QueriesCopyWithImpl<$Res, _$QueriesImpl> + implements _$$QueriesImplCopyWith<$Res> { + __$$QueriesImplCopyWithImpl( + _$QueriesImpl _value, $Res Function(_$QueriesImpl) _then) + : super(_value, _then); + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? queries = null, + Object? cursor = null, + Object? recordsTotal = null, + Object? recordsFiltered = null, + Object? draw = null, + Object? took = null, + }) { + return _then(_$QueriesImpl( + queries: null == queries + ? _value._queries + : queries // ignore: cast_nullable_to_non_nullable + as List, + cursor: null == cursor + ? _value.cursor + : cursor // ignore: cast_nullable_to_non_nullable + as int, + recordsTotal: null == recordsTotal + ? _value.recordsTotal + : recordsTotal // ignore: cast_nullable_to_non_nullable + as int, + recordsFiltered: null == recordsFiltered + ? _value.recordsFiltered + : recordsFiltered // ignore: cast_nullable_to_non_nullable + as int, + draw: null == draw + ? _value.draw + : draw // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$QueriesImpl implements _Queries { + const _$QueriesImpl( + {required final List queries, + required this.cursor, + required this.recordsTotal, + required this.recordsFiltered, + required this.draw, + required this.took}) + : _queries = queries; + + factory _$QueriesImpl.fromJson(Map json) => + _$$QueriesImplFromJson(json); + + final List _queries; + @override + List get queries { + if (_queries is EqualUnmodifiableListView) return _queries; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_queries); + } + + @override + final int cursor; + @override + final int recordsTotal; + @override + final int recordsFiltered; + @override + final int draw; + @override + final double took; + + @override + String toString() { + return 'Queries(queries: $queries, cursor: $cursor, recordsTotal: $recordsTotal, recordsFiltered: $recordsFiltered, draw: $draw, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$QueriesImpl && + const DeepCollectionEquality().equals(other._queries, _queries) && + (identical(other.cursor, cursor) || other.cursor == cursor) && + (identical(other.recordsTotal, recordsTotal) || + other.recordsTotal == recordsTotal) && + (identical(other.recordsFiltered, recordsFiltered) || + other.recordsFiltered == recordsFiltered) && + (identical(other.draw, draw) || other.draw == draw) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_queries), + cursor, + recordsTotal, + recordsFiltered, + draw, + took); + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$QueriesImplCopyWith<_$QueriesImpl> get copyWith => + __$$QueriesImplCopyWithImpl<_$QueriesImpl>(this, _$identity); + + @override + Map toJson() { + return _$$QueriesImplToJson( + this, + ); + } +} + +abstract class _Queries implements Queries { + const factory _Queries( + {required final List queries, + required final int cursor, + required final int recordsTotal, + required final int recordsFiltered, + required final int draw, + required final double took}) = _$QueriesImpl; + + factory _Queries.fromJson(Map json) = _$QueriesImpl.fromJson; + + @override + List get queries; + @override + int get cursor; + @override + int get recordsTotal; + @override + int get recordsFiltered; + @override + int get draw; + @override + double get took; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$QueriesImplCopyWith<_$QueriesImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Query _$QueryFromJson(Map json) { + return _Query.fromJson(json); +} + +/// @nodoc +mixin _$Query { + int get id => throw _privateConstructorUsedError; + double get time => throw _privateConstructorUsedError; + String get type => throw _privateConstructorUsedError; + String get domain => throw _privateConstructorUsedError; + String? get cname => throw _privateConstructorUsedError; + String? get status => throw _privateConstructorUsedError; + Client get client => throw _privateConstructorUsedError; + String? get dnssec => throw _privateConstructorUsedError; + Reply get reply => throw _privateConstructorUsedError; + @JsonKey(name: 'list_id') + int? get listId => throw _privateConstructorUsedError; + String? get upstream => throw _privateConstructorUsedError; + + /// Serializes this Query to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $QueryCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $QueryCopyWith<$Res> { + factory $QueryCopyWith(Query value, $Res Function(Query) then) = + _$QueryCopyWithImpl<$Res, Query>; + @useResult + $Res call( + {int id, + double time, + String type, + String domain, + String? cname, + String? status, + Client client, + String? dnssec, + Reply reply, + @JsonKey(name: 'list_id') int? listId, + String? upstream}); + + $ClientCopyWith<$Res> get client; + $ReplyCopyWith<$Res> get reply; +} + +/// @nodoc +class _$QueryCopyWithImpl<$Res, $Val extends Query> + implements $QueryCopyWith<$Res> { + _$QueryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? domain = null, + Object? cname = freezed, + Object? status = freezed, + Object? client = null, + Object? dnssec = freezed, + Object? reply = null, + Object? listId = freezed, + Object? upstream = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + cname: freezed == cname + ? _value.cname + : cname // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + client: null == client + ? _value.client + : client // ignore: cast_nullable_to_non_nullable + as Client, + dnssec: freezed == dnssec + ? _value.dnssec + : dnssec // ignore: cast_nullable_to_non_nullable + as String?, + reply: null == reply + ? _value.reply + : reply // ignore: cast_nullable_to_non_nullable + as Reply, + listId: freezed == listId + ? _value.listId + : listId // ignore: cast_nullable_to_non_nullable + as int?, + upstream: freezed == upstream + ? _value.upstream + : upstream // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ClientCopyWith<$Res> get client { + return $ClientCopyWith<$Res>(_value.client, (value) { + return _then(_value.copyWith(client: value) as $Val); + }); + } + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ReplyCopyWith<$Res> get reply { + return $ReplyCopyWith<$Res>(_value.reply, (value) { + return _then(_value.copyWith(reply: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$QueryImplCopyWith<$Res> implements $QueryCopyWith<$Res> { + factory _$$QueryImplCopyWith( + _$QueryImpl value, $Res Function(_$QueryImpl) then) = + __$$QueryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, + double time, + String type, + String domain, + String? cname, + String? status, + Client client, + String? dnssec, + Reply reply, + @JsonKey(name: 'list_id') int? listId, + String? upstream}); + + @override + $ClientCopyWith<$Res> get client; + @override + $ReplyCopyWith<$Res> get reply; +} + +/// @nodoc +class __$$QueryImplCopyWithImpl<$Res> + extends _$QueryCopyWithImpl<$Res, _$QueryImpl> + implements _$$QueryImplCopyWith<$Res> { + __$$QueryImplCopyWithImpl( + _$QueryImpl _value, $Res Function(_$QueryImpl) _then) + : super(_value, _then); + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? domain = null, + Object? cname = freezed, + Object? status = freezed, + Object? client = null, + Object? dnssec = freezed, + Object? reply = null, + Object? listId = freezed, + Object? upstream = freezed, + }) { + return _then(_$QueryImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + cname: freezed == cname + ? _value.cname + : cname // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + client: null == client + ? _value.client + : client // ignore: cast_nullable_to_non_nullable + as Client, + dnssec: freezed == dnssec + ? _value.dnssec + : dnssec // ignore: cast_nullable_to_non_nullable + as String?, + reply: null == reply + ? _value.reply + : reply // ignore: cast_nullable_to_non_nullable + as Reply, + listId: freezed == listId + ? _value.listId + : listId // ignore: cast_nullable_to_non_nullable + as int?, + upstream: freezed == upstream + ? _value.upstream + : upstream // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$QueryImpl implements _Query { + const _$QueryImpl( + {required this.id, + required this.time, + required this.type, + required this.domain, + this.cname, + this.status, + required this.client, + this.dnssec, + required this.reply, + @JsonKey(name: 'list_id') this.listId, + this.upstream}); + + factory _$QueryImpl.fromJson(Map json) => + _$$QueryImplFromJson(json); + + @override + final int id; + @override + final double time; + @override + final String type; + @override + final String domain; + @override + final String? cname; + @override + final String? status; + @override + final Client client; + @override + final String? dnssec; + @override + final Reply reply; + @override + @JsonKey(name: 'list_id') + final int? listId; + @override + final String? upstream; + + @override + String toString() { + return 'Query(id: $id, time: $time, type: $type, domain: $domain, cname: $cname, status: $status, client: $client, dnssec: $dnssec, reply: $reply, listId: $listId, upstream: $upstream)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$QueryImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.time, time) || other.time == time) && + (identical(other.type, type) || other.type == type) && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.cname, cname) || other.cname == cname) && + (identical(other.status, status) || other.status == status) && + (identical(other.client, client) || other.client == client) && + (identical(other.dnssec, dnssec) || other.dnssec == dnssec) && + (identical(other.reply, reply) || other.reply == reply) && + (identical(other.listId, listId) || other.listId == listId) && + (identical(other.upstream, upstream) || + other.upstream == upstream)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, time, type, domain, cname, + status, client, dnssec, reply, listId, upstream); + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$QueryImplCopyWith<_$QueryImpl> get copyWith => + __$$QueryImplCopyWithImpl<_$QueryImpl>(this, _$identity); + + @override + Map toJson() { + return _$$QueryImplToJson( + this, + ); + } +} + +abstract class _Query implements Query { + const factory _Query( + {required final int id, + required final double time, + required final String type, + required final String domain, + final String? cname, + final String? status, + required final Client client, + final String? dnssec, + required final Reply reply, + @JsonKey(name: 'list_id') final int? listId, + final String? upstream}) = _$QueryImpl; + + factory _Query.fromJson(Map json) = _$QueryImpl.fromJson; + + @override + int get id; + @override + double get time; + @override + String get type; + @override + String get domain; + @override + String? get cname; + @override + String? get status; + @override + Client get client; + @override + String? get dnssec; + @override + Reply get reply; + @override + @JsonKey(name: 'list_id') + int? get listId; + @override + String? get upstream; + + /// Create a copy of Query + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$QueryImplCopyWith<_$QueryImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Client _$ClientFromJson(Map json) { + return _Client.fromJson(json); +} + +/// @nodoc +mixin _$Client { + String get ip => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + + /// Serializes this Client to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ClientCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ClientCopyWith<$Res> { + factory $ClientCopyWith(Client value, $Res Function(Client) then) = + _$ClientCopyWithImpl<$Res, Client>; + @useResult + $Res call({String ip, String? name}); +} + +/// @nodoc +class _$ClientCopyWithImpl<$Res, $Val extends Client> + implements $ClientCopyWith<$Res> { + _$ClientCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = freezed, + }) { + return _then(_value.copyWith( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ClientImplCopyWith<$Res> implements $ClientCopyWith<$Res> { + factory _$$ClientImplCopyWith( + _$ClientImpl value, $Res Function(_$ClientImpl) then) = + __$$ClientImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String ip, String? name}); +} + +/// @nodoc +class __$$ClientImplCopyWithImpl<$Res> + extends _$ClientCopyWithImpl<$Res, _$ClientImpl> + implements _$$ClientImplCopyWith<$Res> { + __$$ClientImplCopyWithImpl( + _$ClientImpl _value, $Res Function(_$ClientImpl) _then) + : super(_value, _then); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = freezed, + }) { + return _then(_$ClientImpl( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ClientImpl implements _Client { + const _$ClientImpl({required this.ip, this.name}); + + factory _$ClientImpl.fromJson(Map json) => + _$$ClientImplFromJson(json); + + @override + final String ip; + @override + final String? name; + + @override + String toString() { + return 'Client(ip: $ip, name: $name)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ClientImpl && + (identical(other.ip, ip) || other.ip == ip) && + (identical(other.name, name) || other.name == name)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, ip, name); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + __$$ClientImplCopyWithImpl<_$ClientImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ClientImplToJson( + this, + ); + } +} + +abstract class _Client implements Client { + const factory _Client({required final String ip, final String? name}) = + _$ClientImpl; + + factory _Client.fromJson(Map json) = _$ClientImpl.fromJson; + + @override + String get ip; + @override + String? get name; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Reply _$ReplyFromJson(Map json) { + return _Reply.fromJson(json); +} + +/// @nodoc +mixin _$Reply { + String? get type => throw _privateConstructorUsedError; + double get time => throw _privateConstructorUsedError; + + /// Serializes this Reply to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Reply + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ReplyCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ReplyCopyWith<$Res> { + factory $ReplyCopyWith(Reply value, $Res Function(Reply) then) = + _$ReplyCopyWithImpl<$Res, Reply>; + @useResult + $Res call({String? type, double time}); +} + +/// @nodoc +class _$ReplyCopyWithImpl<$Res, $Val extends Reply> + implements $ReplyCopyWith<$Res> { + _$ReplyCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Reply + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = freezed, + Object? time = null, + }) { + return _then(_value.copyWith( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ReplyImplCopyWith<$Res> implements $ReplyCopyWith<$Res> { + factory _$$ReplyImplCopyWith( + _$ReplyImpl value, $Res Function(_$ReplyImpl) then) = + __$$ReplyImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String? type, double time}); +} + +/// @nodoc +class __$$ReplyImplCopyWithImpl<$Res> + extends _$ReplyCopyWithImpl<$Res, _$ReplyImpl> + implements _$$ReplyImplCopyWith<$Res> { + __$$ReplyImplCopyWithImpl( + _$ReplyImpl _value, $Res Function(_$ReplyImpl) _then) + : super(_value, _then); + + /// Create a copy of Reply + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = freezed, + Object? time = null, + }) { + return _then(_$ReplyImpl( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ReplyImpl implements _Reply { + const _$ReplyImpl({this.type, required this.time}); + + factory _$ReplyImpl.fromJson(Map json) => + _$$ReplyImplFromJson(json); + + @override + final String? type; + @override + final double time; + + @override + String toString() { + return 'Reply(type: $type, time: $time)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ReplyImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, type, time); + + /// Create a copy of Reply + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ReplyImplCopyWith<_$ReplyImpl> get copyWith => + __$$ReplyImplCopyWithImpl<_$ReplyImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ReplyImplToJson( + this, + ); + } +} + +abstract class _Reply implements Reply { + const factory _Reply({final String? type, required final double time}) = + _$ReplyImpl; + + factory _Reply.fromJson(Map json) = _$ReplyImpl.fromJson; + + @override + String? get type; + @override + double get time; + + /// Create a copy of Reply + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ReplyImplCopyWith<_$ReplyImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/metrics/query.g.dart b/lib/models/api/v6/metrics/query.g.dart new file mode 100644 index 00000000..6fea48fa --- /dev/null +++ b/lib/models/api/v6/metrics/query.g.dart @@ -0,0 +1,80 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'query.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$QueriesImpl _$$QueriesImplFromJson(Map json) => + _$QueriesImpl( + queries: (json['queries'] as List) + .map((e) => Query.fromJson(e as Map)) + .toList(), + cursor: (json['cursor'] as num).toInt(), + recordsTotal: (json['recordsTotal'] as num).toInt(), + recordsFiltered: (json['recordsFiltered'] as num).toInt(), + draw: (json['draw'] as num).toInt(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$QueriesImplToJson(_$QueriesImpl instance) => + { + 'queries': instance.queries, + 'cursor': instance.cursor, + 'recordsTotal': instance.recordsTotal, + 'recordsFiltered': instance.recordsFiltered, + 'draw': instance.draw, + 'took': instance.took, + }; + +_$QueryImpl _$$QueryImplFromJson(Map json) => _$QueryImpl( + id: (json['id'] as num).toInt(), + time: (json['time'] as num).toDouble(), + type: json['type'] as String, + domain: json['domain'] as String, + cname: json['cname'] as String?, + status: json['status'] as String?, + client: Client.fromJson(json['client'] as Map), + dnssec: json['dnssec'] as String?, + reply: Reply.fromJson(json['reply'] as Map), + listId: (json['list_id'] as num?)?.toInt(), + upstream: json['upstream'] as String?, + ); + +Map _$$QueryImplToJson(_$QueryImpl instance) => + { + 'id': instance.id, + 'time': instance.time, + 'type': instance.type, + 'domain': instance.domain, + 'cname': instance.cname, + 'status': instance.status, + 'client': instance.client, + 'dnssec': instance.dnssec, + 'reply': instance.reply, + 'list_id': instance.listId, + 'upstream': instance.upstream, + }; + +_$ClientImpl _$$ClientImplFromJson(Map json) => _$ClientImpl( + ip: json['ip'] as String, + name: json['name'] as String?, + ); + +Map _$$ClientImplToJson(_$ClientImpl instance) => + { + 'ip': instance.ip, + 'name': instance.name, + }; + +_$ReplyImpl _$$ReplyImplFromJson(Map json) => _$ReplyImpl( + type: json['type'] as String?, + time: (json['time'] as num).toDouble(), + ); + +Map _$$ReplyImplToJson(_$ReplyImpl instance) => + { + 'type': instance.type, + 'time': instance.time, + }; diff --git a/lib/models/api/v6/metrics/stats.dart b/lib/models/api/v6/metrics/stats.dart new file mode 100644 index 00000000..53180c43 --- /dev/null +++ b/lib/models/api/v6/metrics/stats.dart @@ -0,0 +1,218 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'stats.freezed.dart'; +part 'stats.g.dart'; + +@freezed +class StatsSummary with _$StatsSummary { + const factory StatsSummary({ + required Queries queries, + required Clients clients, + required Gravity gravity, + required double took, + }) = _StatsSummary; + + factory StatsSummary.fromJson(Map json) => + _$StatsSummaryFromJson(json); +} + +@freezed +class Queries with _$Queries { + const factory Queries({ + required int total, + required int blocked, + @JsonKey(name: 'percent_blocked') required double percentBlocked, + @JsonKey(name: 'unique_domains') required int uniqueDomains, + required int forwarded, + required int cached, + required Types types, + required Status status, + required Replies replies, + }) = _Queries; + + factory Queries.fromJson(Map json) => + _$QueriesFromJson(json); +} + +@freezed +class Types with _$Types { + const factory Types({ + @JsonKey(name: 'A') required int a, + @JsonKey(name: 'AAAA') required int aaaa, + @JsonKey(name: 'ANY') required int any, + @JsonKey(name: 'SRV') required int srv, + @JsonKey(name: 'SOA') required int soa, + @JsonKey(name: 'PTR') required int ptr, + @JsonKey(name: 'TXT') required int txt, + @JsonKey(name: 'NAPTR') required int naptr, + @JsonKey(name: 'MX') required int mx, + @JsonKey(name: 'DS') required int ds, + @JsonKey(name: 'RRSIG') required int rrsig, + @JsonKey(name: 'DNSKEY') required int dnskey, + @JsonKey(name: 'NS') required int ns, + @JsonKey(name: 'SVCB') required int svcb, + @JsonKey(name: 'HTTPS') required int https, + @JsonKey(name: 'OTHER') required int other, + }) = _Types; + + factory Types.fromJson(Map json) => _$TypesFromJson(json); +} + +@freezed +class Status with _$Status { + const factory Status({ + @JsonKey(name: 'UNKNOWN') required int unknown, + @JsonKey(name: 'GRAVITY') required int gravity, + @JsonKey(name: 'FORWARDED') required int forwarded, + @JsonKey(name: 'CACHE') required int cache, + @JsonKey(name: 'REGEX') required int regex, + @JsonKey(name: 'DENYLIST') required int denylist, + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') required int externalBlockedIp, + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') required int externalBlockedNull, + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') required int externalBlockedNxra, + @JsonKey(name: 'GRAVITY_CNAME') required int gravityCname, + @JsonKey(name: 'REGEX_CNAME') required int regexCname, + @JsonKey(name: 'DENYLIST_CNAME') required int denylistCname, + @JsonKey(name: 'RETRIED') required int retried, + @JsonKey(name: 'RETRIED_DNSSEC') required int retriedDnssec, + @JsonKey(name: 'IN_PROGRESS') required int inProgress, + @JsonKey(name: 'DBBUSY') required int dbbusy, + @JsonKey(name: 'SPECIAL_DOMAIN') required int specialDomain, + @JsonKey(name: 'CACHE_STALE') required int cacheStale, + }) = _Status; + + factory Status.fromJson(Map json) => _$StatusFromJson(json); +} + +@freezed +class Replies with _$Replies { + const factory Replies({ + @JsonKey(name: 'UNKNOWN') required int unknown, + @JsonKey(name: 'NODATA') required int nodata, + @JsonKey(name: 'NXDOMAIN') required int nxdomain, + @JsonKey(name: 'CNAME') required int cname, + @JsonKey(name: 'IP') required int ip, + @JsonKey(name: 'DOMAIN') required int domain, + @JsonKey(name: 'RRNAME') required int rrname, + @JsonKey(name: 'SERVFAIL') required int servfail, + @JsonKey(name: 'REFUSED') required int refused, + @JsonKey(name: 'NOTIMP') required int notimp, + @JsonKey(name: 'OTHER') required int other, + @JsonKey(name: 'DNSSEC') required int dnssec, + @JsonKey(name: 'NONE') required int none, + @JsonKey(name: 'BLOB') required int blob, + }) = _Replies; + + factory Replies.fromJson(Map json) => + _$RepliesFromJson(json); +} + +@freezed +class Clients with _$Clients { + const factory Clients({ + required int active, + required int total, + }) = _Clients; + + factory Clients.fromJson(Map json) => + _$ClientsFromJson(json); +} + +@freezed +class Gravity with _$Gravity { + const factory Gravity({ + @JsonKey(name: 'domains_being_blocked') required int domainsBeingBlocked, + @JsonKey(name: 'last_update') required int lastUpdate, + }) = _Gravity; + + factory Gravity.fromJson(Map json) => + _$GravityFromJson(json); +} + +//api/stats/top_tomains +@freezed +class StatsTopDomains with _$StatsTopDomains { + const factory StatsTopDomains({ + required List domains, + @JsonKey(name: 'total_queries') required int totalQueries, + @JsonKey(name: 'blocked_queries') required int blockedQueries, + required double took, + }) = _StatsTopDomains; + + factory StatsTopDomains.fromJson(Map json) => + _$StatsTopDomainsFromJson(json); +} + +@freezed +class Domain with _$Domain { + const factory Domain({ + required String domain, + required int count, + }) = _Domain; + + factory Domain.fromJson(Map json) => _$DomainFromJson(json); +} + +// api/stats/top_clients +@freezed +class StatsTopClients with _$StatsTopClients { + const factory StatsTopClients({ + required List clients, + @JsonKey(name: 'total_queries') required int totalQueries, + @JsonKey(name: 'blocked_queries') required int blockedQueries, + required double took, + }) = _StatsTopClients; + + factory StatsTopClients.fromJson(Map json) => + _$StatsTopClientsFromJson(json); +} + +@freezed +class Client with _$Client { + const factory Client({ + required String ip, + required String name, + required int count, + }) = _Client; + + factory Client.fromJson(Map json) => _$ClientFromJson(json); +} + +// api/stats/StatsUpstreams +@freezed +class StatsUpstreams with _$StatsUpstreams { + const factory StatsUpstreams({ + required List upstreams, + @JsonKey(name: 'forwarded_queries') required int forwardedQueries, + @JsonKey(name: 'total_queries') required int totalQueries, + required double took, + }) = _StatsUpstreams; + + factory StatsUpstreams.fromJson(Map json) => + _$StatsUpstreamsFromJson(json); +} + +@freezed +class Upstream with _$Upstream { + const factory Upstream({ + required String ip, + required String name, + required int port, + required int count, + required Statistics statistics, + }) = _Upstream; + + factory Upstream.fromJson(Map json) => + _$UpstreamFromJson(json); +} + +@freezed +class Statistics with _$Statistics { + const factory Statistics({ + required double response, + required double variance, + }) = _Statistics; + + factory Statistics.fromJson(Map json) => + _$StatisticsFromJson(json); +} diff --git a/lib/models/api/v6/metrics/stats.freezed.dart b/lib/models/api/v6/metrics/stats.freezed.dart new file mode 100644 index 00000000..56fdeea4 --- /dev/null +++ b/lib/models/api/v6/metrics/stats.freezed.dart @@ -0,0 +1,3949 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'stats.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +StatsSummary _$StatsSummaryFromJson(Map json) { + return _StatsSummary.fromJson(json); +} + +/// @nodoc +mixin _$StatsSummary { + Queries get queries => throw _privateConstructorUsedError; + Clients get clients => throw _privateConstructorUsedError; + Gravity get gravity => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this StatsSummary to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatsSummaryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatsSummaryCopyWith<$Res> { + factory $StatsSummaryCopyWith( + StatsSummary value, $Res Function(StatsSummary) then) = + _$StatsSummaryCopyWithImpl<$Res, StatsSummary>; + @useResult + $Res call({Queries queries, Clients clients, Gravity gravity, double took}); + + $QueriesCopyWith<$Res> get queries; + $ClientsCopyWith<$Res> get clients; + $GravityCopyWith<$Res> get gravity; +} + +/// @nodoc +class _$StatsSummaryCopyWithImpl<$Res, $Val extends StatsSummary> + implements $StatsSummaryCopyWith<$Res> { + _$StatsSummaryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? queries = null, + Object? clients = null, + Object? gravity = null, + Object? took = null, + }) { + return _then(_value.copyWith( + queries: null == queries + ? _value.queries + : queries // ignore: cast_nullable_to_non_nullable + as Queries, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as Clients, + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as Gravity, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $QueriesCopyWith<$Res> get queries { + return $QueriesCopyWith<$Res>(_value.queries, (value) { + return _then(_value.copyWith(queries: value) as $Val); + }); + } + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ClientsCopyWith<$Res> get clients { + return $ClientsCopyWith<$Res>(_value.clients, (value) { + return _then(_value.copyWith(clients: value) as $Val); + }); + } + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $GravityCopyWith<$Res> get gravity { + return $GravityCopyWith<$Res>(_value.gravity, (value) { + return _then(_value.copyWith(gravity: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$StatsSummaryImplCopyWith<$Res> + implements $StatsSummaryCopyWith<$Res> { + factory _$$StatsSummaryImplCopyWith( + _$StatsSummaryImpl value, $Res Function(_$StatsSummaryImpl) then) = + __$$StatsSummaryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({Queries queries, Clients clients, Gravity gravity, double took}); + + @override + $QueriesCopyWith<$Res> get queries; + @override + $ClientsCopyWith<$Res> get clients; + @override + $GravityCopyWith<$Res> get gravity; +} + +/// @nodoc +class __$$StatsSummaryImplCopyWithImpl<$Res> + extends _$StatsSummaryCopyWithImpl<$Res, _$StatsSummaryImpl> + implements _$$StatsSummaryImplCopyWith<$Res> { + __$$StatsSummaryImplCopyWithImpl( + _$StatsSummaryImpl _value, $Res Function(_$StatsSummaryImpl) _then) + : super(_value, _then); + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? queries = null, + Object? clients = null, + Object? gravity = null, + Object? took = null, + }) { + return _then(_$StatsSummaryImpl( + queries: null == queries + ? _value.queries + : queries // ignore: cast_nullable_to_non_nullable + as Queries, + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as Clients, + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as Gravity, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatsSummaryImpl implements _StatsSummary { + const _$StatsSummaryImpl( + {required this.queries, + required this.clients, + required this.gravity, + required this.took}); + + factory _$StatsSummaryImpl.fromJson(Map json) => + _$$StatsSummaryImplFromJson(json); + + @override + final Queries queries; + @override + final Clients clients; + @override + final Gravity gravity; + @override + final double took; + + @override + String toString() { + return 'StatsSummary(queries: $queries, clients: $clients, gravity: $gravity, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatsSummaryImpl && + (identical(other.queries, queries) || other.queries == queries) && + (identical(other.clients, clients) || other.clients == clients) && + (identical(other.gravity, gravity) || other.gravity == gravity) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, queries, clients, gravity, took); + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatsSummaryImplCopyWith<_$StatsSummaryImpl> get copyWith => + __$$StatsSummaryImplCopyWithImpl<_$StatsSummaryImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StatsSummaryImplToJson( + this, + ); + } +} + +abstract class _StatsSummary implements StatsSummary { + const factory _StatsSummary( + {required final Queries queries, + required final Clients clients, + required final Gravity gravity, + required final double took}) = _$StatsSummaryImpl; + + factory _StatsSummary.fromJson(Map json) = + _$StatsSummaryImpl.fromJson; + + @override + Queries get queries; + @override + Clients get clients; + @override + Gravity get gravity; + @override + double get took; + + /// Create a copy of StatsSummary + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatsSummaryImplCopyWith<_$StatsSummaryImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Queries _$QueriesFromJson(Map json) { + return _Queries.fromJson(json); +} + +/// @nodoc +mixin _$Queries { + int get total => throw _privateConstructorUsedError; + int get blocked => throw _privateConstructorUsedError; + @JsonKey(name: 'percent_blocked') + double get percentBlocked => throw _privateConstructorUsedError; + @JsonKey(name: 'unique_domains') + int get uniqueDomains => throw _privateConstructorUsedError; + int get forwarded => throw _privateConstructorUsedError; + int get cached => throw _privateConstructorUsedError; + Types get types => throw _privateConstructorUsedError; + Status get status => throw _privateConstructorUsedError; + Replies get replies => throw _privateConstructorUsedError; + + /// Serializes this Queries to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $QueriesCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $QueriesCopyWith<$Res> { + factory $QueriesCopyWith(Queries value, $Res Function(Queries) then) = + _$QueriesCopyWithImpl<$Res, Queries>; + @useResult + $Res call( + {int total, + int blocked, + @JsonKey(name: 'percent_blocked') double percentBlocked, + @JsonKey(name: 'unique_domains') int uniqueDomains, + int forwarded, + int cached, + Types types, + Status status, + Replies replies}); + + $TypesCopyWith<$Res> get types; + $StatusCopyWith<$Res> get status; + $RepliesCopyWith<$Res> get replies; +} + +/// @nodoc +class _$QueriesCopyWithImpl<$Res, $Val extends Queries> + implements $QueriesCopyWith<$Res> { + _$QueriesCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? total = null, + Object? blocked = null, + Object? percentBlocked = null, + Object? uniqueDomains = null, + Object? forwarded = null, + Object? cached = null, + Object? types = null, + Object? status = null, + Object? replies = null, + }) { + return _then(_value.copyWith( + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + blocked: null == blocked + ? _value.blocked + : blocked // ignore: cast_nullable_to_non_nullable + as int, + percentBlocked: null == percentBlocked + ? _value.percentBlocked + : percentBlocked // ignore: cast_nullable_to_non_nullable + as double, + uniqueDomains: null == uniqueDomains + ? _value.uniqueDomains + : uniqueDomains // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + cached: null == cached + ? _value.cached + : cached // ignore: cast_nullable_to_non_nullable + as int, + types: null == types + ? _value.types + : types // ignore: cast_nullable_to_non_nullable + as Types, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as Status, + replies: null == replies + ? _value.replies + : replies // ignore: cast_nullable_to_non_nullable + as Replies, + ) as $Val); + } + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $TypesCopyWith<$Res> get types { + return $TypesCopyWith<$Res>(_value.types, (value) { + return _then(_value.copyWith(types: value) as $Val); + }); + } + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StatusCopyWith<$Res> get status { + return $StatusCopyWith<$Res>(_value.status, (value) { + return _then(_value.copyWith(status: value) as $Val); + }); + } + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $RepliesCopyWith<$Res> get replies { + return $RepliesCopyWith<$Res>(_value.replies, (value) { + return _then(_value.copyWith(replies: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$QueriesImplCopyWith<$Res> implements $QueriesCopyWith<$Res> { + factory _$$QueriesImplCopyWith( + _$QueriesImpl value, $Res Function(_$QueriesImpl) then) = + __$$QueriesImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int total, + int blocked, + @JsonKey(name: 'percent_blocked') double percentBlocked, + @JsonKey(name: 'unique_domains') int uniqueDomains, + int forwarded, + int cached, + Types types, + Status status, + Replies replies}); + + @override + $TypesCopyWith<$Res> get types; + @override + $StatusCopyWith<$Res> get status; + @override + $RepliesCopyWith<$Res> get replies; +} + +/// @nodoc +class __$$QueriesImplCopyWithImpl<$Res> + extends _$QueriesCopyWithImpl<$Res, _$QueriesImpl> + implements _$$QueriesImplCopyWith<$Res> { + __$$QueriesImplCopyWithImpl( + _$QueriesImpl _value, $Res Function(_$QueriesImpl) _then) + : super(_value, _then); + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? total = null, + Object? blocked = null, + Object? percentBlocked = null, + Object? uniqueDomains = null, + Object? forwarded = null, + Object? cached = null, + Object? types = null, + Object? status = null, + Object? replies = null, + }) { + return _then(_$QueriesImpl( + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + blocked: null == blocked + ? _value.blocked + : blocked // ignore: cast_nullable_to_non_nullable + as int, + percentBlocked: null == percentBlocked + ? _value.percentBlocked + : percentBlocked // ignore: cast_nullable_to_non_nullable + as double, + uniqueDomains: null == uniqueDomains + ? _value.uniqueDomains + : uniqueDomains // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + cached: null == cached + ? _value.cached + : cached // ignore: cast_nullable_to_non_nullable + as int, + types: null == types + ? _value.types + : types // ignore: cast_nullable_to_non_nullable + as Types, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as Status, + replies: null == replies + ? _value.replies + : replies // ignore: cast_nullable_to_non_nullable + as Replies, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$QueriesImpl implements _Queries { + const _$QueriesImpl( + {required this.total, + required this.blocked, + @JsonKey(name: 'percent_blocked') required this.percentBlocked, + @JsonKey(name: 'unique_domains') required this.uniqueDomains, + required this.forwarded, + required this.cached, + required this.types, + required this.status, + required this.replies}); + + factory _$QueriesImpl.fromJson(Map json) => + _$$QueriesImplFromJson(json); + + @override + final int total; + @override + final int blocked; + @override + @JsonKey(name: 'percent_blocked') + final double percentBlocked; + @override + @JsonKey(name: 'unique_domains') + final int uniqueDomains; + @override + final int forwarded; + @override + final int cached; + @override + final Types types; + @override + final Status status; + @override + final Replies replies; + + @override + String toString() { + return 'Queries(total: $total, blocked: $blocked, percentBlocked: $percentBlocked, uniqueDomains: $uniqueDomains, forwarded: $forwarded, cached: $cached, types: $types, status: $status, replies: $replies)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$QueriesImpl && + (identical(other.total, total) || other.total == total) && + (identical(other.blocked, blocked) || other.blocked == blocked) && + (identical(other.percentBlocked, percentBlocked) || + other.percentBlocked == percentBlocked) && + (identical(other.uniqueDomains, uniqueDomains) || + other.uniqueDomains == uniqueDomains) && + (identical(other.forwarded, forwarded) || + other.forwarded == forwarded) && + (identical(other.cached, cached) || other.cached == cached) && + (identical(other.types, types) || other.types == types) && + (identical(other.status, status) || other.status == status) && + (identical(other.replies, replies) || other.replies == replies)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, total, blocked, percentBlocked, + uniqueDomains, forwarded, cached, types, status, replies); + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$QueriesImplCopyWith<_$QueriesImpl> get copyWith => + __$$QueriesImplCopyWithImpl<_$QueriesImpl>(this, _$identity); + + @override + Map toJson() { + return _$$QueriesImplToJson( + this, + ); + } +} + +abstract class _Queries implements Queries { + const factory _Queries( + {required final int total, + required final int blocked, + @JsonKey(name: 'percent_blocked') required final double percentBlocked, + @JsonKey(name: 'unique_domains') required final int uniqueDomains, + required final int forwarded, + required final int cached, + required final Types types, + required final Status status, + required final Replies replies}) = _$QueriesImpl; + + factory _Queries.fromJson(Map json) = _$QueriesImpl.fromJson; + + @override + int get total; + @override + int get blocked; + @override + @JsonKey(name: 'percent_blocked') + double get percentBlocked; + @override + @JsonKey(name: 'unique_domains') + int get uniqueDomains; + @override + int get forwarded; + @override + int get cached; + @override + Types get types; + @override + Status get status; + @override + Replies get replies; + + /// Create a copy of Queries + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$QueriesImplCopyWith<_$QueriesImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Types _$TypesFromJson(Map json) { + return _Types.fromJson(json); +} + +/// @nodoc +mixin _$Types { + @JsonKey(name: 'A') + int get a => throw _privateConstructorUsedError; + @JsonKey(name: 'AAAA') + int get aaaa => throw _privateConstructorUsedError; + @JsonKey(name: 'ANY') + int get any => throw _privateConstructorUsedError; + @JsonKey(name: 'SRV') + int get srv => throw _privateConstructorUsedError; + @JsonKey(name: 'SOA') + int get soa => throw _privateConstructorUsedError; + @JsonKey(name: 'PTR') + int get ptr => throw _privateConstructorUsedError; + @JsonKey(name: 'TXT') + int get txt => throw _privateConstructorUsedError; + @JsonKey(name: 'NAPTR') + int get naptr => throw _privateConstructorUsedError; + @JsonKey(name: 'MX') + int get mx => throw _privateConstructorUsedError; + @JsonKey(name: 'DS') + int get ds => throw _privateConstructorUsedError; + @JsonKey(name: 'RRSIG') + int get rrsig => throw _privateConstructorUsedError; + @JsonKey(name: 'DNSKEY') + int get dnskey => throw _privateConstructorUsedError; + @JsonKey(name: 'NS') + int get ns => throw _privateConstructorUsedError; + @JsonKey(name: 'SVCB') + int get svcb => throw _privateConstructorUsedError; + @JsonKey(name: 'HTTPS') + int get https => throw _privateConstructorUsedError; + @JsonKey(name: 'OTHER') + int get other => throw _privateConstructorUsedError; + + /// Serializes this Types to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Types + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $TypesCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TypesCopyWith<$Res> { + factory $TypesCopyWith(Types value, $Res Function(Types) then) = + _$TypesCopyWithImpl<$Res, Types>; + @useResult + $Res call( + {@JsonKey(name: 'A') int a, + @JsonKey(name: 'AAAA') int aaaa, + @JsonKey(name: 'ANY') int any, + @JsonKey(name: 'SRV') int srv, + @JsonKey(name: 'SOA') int soa, + @JsonKey(name: 'PTR') int ptr, + @JsonKey(name: 'TXT') int txt, + @JsonKey(name: 'NAPTR') int naptr, + @JsonKey(name: 'MX') int mx, + @JsonKey(name: 'DS') int ds, + @JsonKey(name: 'RRSIG') int rrsig, + @JsonKey(name: 'DNSKEY') int dnskey, + @JsonKey(name: 'NS') int ns, + @JsonKey(name: 'SVCB') int svcb, + @JsonKey(name: 'HTTPS') int https, + @JsonKey(name: 'OTHER') int other}); +} + +/// @nodoc +class _$TypesCopyWithImpl<$Res, $Val extends Types> + implements $TypesCopyWith<$Res> { + _$TypesCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Types + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? a = null, + Object? aaaa = null, + Object? any = null, + Object? srv = null, + Object? soa = null, + Object? ptr = null, + Object? txt = null, + Object? naptr = null, + Object? mx = null, + Object? ds = null, + Object? rrsig = null, + Object? dnskey = null, + Object? ns = null, + Object? svcb = null, + Object? https = null, + Object? other = null, + }) { + return _then(_value.copyWith( + a: null == a + ? _value.a + : a // ignore: cast_nullable_to_non_nullable + as int, + aaaa: null == aaaa + ? _value.aaaa + : aaaa // ignore: cast_nullable_to_non_nullable + as int, + any: null == any + ? _value.any + : any // ignore: cast_nullable_to_non_nullable + as int, + srv: null == srv + ? _value.srv + : srv // ignore: cast_nullable_to_non_nullable + as int, + soa: null == soa + ? _value.soa + : soa // ignore: cast_nullable_to_non_nullable + as int, + ptr: null == ptr + ? _value.ptr + : ptr // ignore: cast_nullable_to_non_nullable + as int, + txt: null == txt + ? _value.txt + : txt // ignore: cast_nullable_to_non_nullable + as int, + naptr: null == naptr + ? _value.naptr + : naptr // ignore: cast_nullable_to_non_nullable + as int, + mx: null == mx + ? _value.mx + : mx // ignore: cast_nullable_to_non_nullable + as int, + ds: null == ds + ? _value.ds + : ds // ignore: cast_nullable_to_non_nullable + as int, + rrsig: null == rrsig + ? _value.rrsig + : rrsig // ignore: cast_nullable_to_non_nullable + as int, + dnskey: null == dnskey + ? _value.dnskey + : dnskey // ignore: cast_nullable_to_non_nullable + as int, + ns: null == ns + ? _value.ns + : ns // ignore: cast_nullable_to_non_nullable + as int, + svcb: null == svcb + ? _value.svcb + : svcb // ignore: cast_nullable_to_non_nullable + as int, + https: null == https + ? _value.https + : https // ignore: cast_nullable_to_non_nullable + as int, + other: null == other + ? _value.other + : other // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$TypesImplCopyWith<$Res> implements $TypesCopyWith<$Res> { + factory _$$TypesImplCopyWith( + _$TypesImpl value, $Res Function(_$TypesImpl) then) = + __$$TypesImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'A') int a, + @JsonKey(name: 'AAAA') int aaaa, + @JsonKey(name: 'ANY') int any, + @JsonKey(name: 'SRV') int srv, + @JsonKey(name: 'SOA') int soa, + @JsonKey(name: 'PTR') int ptr, + @JsonKey(name: 'TXT') int txt, + @JsonKey(name: 'NAPTR') int naptr, + @JsonKey(name: 'MX') int mx, + @JsonKey(name: 'DS') int ds, + @JsonKey(name: 'RRSIG') int rrsig, + @JsonKey(name: 'DNSKEY') int dnskey, + @JsonKey(name: 'NS') int ns, + @JsonKey(name: 'SVCB') int svcb, + @JsonKey(name: 'HTTPS') int https, + @JsonKey(name: 'OTHER') int other}); +} + +/// @nodoc +class __$$TypesImplCopyWithImpl<$Res> + extends _$TypesCopyWithImpl<$Res, _$TypesImpl> + implements _$$TypesImplCopyWith<$Res> { + __$$TypesImplCopyWithImpl( + _$TypesImpl _value, $Res Function(_$TypesImpl) _then) + : super(_value, _then); + + /// Create a copy of Types + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? a = null, + Object? aaaa = null, + Object? any = null, + Object? srv = null, + Object? soa = null, + Object? ptr = null, + Object? txt = null, + Object? naptr = null, + Object? mx = null, + Object? ds = null, + Object? rrsig = null, + Object? dnskey = null, + Object? ns = null, + Object? svcb = null, + Object? https = null, + Object? other = null, + }) { + return _then(_$TypesImpl( + a: null == a + ? _value.a + : a // ignore: cast_nullable_to_non_nullable + as int, + aaaa: null == aaaa + ? _value.aaaa + : aaaa // ignore: cast_nullable_to_non_nullable + as int, + any: null == any + ? _value.any + : any // ignore: cast_nullable_to_non_nullable + as int, + srv: null == srv + ? _value.srv + : srv // ignore: cast_nullable_to_non_nullable + as int, + soa: null == soa + ? _value.soa + : soa // ignore: cast_nullable_to_non_nullable + as int, + ptr: null == ptr + ? _value.ptr + : ptr // ignore: cast_nullable_to_non_nullable + as int, + txt: null == txt + ? _value.txt + : txt // ignore: cast_nullable_to_non_nullable + as int, + naptr: null == naptr + ? _value.naptr + : naptr // ignore: cast_nullable_to_non_nullable + as int, + mx: null == mx + ? _value.mx + : mx // ignore: cast_nullable_to_non_nullable + as int, + ds: null == ds + ? _value.ds + : ds // ignore: cast_nullable_to_non_nullable + as int, + rrsig: null == rrsig + ? _value.rrsig + : rrsig // ignore: cast_nullable_to_non_nullable + as int, + dnskey: null == dnskey + ? _value.dnskey + : dnskey // ignore: cast_nullable_to_non_nullable + as int, + ns: null == ns + ? _value.ns + : ns // ignore: cast_nullable_to_non_nullable + as int, + svcb: null == svcb + ? _value.svcb + : svcb // ignore: cast_nullable_to_non_nullable + as int, + https: null == https + ? _value.https + : https // ignore: cast_nullable_to_non_nullable + as int, + other: null == other + ? _value.other + : other // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$TypesImpl implements _Types { + const _$TypesImpl( + {@JsonKey(name: 'A') required this.a, + @JsonKey(name: 'AAAA') required this.aaaa, + @JsonKey(name: 'ANY') required this.any, + @JsonKey(name: 'SRV') required this.srv, + @JsonKey(name: 'SOA') required this.soa, + @JsonKey(name: 'PTR') required this.ptr, + @JsonKey(name: 'TXT') required this.txt, + @JsonKey(name: 'NAPTR') required this.naptr, + @JsonKey(name: 'MX') required this.mx, + @JsonKey(name: 'DS') required this.ds, + @JsonKey(name: 'RRSIG') required this.rrsig, + @JsonKey(name: 'DNSKEY') required this.dnskey, + @JsonKey(name: 'NS') required this.ns, + @JsonKey(name: 'SVCB') required this.svcb, + @JsonKey(name: 'HTTPS') required this.https, + @JsonKey(name: 'OTHER') required this.other}); + + factory _$TypesImpl.fromJson(Map json) => + _$$TypesImplFromJson(json); + + @override + @JsonKey(name: 'A') + final int a; + @override + @JsonKey(name: 'AAAA') + final int aaaa; + @override + @JsonKey(name: 'ANY') + final int any; + @override + @JsonKey(name: 'SRV') + final int srv; + @override + @JsonKey(name: 'SOA') + final int soa; + @override + @JsonKey(name: 'PTR') + final int ptr; + @override + @JsonKey(name: 'TXT') + final int txt; + @override + @JsonKey(name: 'NAPTR') + final int naptr; + @override + @JsonKey(name: 'MX') + final int mx; + @override + @JsonKey(name: 'DS') + final int ds; + @override + @JsonKey(name: 'RRSIG') + final int rrsig; + @override + @JsonKey(name: 'DNSKEY') + final int dnskey; + @override + @JsonKey(name: 'NS') + final int ns; + @override + @JsonKey(name: 'SVCB') + final int svcb; + @override + @JsonKey(name: 'HTTPS') + final int https; + @override + @JsonKey(name: 'OTHER') + final int other; + + @override + String toString() { + return 'Types(a: $a, aaaa: $aaaa, any: $any, srv: $srv, soa: $soa, ptr: $ptr, txt: $txt, naptr: $naptr, mx: $mx, ds: $ds, rrsig: $rrsig, dnskey: $dnskey, ns: $ns, svcb: $svcb, https: $https, other: $other)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TypesImpl && + (identical(other.a, a) || other.a == a) && + (identical(other.aaaa, aaaa) || other.aaaa == aaaa) && + (identical(other.any, any) || other.any == any) && + (identical(other.srv, srv) || other.srv == srv) && + (identical(other.soa, soa) || other.soa == soa) && + (identical(other.ptr, ptr) || other.ptr == ptr) && + (identical(other.txt, txt) || other.txt == txt) && + (identical(other.naptr, naptr) || other.naptr == naptr) && + (identical(other.mx, mx) || other.mx == mx) && + (identical(other.ds, ds) || other.ds == ds) && + (identical(other.rrsig, rrsig) || other.rrsig == rrsig) && + (identical(other.dnskey, dnskey) || other.dnskey == dnskey) && + (identical(other.ns, ns) || other.ns == ns) && + (identical(other.svcb, svcb) || other.svcb == svcb) && + (identical(other.https, https) || other.https == https) && + (identical(other.other, this.other) || other.other == this.other)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, a, aaaa, any, srv, soa, ptr, txt, + naptr, mx, ds, rrsig, dnskey, ns, svcb, https, other); + + /// Create a copy of Types + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$TypesImplCopyWith<_$TypesImpl> get copyWith => + __$$TypesImplCopyWithImpl<_$TypesImpl>(this, _$identity); + + @override + Map toJson() { + return _$$TypesImplToJson( + this, + ); + } +} + +abstract class _Types implements Types { + const factory _Types( + {@JsonKey(name: 'A') required final int a, + @JsonKey(name: 'AAAA') required final int aaaa, + @JsonKey(name: 'ANY') required final int any, + @JsonKey(name: 'SRV') required final int srv, + @JsonKey(name: 'SOA') required final int soa, + @JsonKey(name: 'PTR') required final int ptr, + @JsonKey(name: 'TXT') required final int txt, + @JsonKey(name: 'NAPTR') required final int naptr, + @JsonKey(name: 'MX') required final int mx, + @JsonKey(name: 'DS') required final int ds, + @JsonKey(name: 'RRSIG') required final int rrsig, + @JsonKey(name: 'DNSKEY') required final int dnskey, + @JsonKey(name: 'NS') required final int ns, + @JsonKey(name: 'SVCB') required final int svcb, + @JsonKey(name: 'HTTPS') required final int https, + @JsonKey(name: 'OTHER') required final int other}) = _$TypesImpl; + + factory _Types.fromJson(Map json) = _$TypesImpl.fromJson; + + @override + @JsonKey(name: 'A') + int get a; + @override + @JsonKey(name: 'AAAA') + int get aaaa; + @override + @JsonKey(name: 'ANY') + int get any; + @override + @JsonKey(name: 'SRV') + int get srv; + @override + @JsonKey(name: 'SOA') + int get soa; + @override + @JsonKey(name: 'PTR') + int get ptr; + @override + @JsonKey(name: 'TXT') + int get txt; + @override + @JsonKey(name: 'NAPTR') + int get naptr; + @override + @JsonKey(name: 'MX') + int get mx; + @override + @JsonKey(name: 'DS') + int get ds; + @override + @JsonKey(name: 'RRSIG') + int get rrsig; + @override + @JsonKey(name: 'DNSKEY') + int get dnskey; + @override + @JsonKey(name: 'NS') + int get ns; + @override + @JsonKey(name: 'SVCB') + int get svcb; + @override + @JsonKey(name: 'HTTPS') + int get https; + @override + @JsonKey(name: 'OTHER') + int get other; + + /// Create a copy of Types + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$TypesImplCopyWith<_$TypesImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Status _$StatusFromJson(Map json) { + return _Status.fromJson(json); +} + +/// @nodoc +mixin _$Status { + @JsonKey(name: 'UNKNOWN') + int get unknown => throw _privateConstructorUsedError; + @JsonKey(name: 'GRAVITY') + int get gravity => throw _privateConstructorUsedError; + @JsonKey(name: 'FORWARDED') + int get forwarded => throw _privateConstructorUsedError; + @JsonKey(name: 'CACHE') + int get cache => throw _privateConstructorUsedError; + @JsonKey(name: 'REGEX') + int get regex => throw _privateConstructorUsedError; + @JsonKey(name: 'DENYLIST') + int get denylist => throw _privateConstructorUsedError; + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') + int get externalBlockedIp => throw _privateConstructorUsedError; + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') + int get externalBlockedNull => throw _privateConstructorUsedError; + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') + int get externalBlockedNxra => throw _privateConstructorUsedError; + @JsonKey(name: 'GRAVITY_CNAME') + int get gravityCname => throw _privateConstructorUsedError; + @JsonKey(name: 'REGEX_CNAME') + int get regexCname => throw _privateConstructorUsedError; + @JsonKey(name: 'DENYLIST_CNAME') + int get denylistCname => throw _privateConstructorUsedError; + @JsonKey(name: 'RETRIED') + int get retried => throw _privateConstructorUsedError; + @JsonKey(name: 'RETRIED_DNSSEC') + int get retriedDnssec => throw _privateConstructorUsedError; + @JsonKey(name: 'IN_PROGRESS') + int get inProgress => throw _privateConstructorUsedError; + @JsonKey(name: 'DBBUSY') + int get dbbusy => throw _privateConstructorUsedError; + @JsonKey(name: 'SPECIAL_DOMAIN') + int get specialDomain => throw _privateConstructorUsedError; + @JsonKey(name: 'CACHE_STALE') + int get cacheStale => throw _privateConstructorUsedError; + + /// Serializes this Status to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Status + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatusCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatusCopyWith<$Res> { + factory $StatusCopyWith(Status value, $Res Function(Status) then) = + _$StatusCopyWithImpl<$Res, Status>; + @useResult + $Res call( + {@JsonKey(name: 'UNKNOWN') int unknown, + @JsonKey(name: 'GRAVITY') int gravity, + @JsonKey(name: 'FORWARDED') int forwarded, + @JsonKey(name: 'CACHE') int cache, + @JsonKey(name: 'REGEX') int regex, + @JsonKey(name: 'DENYLIST') int denylist, + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') int externalBlockedIp, + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') int externalBlockedNull, + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') int externalBlockedNxra, + @JsonKey(name: 'GRAVITY_CNAME') int gravityCname, + @JsonKey(name: 'REGEX_CNAME') int regexCname, + @JsonKey(name: 'DENYLIST_CNAME') int denylistCname, + @JsonKey(name: 'RETRIED') int retried, + @JsonKey(name: 'RETRIED_DNSSEC') int retriedDnssec, + @JsonKey(name: 'IN_PROGRESS') int inProgress, + @JsonKey(name: 'DBBUSY') int dbbusy, + @JsonKey(name: 'SPECIAL_DOMAIN') int specialDomain, + @JsonKey(name: 'CACHE_STALE') int cacheStale}); +} + +/// @nodoc +class _$StatusCopyWithImpl<$Res, $Val extends Status> + implements $StatusCopyWith<$Res> { + _$StatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Status + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? unknown = null, + Object? gravity = null, + Object? forwarded = null, + Object? cache = null, + Object? regex = null, + Object? denylist = null, + Object? externalBlockedIp = null, + Object? externalBlockedNull = null, + Object? externalBlockedNxra = null, + Object? gravityCname = null, + Object? regexCname = null, + Object? denylistCname = null, + Object? retried = null, + Object? retriedDnssec = null, + Object? inProgress = null, + Object? dbbusy = null, + Object? specialDomain = null, + Object? cacheStale = null, + }) { + return _then(_value.copyWith( + unknown: null == unknown + ? _value.unknown + : unknown // ignore: cast_nullable_to_non_nullable + as int, + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + cache: null == cache + ? _value.cache + : cache // ignore: cast_nullable_to_non_nullable + as int, + regex: null == regex + ? _value.regex + : regex // ignore: cast_nullable_to_non_nullable + as int, + denylist: null == denylist + ? _value.denylist + : denylist // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedIp: null == externalBlockedIp + ? _value.externalBlockedIp + : externalBlockedIp // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedNull: null == externalBlockedNull + ? _value.externalBlockedNull + : externalBlockedNull // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedNxra: null == externalBlockedNxra + ? _value.externalBlockedNxra + : externalBlockedNxra // ignore: cast_nullable_to_non_nullable + as int, + gravityCname: null == gravityCname + ? _value.gravityCname + : gravityCname // ignore: cast_nullable_to_non_nullable + as int, + regexCname: null == regexCname + ? _value.regexCname + : regexCname // ignore: cast_nullable_to_non_nullable + as int, + denylistCname: null == denylistCname + ? _value.denylistCname + : denylistCname // ignore: cast_nullable_to_non_nullable + as int, + retried: null == retried + ? _value.retried + : retried // ignore: cast_nullable_to_non_nullable + as int, + retriedDnssec: null == retriedDnssec + ? _value.retriedDnssec + : retriedDnssec // ignore: cast_nullable_to_non_nullable + as int, + inProgress: null == inProgress + ? _value.inProgress + : inProgress // ignore: cast_nullable_to_non_nullable + as int, + dbbusy: null == dbbusy + ? _value.dbbusy + : dbbusy // ignore: cast_nullable_to_non_nullable + as int, + specialDomain: null == specialDomain + ? _value.specialDomain + : specialDomain // ignore: cast_nullable_to_non_nullable + as int, + cacheStale: null == cacheStale + ? _value.cacheStale + : cacheStale // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatusImplCopyWith<$Res> implements $StatusCopyWith<$Res> { + factory _$$StatusImplCopyWith( + _$StatusImpl value, $Res Function(_$StatusImpl) then) = + __$$StatusImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'UNKNOWN') int unknown, + @JsonKey(name: 'GRAVITY') int gravity, + @JsonKey(name: 'FORWARDED') int forwarded, + @JsonKey(name: 'CACHE') int cache, + @JsonKey(name: 'REGEX') int regex, + @JsonKey(name: 'DENYLIST') int denylist, + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') int externalBlockedIp, + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') int externalBlockedNull, + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') int externalBlockedNxra, + @JsonKey(name: 'GRAVITY_CNAME') int gravityCname, + @JsonKey(name: 'REGEX_CNAME') int regexCname, + @JsonKey(name: 'DENYLIST_CNAME') int denylistCname, + @JsonKey(name: 'RETRIED') int retried, + @JsonKey(name: 'RETRIED_DNSSEC') int retriedDnssec, + @JsonKey(name: 'IN_PROGRESS') int inProgress, + @JsonKey(name: 'DBBUSY') int dbbusy, + @JsonKey(name: 'SPECIAL_DOMAIN') int specialDomain, + @JsonKey(name: 'CACHE_STALE') int cacheStale}); +} + +/// @nodoc +class __$$StatusImplCopyWithImpl<$Res> + extends _$StatusCopyWithImpl<$Res, _$StatusImpl> + implements _$$StatusImplCopyWith<$Res> { + __$$StatusImplCopyWithImpl( + _$StatusImpl _value, $Res Function(_$StatusImpl) _then) + : super(_value, _then); + + /// Create a copy of Status + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? unknown = null, + Object? gravity = null, + Object? forwarded = null, + Object? cache = null, + Object? regex = null, + Object? denylist = null, + Object? externalBlockedIp = null, + Object? externalBlockedNull = null, + Object? externalBlockedNxra = null, + Object? gravityCname = null, + Object? regexCname = null, + Object? denylistCname = null, + Object? retried = null, + Object? retriedDnssec = null, + Object? inProgress = null, + Object? dbbusy = null, + Object? specialDomain = null, + Object? cacheStale = null, + }) { + return _then(_$StatusImpl( + unknown: null == unknown + ? _value.unknown + : unknown // ignore: cast_nullable_to_non_nullable + as int, + gravity: null == gravity + ? _value.gravity + : gravity // ignore: cast_nullable_to_non_nullable + as int, + forwarded: null == forwarded + ? _value.forwarded + : forwarded // ignore: cast_nullable_to_non_nullable + as int, + cache: null == cache + ? _value.cache + : cache // ignore: cast_nullable_to_non_nullable + as int, + regex: null == regex + ? _value.regex + : regex // ignore: cast_nullable_to_non_nullable + as int, + denylist: null == denylist + ? _value.denylist + : denylist // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedIp: null == externalBlockedIp + ? _value.externalBlockedIp + : externalBlockedIp // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedNull: null == externalBlockedNull + ? _value.externalBlockedNull + : externalBlockedNull // ignore: cast_nullable_to_non_nullable + as int, + externalBlockedNxra: null == externalBlockedNxra + ? _value.externalBlockedNxra + : externalBlockedNxra // ignore: cast_nullable_to_non_nullable + as int, + gravityCname: null == gravityCname + ? _value.gravityCname + : gravityCname // ignore: cast_nullable_to_non_nullable + as int, + regexCname: null == regexCname + ? _value.regexCname + : regexCname // ignore: cast_nullable_to_non_nullable + as int, + denylistCname: null == denylistCname + ? _value.denylistCname + : denylistCname // ignore: cast_nullable_to_non_nullable + as int, + retried: null == retried + ? _value.retried + : retried // ignore: cast_nullable_to_non_nullable + as int, + retriedDnssec: null == retriedDnssec + ? _value.retriedDnssec + : retriedDnssec // ignore: cast_nullable_to_non_nullable + as int, + inProgress: null == inProgress + ? _value.inProgress + : inProgress // ignore: cast_nullable_to_non_nullable + as int, + dbbusy: null == dbbusy + ? _value.dbbusy + : dbbusy // ignore: cast_nullable_to_non_nullable + as int, + specialDomain: null == specialDomain + ? _value.specialDomain + : specialDomain // ignore: cast_nullable_to_non_nullable + as int, + cacheStale: null == cacheStale + ? _value.cacheStale + : cacheStale // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatusImpl implements _Status { + const _$StatusImpl( + {@JsonKey(name: 'UNKNOWN') required this.unknown, + @JsonKey(name: 'GRAVITY') required this.gravity, + @JsonKey(name: 'FORWARDED') required this.forwarded, + @JsonKey(name: 'CACHE') required this.cache, + @JsonKey(name: 'REGEX') required this.regex, + @JsonKey(name: 'DENYLIST') required this.denylist, + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') required this.externalBlockedIp, + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') required this.externalBlockedNull, + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') required this.externalBlockedNxra, + @JsonKey(name: 'GRAVITY_CNAME') required this.gravityCname, + @JsonKey(name: 'REGEX_CNAME') required this.regexCname, + @JsonKey(name: 'DENYLIST_CNAME') required this.denylistCname, + @JsonKey(name: 'RETRIED') required this.retried, + @JsonKey(name: 'RETRIED_DNSSEC') required this.retriedDnssec, + @JsonKey(name: 'IN_PROGRESS') required this.inProgress, + @JsonKey(name: 'DBBUSY') required this.dbbusy, + @JsonKey(name: 'SPECIAL_DOMAIN') required this.specialDomain, + @JsonKey(name: 'CACHE_STALE') required this.cacheStale}); + + factory _$StatusImpl.fromJson(Map json) => + _$$StatusImplFromJson(json); + + @override + @JsonKey(name: 'UNKNOWN') + final int unknown; + @override + @JsonKey(name: 'GRAVITY') + final int gravity; + @override + @JsonKey(name: 'FORWARDED') + final int forwarded; + @override + @JsonKey(name: 'CACHE') + final int cache; + @override + @JsonKey(name: 'REGEX') + final int regex; + @override + @JsonKey(name: 'DENYLIST') + final int denylist; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') + final int externalBlockedIp; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') + final int externalBlockedNull; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') + final int externalBlockedNxra; + @override + @JsonKey(name: 'GRAVITY_CNAME') + final int gravityCname; + @override + @JsonKey(name: 'REGEX_CNAME') + final int regexCname; + @override + @JsonKey(name: 'DENYLIST_CNAME') + final int denylistCname; + @override + @JsonKey(name: 'RETRIED') + final int retried; + @override + @JsonKey(name: 'RETRIED_DNSSEC') + final int retriedDnssec; + @override + @JsonKey(name: 'IN_PROGRESS') + final int inProgress; + @override + @JsonKey(name: 'DBBUSY') + final int dbbusy; + @override + @JsonKey(name: 'SPECIAL_DOMAIN') + final int specialDomain; + @override + @JsonKey(name: 'CACHE_STALE') + final int cacheStale; + + @override + String toString() { + return 'Status(unknown: $unknown, gravity: $gravity, forwarded: $forwarded, cache: $cache, regex: $regex, denylist: $denylist, externalBlockedIp: $externalBlockedIp, externalBlockedNull: $externalBlockedNull, externalBlockedNxra: $externalBlockedNxra, gravityCname: $gravityCname, regexCname: $regexCname, denylistCname: $denylistCname, retried: $retried, retriedDnssec: $retriedDnssec, inProgress: $inProgress, dbbusy: $dbbusy, specialDomain: $specialDomain, cacheStale: $cacheStale)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatusImpl && + (identical(other.unknown, unknown) || other.unknown == unknown) && + (identical(other.gravity, gravity) || other.gravity == gravity) && + (identical(other.forwarded, forwarded) || + other.forwarded == forwarded) && + (identical(other.cache, cache) || other.cache == cache) && + (identical(other.regex, regex) || other.regex == regex) && + (identical(other.denylist, denylist) || + other.denylist == denylist) && + (identical(other.externalBlockedIp, externalBlockedIp) || + other.externalBlockedIp == externalBlockedIp) && + (identical(other.externalBlockedNull, externalBlockedNull) || + other.externalBlockedNull == externalBlockedNull) && + (identical(other.externalBlockedNxra, externalBlockedNxra) || + other.externalBlockedNxra == externalBlockedNxra) && + (identical(other.gravityCname, gravityCname) || + other.gravityCname == gravityCname) && + (identical(other.regexCname, regexCname) || + other.regexCname == regexCname) && + (identical(other.denylistCname, denylistCname) || + other.denylistCname == denylistCname) && + (identical(other.retried, retried) || other.retried == retried) && + (identical(other.retriedDnssec, retriedDnssec) || + other.retriedDnssec == retriedDnssec) && + (identical(other.inProgress, inProgress) || + other.inProgress == inProgress) && + (identical(other.dbbusy, dbbusy) || other.dbbusy == dbbusy) && + (identical(other.specialDomain, specialDomain) || + other.specialDomain == specialDomain) && + (identical(other.cacheStale, cacheStale) || + other.cacheStale == cacheStale)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + unknown, + gravity, + forwarded, + cache, + regex, + denylist, + externalBlockedIp, + externalBlockedNull, + externalBlockedNxra, + gravityCname, + regexCname, + denylistCname, + retried, + retriedDnssec, + inProgress, + dbbusy, + specialDomain, + cacheStale); + + /// Create a copy of Status + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatusImplCopyWith<_$StatusImpl> get copyWith => + __$$StatusImplCopyWithImpl<_$StatusImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StatusImplToJson( + this, + ); + } +} + +abstract class _Status implements Status { + const factory _Status( + {@JsonKey(name: 'UNKNOWN') required final int unknown, + @JsonKey(name: 'GRAVITY') required final int gravity, + @JsonKey(name: 'FORWARDED') required final int forwarded, + @JsonKey(name: 'CACHE') required final int cache, + @JsonKey(name: 'REGEX') required final int regex, + @JsonKey(name: 'DENYLIST') required final int denylist, + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') + required final int externalBlockedIp, + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') + required final int externalBlockedNull, + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') + required final int externalBlockedNxra, + @JsonKey(name: 'GRAVITY_CNAME') required final int gravityCname, + @JsonKey(name: 'REGEX_CNAME') required final int regexCname, + @JsonKey(name: 'DENYLIST_CNAME') required final int denylistCname, + @JsonKey(name: 'RETRIED') required final int retried, + @JsonKey(name: 'RETRIED_DNSSEC') required final int retriedDnssec, + @JsonKey(name: 'IN_PROGRESS') required final int inProgress, + @JsonKey(name: 'DBBUSY') required final int dbbusy, + @JsonKey(name: 'SPECIAL_DOMAIN') required final int specialDomain, + @JsonKey(name: 'CACHE_STALE') required final int cacheStale}) = + _$StatusImpl; + + factory _Status.fromJson(Map json) = _$StatusImpl.fromJson; + + @override + @JsonKey(name: 'UNKNOWN') + int get unknown; + @override + @JsonKey(name: 'GRAVITY') + int get gravity; + @override + @JsonKey(name: 'FORWARDED') + int get forwarded; + @override + @JsonKey(name: 'CACHE') + int get cache; + @override + @JsonKey(name: 'REGEX') + int get regex; + @override + @JsonKey(name: 'DENYLIST') + int get denylist; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_IP') + int get externalBlockedIp; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_NULL') + int get externalBlockedNull; + @override + @JsonKey(name: 'EXTERNAL_BLOCKED_NXRA') + int get externalBlockedNxra; + @override + @JsonKey(name: 'GRAVITY_CNAME') + int get gravityCname; + @override + @JsonKey(name: 'REGEX_CNAME') + int get regexCname; + @override + @JsonKey(name: 'DENYLIST_CNAME') + int get denylistCname; + @override + @JsonKey(name: 'RETRIED') + int get retried; + @override + @JsonKey(name: 'RETRIED_DNSSEC') + int get retriedDnssec; + @override + @JsonKey(name: 'IN_PROGRESS') + int get inProgress; + @override + @JsonKey(name: 'DBBUSY') + int get dbbusy; + @override + @JsonKey(name: 'SPECIAL_DOMAIN') + int get specialDomain; + @override + @JsonKey(name: 'CACHE_STALE') + int get cacheStale; + + /// Create a copy of Status + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatusImplCopyWith<_$StatusImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Replies _$RepliesFromJson(Map json) { + return _Replies.fromJson(json); +} + +/// @nodoc +mixin _$Replies { + @JsonKey(name: 'UNKNOWN') + int get unknown => throw _privateConstructorUsedError; + @JsonKey(name: 'NODATA') + int get nodata => throw _privateConstructorUsedError; + @JsonKey(name: 'NXDOMAIN') + int get nxdomain => throw _privateConstructorUsedError; + @JsonKey(name: 'CNAME') + int get cname => throw _privateConstructorUsedError; + @JsonKey(name: 'IP') + int get ip => throw _privateConstructorUsedError; + @JsonKey(name: 'DOMAIN') + int get domain => throw _privateConstructorUsedError; + @JsonKey(name: 'RRNAME') + int get rrname => throw _privateConstructorUsedError; + @JsonKey(name: 'SERVFAIL') + int get servfail => throw _privateConstructorUsedError; + @JsonKey(name: 'REFUSED') + int get refused => throw _privateConstructorUsedError; + @JsonKey(name: 'NOTIMP') + int get notimp => throw _privateConstructorUsedError; + @JsonKey(name: 'OTHER') + int get other => throw _privateConstructorUsedError; + @JsonKey(name: 'DNSSEC') + int get dnssec => throw _privateConstructorUsedError; + @JsonKey(name: 'NONE') + int get none => throw _privateConstructorUsedError; + @JsonKey(name: 'BLOB') + int get blob => throw _privateConstructorUsedError; + + /// Serializes this Replies to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Replies + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $RepliesCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RepliesCopyWith<$Res> { + factory $RepliesCopyWith(Replies value, $Res Function(Replies) then) = + _$RepliesCopyWithImpl<$Res, Replies>; + @useResult + $Res call( + {@JsonKey(name: 'UNKNOWN') int unknown, + @JsonKey(name: 'NODATA') int nodata, + @JsonKey(name: 'NXDOMAIN') int nxdomain, + @JsonKey(name: 'CNAME') int cname, + @JsonKey(name: 'IP') int ip, + @JsonKey(name: 'DOMAIN') int domain, + @JsonKey(name: 'RRNAME') int rrname, + @JsonKey(name: 'SERVFAIL') int servfail, + @JsonKey(name: 'REFUSED') int refused, + @JsonKey(name: 'NOTIMP') int notimp, + @JsonKey(name: 'OTHER') int other, + @JsonKey(name: 'DNSSEC') int dnssec, + @JsonKey(name: 'NONE') int none, + @JsonKey(name: 'BLOB') int blob}); +} + +/// @nodoc +class _$RepliesCopyWithImpl<$Res, $Val extends Replies> + implements $RepliesCopyWith<$Res> { + _$RepliesCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Replies + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? unknown = null, + Object? nodata = null, + Object? nxdomain = null, + Object? cname = null, + Object? ip = null, + Object? domain = null, + Object? rrname = null, + Object? servfail = null, + Object? refused = null, + Object? notimp = null, + Object? other = null, + Object? dnssec = null, + Object? none = null, + Object? blob = null, + }) { + return _then(_value.copyWith( + unknown: null == unknown + ? _value.unknown + : unknown // ignore: cast_nullable_to_non_nullable + as int, + nodata: null == nodata + ? _value.nodata + : nodata // ignore: cast_nullable_to_non_nullable + as int, + nxdomain: null == nxdomain + ? _value.nxdomain + : nxdomain // ignore: cast_nullable_to_non_nullable + as int, + cname: null == cname + ? _value.cname + : cname // ignore: cast_nullable_to_non_nullable + as int, + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as int, + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as int, + rrname: null == rrname + ? _value.rrname + : rrname // ignore: cast_nullable_to_non_nullable + as int, + servfail: null == servfail + ? _value.servfail + : servfail // ignore: cast_nullable_to_non_nullable + as int, + refused: null == refused + ? _value.refused + : refused // ignore: cast_nullable_to_non_nullable + as int, + notimp: null == notimp + ? _value.notimp + : notimp // ignore: cast_nullable_to_non_nullable + as int, + other: null == other + ? _value.other + : other // ignore: cast_nullable_to_non_nullable + as int, + dnssec: null == dnssec + ? _value.dnssec + : dnssec // ignore: cast_nullable_to_non_nullable + as int, + none: null == none + ? _value.none + : none // ignore: cast_nullable_to_non_nullable + as int, + blob: null == blob + ? _value.blob + : blob // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$RepliesImplCopyWith<$Res> implements $RepliesCopyWith<$Res> { + factory _$$RepliesImplCopyWith( + _$RepliesImpl value, $Res Function(_$RepliesImpl) then) = + __$$RepliesImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'UNKNOWN') int unknown, + @JsonKey(name: 'NODATA') int nodata, + @JsonKey(name: 'NXDOMAIN') int nxdomain, + @JsonKey(name: 'CNAME') int cname, + @JsonKey(name: 'IP') int ip, + @JsonKey(name: 'DOMAIN') int domain, + @JsonKey(name: 'RRNAME') int rrname, + @JsonKey(name: 'SERVFAIL') int servfail, + @JsonKey(name: 'REFUSED') int refused, + @JsonKey(name: 'NOTIMP') int notimp, + @JsonKey(name: 'OTHER') int other, + @JsonKey(name: 'DNSSEC') int dnssec, + @JsonKey(name: 'NONE') int none, + @JsonKey(name: 'BLOB') int blob}); +} + +/// @nodoc +class __$$RepliesImplCopyWithImpl<$Res> + extends _$RepliesCopyWithImpl<$Res, _$RepliesImpl> + implements _$$RepliesImplCopyWith<$Res> { + __$$RepliesImplCopyWithImpl( + _$RepliesImpl _value, $Res Function(_$RepliesImpl) _then) + : super(_value, _then); + + /// Create a copy of Replies + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? unknown = null, + Object? nodata = null, + Object? nxdomain = null, + Object? cname = null, + Object? ip = null, + Object? domain = null, + Object? rrname = null, + Object? servfail = null, + Object? refused = null, + Object? notimp = null, + Object? other = null, + Object? dnssec = null, + Object? none = null, + Object? blob = null, + }) { + return _then(_$RepliesImpl( + unknown: null == unknown + ? _value.unknown + : unknown // ignore: cast_nullable_to_non_nullable + as int, + nodata: null == nodata + ? _value.nodata + : nodata // ignore: cast_nullable_to_non_nullable + as int, + nxdomain: null == nxdomain + ? _value.nxdomain + : nxdomain // ignore: cast_nullable_to_non_nullable + as int, + cname: null == cname + ? _value.cname + : cname // ignore: cast_nullable_to_non_nullable + as int, + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as int, + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as int, + rrname: null == rrname + ? _value.rrname + : rrname // ignore: cast_nullable_to_non_nullable + as int, + servfail: null == servfail + ? _value.servfail + : servfail // ignore: cast_nullable_to_non_nullable + as int, + refused: null == refused + ? _value.refused + : refused // ignore: cast_nullable_to_non_nullable + as int, + notimp: null == notimp + ? _value.notimp + : notimp // ignore: cast_nullable_to_non_nullable + as int, + other: null == other + ? _value.other + : other // ignore: cast_nullable_to_non_nullable + as int, + dnssec: null == dnssec + ? _value.dnssec + : dnssec // ignore: cast_nullable_to_non_nullable + as int, + none: null == none + ? _value.none + : none // ignore: cast_nullable_to_non_nullable + as int, + blob: null == blob + ? _value.blob + : blob // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$RepliesImpl implements _Replies { + const _$RepliesImpl( + {@JsonKey(name: 'UNKNOWN') required this.unknown, + @JsonKey(name: 'NODATA') required this.nodata, + @JsonKey(name: 'NXDOMAIN') required this.nxdomain, + @JsonKey(name: 'CNAME') required this.cname, + @JsonKey(name: 'IP') required this.ip, + @JsonKey(name: 'DOMAIN') required this.domain, + @JsonKey(name: 'RRNAME') required this.rrname, + @JsonKey(name: 'SERVFAIL') required this.servfail, + @JsonKey(name: 'REFUSED') required this.refused, + @JsonKey(name: 'NOTIMP') required this.notimp, + @JsonKey(name: 'OTHER') required this.other, + @JsonKey(name: 'DNSSEC') required this.dnssec, + @JsonKey(name: 'NONE') required this.none, + @JsonKey(name: 'BLOB') required this.blob}); + + factory _$RepliesImpl.fromJson(Map json) => + _$$RepliesImplFromJson(json); + + @override + @JsonKey(name: 'UNKNOWN') + final int unknown; + @override + @JsonKey(name: 'NODATA') + final int nodata; + @override + @JsonKey(name: 'NXDOMAIN') + final int nxdomain; + @override + @JsonKey(name: 'CNAME') + final int cname; + @override + @JsonKey(name: 'IP') + final int ip; + @override + @JsonKey(name: 'DOMAIN') + final int domain; + @override + @JsonKey(name: 'RRNAME') + final int rrname; + @override + @JsonKey(name: 'SERVFAIL') + final int servfail; + @override + @JsonKey(name: 'REFUSED') + final int refused; + @override + @JsonKey(name: 'NOTIMP') + final int notimp; + @override + @JsonKey(name: 'OTHER') + final int other; + @override + @JsonKey(name: 'DNSSEC') + final int dnssec; + @override + @JsonKey(name: 'NONE') + final int none; + @override + @JsonKey(name: 'BLOB') + final int blob; + + @override + String toString() { + return 'Replies(unknown: $unknown, nodata: $nodata, nxdomain: $nxdomain, cname: $cname, ip: $ip, domain: $domain, rrname: $rrname, servfail: $servfail, refused: $refused, notimp: $notimp, other: $other, dnssec: $dnssec, none: $none, blob: $blob)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RepliesImpl && + (identical(other.unknown, unknown) || other.unknown == unknown) && + (identical(other.nodata, nodata) || other.nodata == nodata) && + (identical(other.nxdomain, nxdomain) || + other.nxdomain == nxdomain) && + (identical(other.cname, cname) || other.cname == cname) && + (identical(other.ip, ip) || other.ip == ip) && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.rrname, rrname) || other.rrname == rrname) && + (identical(other.servfail, servfail) || + other.servfail == servfail) && + (identical(other.refused, refused) || other.refused == refused) && + (identical(other.notimp, notimp) || other.notimp == notimp) && + (identical(other.other, this.other) || other.other == this.other) && + (identical(other.dnssec, dnssec) || other.dnssec == dnssec) && + (identical(other.none, none) || other.none == none) && + (identical(other.blob, blob) || other.blob == blob)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, unknown, nodata, nxdomain, cname, + ip, domain, rrname, servfail, refused, notimp, other, dnssec, none, blob); + + /// Create a copy of Replies + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RepliesImplCopyWith<_$RepliesImpl> get copyWith => + __$$RepliesImplCopyWithImpl<_$RepliesImpl>(this, _$identity); + + @override + Map toJson() { + return _$$RepliesImplToJson( + this, + ); + } +} + +abstract class _Replies implements Replies { + const factory _Replies( + {@JsonKey(name: 'UNKNOWN') required final int unknown, + @JsonKey(name: 'NODATA') required final int nodata, + @JsonKey(name: 'NXDOMAIN') required final int nxdomain, + @JsonKey(name: 'CNAME') required final int cname, + @JsonKey(name: 'IP') required final int ip, + @JsonKey(name: 'DOMAIN') required final int domain, + @JsonKey(name: 'RRNAME') required final int rrname, + @JsonKey(name: 'SERVFAIL') required final int servfail, + @JsonKey(name: 'REFUSED') required final int refused, + @JsonKey(name: 'NOTIMP') required final int notimp, + @JsonKey(name: 'OTHER') required final int other, + @JsonKey(name: 'DNSSEC') required final int dnssec, + @JsonKey(name: 'NONE') required final int none, + @JsonKey(name: 'BLOB') required final int blob}) = _$RepliesImpl; + + factory _Replies.fromJson(Map json) = _$RepliesImpl.fromJson; + + @override + @JsonKey(name: 'UNKNOWN') + int get unknown; + @override + @JsonKey(name: 'NODATA') + int get nodata; + @override + @JsonKey(name: 'NXDOMAIN') + int get nxdomain; + @override + @JsonKey(name: 'CNAME') + int get cname; + @override + @JsonKey(name: 'IP') + int get ip; + @override + @JsonKey(name: 'DOMAIN') + int get domain; + @override + @JsonKey(name: 'RRNAME') + int get rrname; + @override + @JsonKey(name: 'SERVFAIL') + int get servfail; + @override + @JsonKey(name: 'REFUSED') + int get refused; + @override + @JsonKey(name: 'NOTIMP') + int get notimp; + @override + @JsonKey(name: 'OTHER') + int get other; + @override + @JsonKey(name: 'DNSSEC') + int get dnssec; + @override + @JsonKey(name: 'NONE') + int get none; + @override + @JsonKey(name: 'BLOB') + int get blob; + + /// Create a copy of Replies + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RepliesImplCopyWith<_$RepliesImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Clients _$ClientsFromJson(Map json) { + return _Clients.fromJson(json); +} + +/// @nodoc +mixin _$Clients { + int get active => throw _privateConstructorUsedError; + int get total => throw _privateConstructorUsedError; + + /// Serializes this Clients to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ClientsCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ClientsCopyWith<$Res> { + factory $ClientsCopyWith(Clients value, $Res Function(Clients) then) = + _$ClientsCopyWithImpl<$Res, Clients>; + @useResult + $Res call({int active, int total}); +} + +/// @nodoc +class _$ClientsCopyWithImpl<$Res, $Val extends Clients> + implements $ClientsCopyWith<$Res> { + _$ClientsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? active = null, + Object? total = null, + }) { + return _then(_value.copyWith( + active: null == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as int, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ClientsImplCopyWith<$Res> implements $ClientsCopyWith<$Res> { + factory _$$ClientsImplCopyWith( + _$ClientsImpl value, $Res Function(_$ClientsImpl) then) = + __$$ClientsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int active, int total}); +} + +/// @nodoc +class __$$ClientsImplCopyWithImpl<$Res> + extends _$ClientsCopyWithImpl<$Res, _$ClientsImpl> + implements _$$ClientsImplCopyWith<$Res> { + __$$ClientsImplCopyWithImpl( + _$ClientsImpl _value, $Res Function(_$ClientsImpl) _then) + : super(_value, _then); + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? active = null, + Object? total = null, + }) { + return _then(_$ClientsImpl( + active: null == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as int, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ClientsImpl implements _Clients { + const _$ClientsImpl({required this.active, required this.total}); + + factory _$ClientsImpl.fromJson(Map json) => + _$$ClientsImplFromJson(json); + + @override + final int active; + @override + final int total; + + @override + String toString() { + return 'Clients(active: $active, total: $total)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ClientsImpl && + (identical(other.active, active) || other.active == active) && + (identical(other.total, total) || other.total == total)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, active, total); + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ClientsImplCopyWith<_$ClientsImpl> get copyWith => + __$$ClientsImplCopyWithImpl<_$ClientsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ClientsImplToJson( + this, + ); + } +} + +abstract class _Clients implements Clients { + const factory _Clients( + {required final int active, required final int total}) = _$ClientsImpl; + + factory _Clients.fromJson(Map json) = _$ClientsImpl.fromJson; + + @override + int get active; + @override + int get total; + + /// Create a copy of Clients + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ClientsImplCopyWith<_$ClientsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Gravity _$GravityFromJson(Map json) { + return _Gravity.fromJson(json); +} + +/// @nodoc +mixin _$Gravity { + @JsonKey(name: 'domains_being_blocked') + int get domainsBeingBlocked => throw _privateConstructorUsedError; + @JsonKey(name: 'last_update') + int get lastUpdate => throw _privateConstructorUsedError; + + /// Serializes this Gravity to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Gravity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $GravityCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $GravityCopyWith<$Res> { + factory $GravityCopyWith(Gravity value, $Res Function(Gravity) then) = + _$GravityCopyWithImpl<$Res, Gravity>; + @useResult + $Res call( + {@JsonKey(name: 'domains_being_blocked') int domainsBeingBlocked, + @JsonKey(name: 'last_update') int lastUpdate}); +} + +/// @nodoc +class _$GravityCopyWithImpl<$Res, $Val extends Gravity> + implements $GravityCopyWith<$Res> { + _$GravityCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Gravity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domainsBeingBlocked = null, + Object? lastUpdate = null, + }) { + return _then(_value.copyWith( + domainsBeingBlocked: null == domainsBeingBlocked + ? _value.domainsBeingBlocked + : domainsBeingBlocked // ignore: cast_nullable_to_non_nullable + as int, + lastUpdate: null == lastUpdate + ? _value.lastUpdate + : lastUpdate // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$GravityImplCopyWith<$Res> implements $GravityCopyWith<$Res> { + factory _$$GravityImplCopyWith( + _$GravityImpl value, $Res Function(_$GravityImpl) then) = + __$$GravityImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'domains_being_blocked') int domainsBeingBlocked, + @JsonKey(name: 'last_update') int lastUpdate}); +} + +/// @nodoc +class __$$GravityImplCopyWithImpl<$Res> + extends _$GravityCopyWithImpl<$Res, _$GravityImpl> + implements _$$GravityImplCopyWith<$Res> { + __$$GravityImplCopyWithImpl( + _$GravityImpl _value, $Res Function(_$GravityImpl) _then) + : super(_value, _then); + + /// Create a copy of Gravity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domainsBeingBlocked = null, + Object? lastUpdate = null, + }) { + return _then(_$GravityImpl( + domainsBeingBlocked: null == domainsBeingBlocked + ? _value.domainsBeingBlocked + : domainsBeingBlocked // ignore: cast_nullable_to_non_nullable + as int, + lastUpdate: null == lastUpdate + ? _value.lastUpdate + : lastUpdate // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$GravityImpl implements _Gravity { + const _$GravityImpl( + {@JsonKey(name: 'domains_being_blocked') + required this.domainsBeingBlocked, + @JsonKey(name: 'last_update') required this.lastUpdate}); + + factory _$GravityImpl.fromJson(Map json) => + _$$GravityImplFromJson(json); + + @override + @JsonKey(name: 'domains_being_blocked') + final int domainsBeingBlocked; + @override + @JsonKey(name: 'last_update') + final int lastUpdate; + + @override + String toString() { + return 'Gravity(domainsBeingBlocked: $domainsBeingBlocked, lastUpdate: $lastUpdate)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$GravityImpl && + (identical(other.domainsBeingBlocked, domainsBeingBlocked) || + other.domainsBeingBlocked == domainsBeingBlocked) && + (identical(other.lastUpdate, lastUpdate) || + other.lastUpdate == lastUpdate)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, domainsBeingBlocked, lastUpdate); + + /// Create a copy of Gravity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$GravityImplCopyWith<_$GravityImpl> get copyWith => + __$$GravityImplCopyWithImpl<_$GravityImpl>(this, _$identity); + + @override + Map toJson() { + return _$$GravityImplToJson( + this, + ); + } +} + +abstract class _Gravity implements Gravity { + const factory _Gravity( + {@JsonKey(name: 'domains_being_blocked') + required final int domainsBeingBlocked, + @JsonKey(name: 'last_update') required final int lastUpdate}) = + _$GravityImpl; + + factory _Gravity.fromJson(Map json) = _$GravityImpl.fromJson; + + @override + @JsonKey(name: 'domains_being_blocked') + int get domainsBeingBlocked; + @override + @JsonKey(name: 'last_update') + int get lastUpdate; + + /// Create a copy of Gravity + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$GravityImplCopyWith<_$GravityImpl> get copyWith => + throw _privateConstructorUsedError; +} + +StatsTopDomains _$StatsTopDomainsFromJson(Map json) { + return _StatsTopDomains.fromJson(json); +} + +/// @nodoc +mixin _$StatsTopDomains { + List get domains => throw _privateConstructorUsedError; + @JsonKey(name: 'total_queries') + int get totalQueries => throw _privateConstructorUsedError; + @JsonKey(name: 'blocked_queries') + int get blockedQueries => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this StatsTopDomains to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StatsTopDomains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatsTopDomainsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatsTopDomainsCopyWith<$Res> { + factory $StatsTopDomainsCopyWith( + StatsTopDomains value, $Res Function(StatsTopDomains) then) = + _$StatsTopDomainsCopyWithImpl<$Res, StatsTopDomains>; + @useResult + $Res call( + {List domains, + @JsonKey(name: 'total_queries') int totalQueries, + @JsonKey(name: 'blocked_queries') int blockedQueries, + double took}); +} + +/// @nodoc +class _$StatsTopDomainsCopyWithImpl<$Res, $Val extends StatsTopDomains> + implements $StatsTopDomainsCopyWith<$Res> { + _$StatsTopDomainsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StatsTopDomains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? totalQueries = null, + Object? blockedQueries = null, + Object? took = null, + }) { + return _then(_value.copyWith( + domains: null == domains + ? _value.domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + blockedQueries: null == blockedQueries + ? _value.blockedQueries + : blockedQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatsTopDomainsImplCopyWith<$Res> + implements $StatsTopDomainsCopyWith<$Res> { + factory _$$StatsTopDomainsImplCopyWith(_$StatsTopDomainsImpl value, + $Res Function(_$StatsTopDomainsImpl) then) = + __$$StatsTopDomainsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List domains, + @JsonKey(name: 'total_queries') int totalQueries, + @JsonKey(name: 'blocked_queries') int blockedQueries, + double took}); +} + +/// @nodoc +class __$$StatsTopDomainsImplCopyWithImpl<$Res> + extends _$StatsTopDomainsCopyWithImpl<$Res, _$StatsTopDomainsImpl> + implements _$$StatsTopDomainsImplCopyWith<$Res> { + __$$StatsTopDomainsImplCopyWithImpl( + _$StatsTopDomainsImpl _value, $Res Function(_$StatsTopDomainsImpl) _then) + : super(_value, _then); + + /// Create a copy of StatsTopDomains + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domains = null, + Object? totalQueries = null, + Object? blockedQueries = null, + Object? took = null, + }) { + return _then(_$StatsTopDomainsImpl( + domains: null == domains + ? _value._domains + : domains // ignore: cast_nullable_to_non_nullable + as List, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + blockedQueries: null == blockedQueries + ? _value.blockedQueries + : blockedQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatsTopDomainsImpl implements _StatsTopDomains { + const _$StatsTopDomainsImpl( + {required final List domains, + @JsonKey(name: 'total_queries') required this.totalQueries, + @JsonKey(name: 'blocked_queries') required this.blockedQueries, + required this.took}) + : _domains = domains; + + factory _$StatsTopDomainsImpl.fromJson(Map json) => + _$$StatsTopDomainsImplFromJson(json); + + final List _domains; + @override + List get domains { + if (_domains is EqualUnmodifiableListView) return _domains; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_domains); + } + + @override + @JsonKey(name: 'total_queries') + final int totalQueries; + @override + @JsonKey(name: 'blocked_queries') + final int blockedQueries; + @override + final double took; + + @override + String toString() { + return 'StatsTopDomains(domains: $domains, totalQueries: $totalQueries, blockedQueries: $blockedQueries, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatsTopDomainsImpl && + const DeepCollectionEquality().equals(other._domains, _domains) && + (identical(other.totalQueries, totalQueries) || + other.totalQueries == totalQueries) && + (identical(other.blockedQueries, blockedQueries) || + other.blockedQueries == blockedQueries) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_domains), + totalQueries, + blockedQueries, + took); + + /// Create a copy of StatsTopDomains + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatsTopDomainsImplCopyWith<_$StatsTopDomainsImpl> get copyWith => + __$$StatsTopDomainsImplCopyWithImpl<_$StatsTopDomainsImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$StatsTopDomainsImplToJson( + this, + ); + } +} + +abstract class _StatsTopDomains implements StatsTopDomains { + const factory _StatsTopDomains( + {required final List domains, + @JsonKey(name: 'total_queries') required final int totalQueries, + @JsonKey(name: 'blocked_queries') required final int blockedQueries, + required final double took}) = _$StatsTopDomainsImpl; + + factory _StatsTopDomains.fromJson(Map json) = + _$StatsTopDomainsImpl.fromJson; + + @override + List get domains; + @override + @JsonKey(name: 'total_queries') + int get totalQueries; + @override + @JsonKey(name: 'blocked_queries') + int get blockedQueries; + @override + double get took; + + /// Create a copy of StatsTopDomains + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatsTopDomainsImplCopyWith<_$StatsTopDomainsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Domain _$DomainFromJson(Map json) { + return _Domain.fromJson(json); +} + +/// @nodoc +mixin _$Domain { + String get domain => throw _privateConstructorUsedError; + int get count => throw _privateConstructorUsedError; + + /// Serializes this Domain to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DomainCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DomainCopyWith<$Res> { + factory $DomainCopyWith(Domain value, $Res Function(Domain) then) = + _$DomainCopyWithImpl<$Res, Domain>; + @useResult + $Res call({String domain, int count}); +} + +/// @nodoc +class _$DomainCopyWithImpl<$Res, $Val extends Domain> + implements $DomainCopyWith<$Res> { + _$DomainCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? count = null, + }) { + return _then(_value.copyWith( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DomainImplCopyWith<$Res> implements $DomainCopyWith<$Res> { + factory _$$DomainImplCopyWith( + _$DomainImpl value, $Res Function(_$DomainImpl) then) = + __$$DomainImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String domain, int count}); +} + +/// @nodoc +class __$$DomainImplCopyWithImpl<$Res> + extends _$DomainCopyWithImpl<$Res, _$DomainImpl> + implements _$$DomainImplCopyWith<$Res> { + __$$DomainImplCopyWithImpl( + _$DomainImpl _value, $Res Function(_$DomainImpl) _then) + : super(_value, _then); + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? count = null, + }) { + return _then(_$DomainImpl( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DomainImpl implements _Domain { + const _$DomainImpl({required this.domain, required this.count}); + + factory _$DomainImpl.fromJson(Map json) => + _$$DomainImplFromJson(json); + + @override + final String domain; + @override + final int count; + + @override + String toString() { + return 'Domain(domain: $domain, count: $count)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DomainImpl && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.count, count) || other.count == count)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, domain, count); + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DomainImplCopyWith<_$DomainImpl> get copyWith => + __$$DomainImplCopyWithImpl<_$DomainImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DomainImplToJson( + this, + ); + } +} + +abstract class _Domain implements Domain { + const factory _Domain( + {required final String domain, required final int count}) = _$DomainImpl; + + factory _Domain.fromJson(Map json) = _$DomainImpl.fromJson; + + @override + String get domain; + @override + int get count; + + /// Create a copy of Domain + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DomainImplCopyWith<_$DomainImpl> get copyWith => + throw _privateConstructorUsedError; +} + +StatsTopClients _$StatsTopClientsFromJson(Map json) { + return _StatsTopClients.fromJson(json); +} + +/// @nodoc +mixin _$StatsTopClients { + List get clients => throw _privateConstructorUsedError; + @JsonKey(name: 'total_queries') + int get totalQueries => throw _privateConstructorUsedError; + @JsonKey(name: 'blocked_queries') + int get blockedQueries => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this StatsTopClients to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StatsTopClients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatsTopClientsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatsTopClientsCopyWith<$Res> { + factory $StatsTopClientsCopyWith( + StatsTopClients value, $Res Function(StatsTopClients) then) = + _$StatsTopClientsCopyWithImpl<$Res, StatsTopClients>; + @useResult + $Res call( + {List clients, + @JsonKey(name: 'total_queries') int totalQueries, + @JsonKey(name: 'blocked_queries') int blockedQueries, + double took}); +} + +/// @nodoc +class _$StatsTopClientsCopyWithImpl<$Res, $Val extends StatsTopClients> + implements $StatsTopClientsCopyWith<$Res> { + _$StatsTopClientsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StatsTopClients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? clients = null, + Object? totalQueries = null, + Object? blockedQueries = null, + Object? took = null, + }) { + return _then(_value.copyWith( + clients: null == clients + ? _value.clients + : clients // ignore: cast_nullable_to_non_nullable + as List, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + blockedQueries: null == blockedQueries + ? _value.blockedQueries + : blockedQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatsTopClientsImplCopyWith<$Res> + implements $StatsTopClientsCopyWith<$Res> { + factory _$$StatsTopClientsImplCopyWith(_$StatsTopClientsImpl value, + $Res Function(_$StatsTopClientsImpl) then) = + __$$StatsTopClientsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List clients, + @JsonKey(name: 'total_queries') int totalQueries, + @JsonKey(name: 'blocked_queries') int blockedQueries, + double took}); +} + +/// @nodoc +class __$$StatsTopClientsImplCopyWithImpl<$Res> + extends _$StatsTopClientsCopyWithImpl<$Res, _$StatsTopClientsImpl> + implements _$$StatsTopClientsImplCopyWith<$Res> { + __$$StatsTopClientsImplCopyWithImpl( + _$StatsTopClientsImpl _value, $Res Function(_$StatsTopClientsImpl) _then) + : super(_value, _then); + + /// Create a copy of StatsTopClients + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? clients = null, + Object? totalQueries = null, + Object? blockedQueries = null, + Object? took = null, + }) { + return _then(_$StatsTopClientsImpl( + clients: null == clients + ? _value._clients + : clients // ignore: cast_nullable_to_non_nullable + as List, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + blockedQueries: null == blockedQueries + ? _value.blockedQueries + : blockedQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatsTopClientsImpl implements _StatsTopClients { + const _$StatsTopClientsImpl( + {required final List clients, + @JsonKey(name: 'total_queries') required this.totalQueries, + @JsonKey(name: 'blocked_queries') required this.blockedQueries, + required this.took}) + : _clients = clients; + + factory _$StatsTopClientsImpl.fromJson(Map json) => + _$$StatsTopClientsImplFromJson(json); + + final List _clients; + @override + List get clients { + if (_clients is EqualUnmodifiableListView) return _clients; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_clients); + } + + @override + @JsonKey(name: 'total_queries') + final int totalQueries; + @override + @JsonKey(name: 'blocked_queries') + final int blockedQueries; + @override + final double took; + + @override + String toString() { + return 'StatsTopClients(clients: $clients, totalQueries: $totalQueries, blockedQueries: $blockedQueries, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatsTopClientsImpl && + const DeepCollectionEquality().equals(other._clients, _clients) && + (identical(other.totalQueries, totalQueries) || + other.totalQueries == totalQueries) && + (identical(other.blockedQueries, blockedQueries) || + other.blockedQueries == blockedQueries) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_clients), + totalQueries, + blockedQueries, + took); + + /// Create a copy of StatsTopClients + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatsTopClientsImplCopyWith<_$StatsTopClientsImpl> get copyWith => + __$$StatsTopClientsImplCopyWithImpl<_$StatsTopClientsImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$StatsTopClientsImplToJson( + this, + ); + } +} + +abstract class _StatsTopClients implements StatsTopClients { + const factory _StatsTopClients( + {required final List clients, + @JsonKey(name: 'total_queries') required final int totalQueries, + @JsonKey(name: 'blocked_queries') required final int blockedQueries, + required final double took}) = _$StatsTopClientsImpl; + + factory _StatsTopClients.fromJson(Map json) = + _$StatsTopClientsImpl.fromJson; + + @override + List get clients; + @override + @JsonKey(name: 'total_queries') + int get totalQueries; + @override + @JsonKey(name: 'blocked_queries') + int get blockedQueries; + @override + double get took; + + /// Create a copy of StatsTopClients + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatsTopClientsImplCopyWith<_$StatsTopClientsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Client _$ClientFromJson(Map json) { + return _Client.fromJson(json); +} + +/// @nodoc +mixin _$Client { + String get ip => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + int get count => throw _privateConstructorUsedError; + + /// Serializes this Client to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ClientCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ClientCopyWith<$Res> { + factory $ClientCopyWith(Client value, $Res Function(Client) then) = + _$ClientCopyWithImpl<$Res, Client>; + @useResult + $Res call({String ip, String name, int count}); +} + +/// @nodoc +class _$ClientCopyWithImpl<$Res, $Val extends Client> + implements $ClientCopyWith<$Res> { + _$ClientCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = null, + Object? count = null, + }) { + return _then(_value.copyWith( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ClientImplCopyWith<$Res> implements $ClientCopyWith<$Res> { + factory _$$ClientImplCopyWith( + _$ClientImpl value, $Res Function(_$ClientImpl) then) = + __$$ClientImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String ip, String name, int count}); +} + +/// @nodoc +class __$$ClientImplCopyWithImpl<$Res> + extends _$ClientCopyWithImpl<$Res, _$ClientImpl> + implements _$$ClientImplCopyWith<$Res> { + __$$ClientImplCopyWithImpl( + _$ClientImpl _value, $Res Function(_$ClientImpl) _then) + : super(_value, _then); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = null, + Object? count = null, + }) { + return _then(_$ClientImpl( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ClientImpl implements _Client { + const _$ClientImpl( + {required this.ip, required this.name, required this.count}); + + factory _$ClientImpl.fromJson(Map json) => + _$$ClientImplFromJson(json); + + @override + final String ip; + @override + final String name; + @override + final int count; + + @override + String toString() { + return 'Client(ip: $ip, name: $name, count: $count)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ClientImpl && + (identical(other.ip, ip) || other.ip == ip) && + (identical(other.name, name) || other.name == name) && + (identical(other.count, count) || other.count == count)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, ip, name, count); + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + __$$ClientImplCopyWithImpl<_$ClientImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ClientImplToJson( + this, + ); + } +} + +abstract class _Client implements Client { + const factory _Client( + {required final String ip, + required final String name, + required final int count}) = _$ClientImpl; + + factory _Client.fromJson(Map json) = _$ClientImpl.fromJson; + + @override + String get ip; + @override + String get name; + @override + int get count; + + /// Create a copy of Client + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ClientImplCopyWith<_$ClientImpl> get copyWith => + throw _privateConstructorUsedError; +} + +StatsUpstreams _$StatsUpstreamsFromJson(Map json) { + return _StatsUpstreams.fromJson(json); +} + +/// @nodoc +mixin _$StatsUpstreams { + List get upstreams => throw _privateConstructorUsedError; + @JsonKey(name: 'forwarded_queries') + int get forwardedQueries => throw _privateConstructorUsedError; + @JsonKey(name: 'total_queries') + int get totalQueries => throw _privateConstructorUsedError; + double get took => throw _privateConstructorUsedError; + + /// Serializes this StatsUpstreams to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StatsUpstreams + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatsUpstreamsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatsUpstreamsCopyWith<$Res> { + factory $StatsUpstreamsCopyWith( + StatsUpstreams value, $Res Function(StatsUpstreams) then) = + _$StatsUpstreamsCopyWithImpl<$Res, StatsUpstreams>; + @useResult + $Res call( + {List upstreams, + @JsonKey(name: 'forwarded_queries') int forwardedQueries, + @JsonKey(name: 'total_queries') int totalQueries, + double took}); +} + +/// @nodoc +class _$StatsUpstreamsCopyWithImpl<$Res, $Val extends StatsUpstreams> + implements $StatsUpstreamsCopyWith<$Res> { + _$StatsUpstreamsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StatsUpstreams + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? upstreams = null, + Object? forwardedQueries = null, + Object? totalQueries = null, + Object? took = null, + }) { + return _then(_value.copyWith( + upstreams: null == upstreams + ? _value.upstreams + : upstreams // ignore: cast_nullable_to_non_nullable + as List, + forwardedQueries: null == forwardedQueries + ? _value.forwardedQueries + : forwardedQueries // ignore: cast_nullable_to_non_nullable + as int, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatsUpstreamsImplCopyWith<$Res> + implements $StatsUpstreamsCopyWith<$Res> { + factory _$$StatsUpstreamsImplCopyWith(_$StatsUpstreamsImpl value, + $Res Function(_$StatsUpstreamsImpl) then) = + __$$StatsUpstreamsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List upstreams, + @JsonKey(name: 'forwarded_queries') int forwardedQueries, + @JsonKey(name: 'total_queries') int totalQueries, + double took}); +} + +/// @nodoc +class __$$StatsUpstreamsImplCopyWithImpl<$Res> + extends _$StatsUpstreamsCopyWithImpl<$Res, _$StatsUpstreamsImpl> + implements _$$StatsUpstreamsImplCopyWith<$Res> { + __$$StatsUpstreamsImplCopyWithImpl( + _$StatsUpstreamsImpl _value, $Res Function(_$StatsUpstreamsImpl) _then) + : super(_value, _then); + + /// Create a copy of StatsUpstreams + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? upstreams = null, + Object? forwardedQueries = null, + Object? totalQueries = null, + Object? took = null, + }) { + return _then(_$StatsUpstreamsImpl( + upstreams: null == upstreams + ? _value._upstreams + : upstreams // ignore: cast_nullable_to_non_nullable + as List, + forwardedQueries: null == forwardedQueries + ? _value.forwardedQueries + : forwardedQueries // ignore: cast_nullable_to_non_nullable + as int, + totalQueries: null == totalQueries + ? _value.totalQueries + : totalQueries // ignore: cast_nullable_to_non_nullable + as int, + took: null == took + ? _value.took + : took // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatsUpstreamsImpl implements _StatsUpstreams { + const _$StatsUpstreamsImpl( + {required final List upstreams, + @JsonKey(name: 'forwarded_queries') required this.forwardedQueries, + @JsonKey(name: 'total_queries') required this.totalQueries, + required this.took}) + : _upstreams = upstreams; + + factory _$StatsUpstreamsImpl.fromJson(Map json) => + _$$StatsUpstreamsImplFromJson(json); + + final List _upstreams; + @override + List get upstreams { + if (_upstreams is EqualUnmodifiableListView) return _upstreams; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_upstreams); + } + + @override + @JsonKey(name: 'forwarded_queries') + final int forwardedQueries; + @override + @JsonKey(name: 'total_queries') + final int totalQueries; + @override + final double took; + + @override + String toString() { + return 'StatsUpstreams(upstreams: $upstreams, forwardedQueries: $forwardedQueries, totalQueries: $totalQueries, took: $took)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatsUpstreamsImpl && + const DeepCollectionEquality() + .equals(other._upstreams, _upstreams) && + (identical(other.forwardedQueries, forwardedQueries) || + other.forwardedQueries == forwardedQueries) && + (identical(other.totalQueries, totalQueries) || + other.totalQueries == totalQueries) && + (identical(other.took, took) || other.took == took)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_upstreams), + forwardedQueries, + totalQueries, + took); + + /// Create a copy of StatsUpstreams + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatsUpstreamsImplCopyWith<_$StatsUpstreamsImpl> get copyWith => + __$$StatsUpstreamsImplCopyWithImpl<_$StatsUpstreamsImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$StatsUpstreamsImplToJson( + this, + ); + } +} + +abstract class _StatsUpstreams implements StatsUpstreams { + const factory _StatsUpstreams( + {required final List upstreams, + @JsonKey(name: 'forwarded_queries') required final int forwardedQueries, + @JsonKey(name: 'total_queries') required final int totalQueries, + required final double took}) = _$StatsUpstreamsImpl; + + factory _StatsUpstreams.fromJson(Map json) = + _$StatsUpstreamsImpl.fromJson; + + @override + List get upstreams; + @override + @JsonKey(name: 'forwarded_queries') + int get forwardedQueries; + @override + @JsonKey(name: 'total_queries') + int get totalQueries; + @override + double get took; + + /// Create a copy of StatsUpstreams + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatsUpstreamsImplCopyWith<_$StatsUpstreamsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Upstream _$UpstreamFromJson(Map json) { + return _Upstream.fromJson(json); +} + +/// @nodoc +mixin _$Upstream { + String get ip => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + int get port => throw _privateConstructorUsedError; + int get count => throw _privateConstructorUsedError; + Statistics get statistics => throw _privateConstructorUsedError; + + /// Serializes this Upstream to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $UpstreamCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $UpstreamCopyWith<$Res> { + factory $UpstreamCopyWith(Upstream value, $Res Function(Upstream) then) = + _$UpstreamCopyWithImpl<$Res, Upstream>; + @useResult + $Res call( + {String ip, String name, int port, int count, Statistics statistics}); + + $StatisticsCopyWith<$Res> get statistics; +} + +/// @nodoc +class _$UpstreamCopyWithImpl<$Res, $Val extends Upstream> + implements $UpstreamCopyWith<$Res> { + _$UpstreamCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = null, + Object? port = null, + Object? count = null, + Object? statistics = null, + }) { + return _then(_value.copyWith( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + port: null == port + ? _value.port + : port // ignore: cast_nullable_to_non_nullable + as int, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + statistics: null == statistics + ? _value.statistics + : statistics // ignore: cast_nullable_to_non_nullable + as Statistics, + ) as $Val); + } + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StatisticsCopyWith<$Res> get statistics { + return $StatisticsCopyWith<$Res>(_value.statistics, (value) { + return _then(_value.copyWith(statistics: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$UpstreamImplCopyWith<$Res> + implements $UpstreamCopyWith<$Res> { + factory _$$UpstreamImplCopyWith( + _$UpstreamImpl value, $Res Function(_$UpstreamImpl) then) = + __$$UpstreamImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String ip, String name, int port, int count, Statistics statistics}); + + @override + $StatisticsCopyWith<$Res> get statistics; +} + +/// @nodoc +class __$$UpstreamImplCopyWithImpl<$Res> + extends _$UpstreamCopyWithImpl<$Res, _$UpstreamImpl> + implements _$$UpstreamImplCopyWith<$Res> { + __$$UpstreamImplCopyWithImpl( + _$UpstreamImpl _value, $Res Function(_$UpstreamImpl) _then) + : super(_value, _then); + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ip = null, + Object? name = null, + Object? port = null, + Object? count = null, + Object? statistics = null, + }) { + return _then(_$UpstreamImpl( + ip: null == ip + ? _value.ip + : ip // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + port: null == port + ? _value.port + : port // ignore: cast_nullable_to_non_nullable + as int, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + statistics: null == statistics + ? _value.statistics + : statistics // ignore: cast_nullable_to_non_nullable + as Statistics, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$UpstreamImpl implements _Upstream { + const _$UpstreamImpl( + {required this.ip, + required this.name, + required this.port, + required this.count, + required this.statistics}); + + factory _$UpstreamImpl.fromJson(Map json) => + _$$UpstreamImplFromJson(json); + + @override + final String ip; + @override + final String name; + @override + final int port; + @override + final int count; + @override + final Statistics statistics; + + @override + String toString() { + return 'Upstream(ip: $ip, name: $name, port: $port, count: $count, statistics: $statistics)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UpstreamImpl && + (identical(other.ip, ip) || other.ip == ip) && + (identical(other.name, name) || other.name == name) && + (identical(other.port, port) || other.port == port) && + (identical(other.count, count) || other.count == count) && + (identical(other.statistics, statistics) || + other.statistics == statistics)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, ip, name, port, count, statistics); + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$UpstreamImplCopyWith<_$UpstreamImpl> get copyWith => + __$$UpstreamImplCopyWithImpl<_$UpstreamImpl>(this, _$identity); + + @override + Map toJson() { + return _$$UpstreamImplToJson( + this, + ); + } +} + +abstract class _Upstream implements Upstream { + const factory _Upstream( + {required final String ip, + required final String name, + required final int port, + required final int count, + required final Statistics statistics}) = _$UpstreamImpl; + + factory _Upstream.fromJson(Map json) = + _$UpstreamImpl.fromJson; + + @override + String get ip; + @override + String get name; + @override + int get port; + @override + int get count; + @override + Statistics get statistics; + + /// Create a copy of Upstream + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$UpstreamImplCopyWith<_$UpstreamImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Statistics _$StatisticsFromJson(Map json) { + return _Statistics.fromJson(json); +} + +/// @nodoc +mixin _$Statistics { + double get response => throw _privateConstructorUsedError; + double get variance => throw _privateConstructorUsedError; + + /// Serializes this Statistics to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Statistics + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StatisticsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatisticsCopyWith<$Res> { + factory $StatisticsCopyWith( + Statistics value, $Res Function(Statistics) then) = + _$StatisticsCopyWithImpl<$Res, Statistics>; + @useResult + $Res call({double response, double variance}); +} + +/// @nodoc +class _$StatisticsCopyWithImpl<$Res, $Val extends Statistics> + implements $StatisticsCopyWith<$Res> { + _$StatisticsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Statistics + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? response = null, + Object? variance = null, + }) { + return _then(_value.copyWith( + response: null == response + ? _value.response + : response // ignore: cast_nullable_to_non_nullable + as double, + variance: null == variance + ? _value.variance + : variance // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatisticsImplCopyWith<$Res> + implements $StatisticsCopyWith<$Res> { + factory _$$StatisticsImplCopyWith( + _$StatisticsImpl value, $Res Function(_$StatisticsImpl) then) = + __$$StatisticsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({double response, double variance}); +} + +/// @nodoc +class __$$StatisticsImplCopyWithImpl<$Res> + extends _$StatisticsCopyWithImpl<$Res, _$StatisticsImpl> + implements _$$StatisticsImplCopyWith<$Res> { + __$$StatisticsImplCopyWithImpl( + _$StatisticsImpl _value, $Res Function(_$StatisticsImpl) _then) + : super(_value, _then); + + /// Create a copy of Statistics + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? response = null, + Object? variance = null, + }) { + return _then(_$StatisticsImpl( + response: null == response + ? _value.response + : response // ignore: cast_nullable_to_non_nullable + as double, + variance: null == variance + ? _value.variance + : variance // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatisticsImpl implements _Statistics { + const _$StatisticsImpl({required this.response, required this.variance}); + + factory _$StatisticsImpl.fromJson(Map json) => + _$$StatisticsImplFromJson(json); + + @override + final double response; + @override + final double variance; + + @override + String toString() { + return 'Statistics(response: $response, variance: $variance)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatisticsImpl && + (identical(other.response, response) || + other.response == response) && + (identical(other.variance, variance) || + other.variance == variance)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, response, variance); + + /// Create a copy of Statistics + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StatisticsImplCopyWith<_$StatisticsImpl> get copyWith => + __$$StatisticsImplCopyWithImpl<_$StatisticsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StatisticsImplToJson( + this, + ); + } +} + +abstract class _Statistics implements Statistics { + const factory _Statistics( + {required final double response, + required final double variance}) = _$StatisticsImpl; + + factory _Statistics.fromJson(Map json) = + _$StatisticsImpl.fromJson; + + @override + double get response; + @override + double get variance; + + /// Create a copy of Statistics + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StatisticsImplCopyWith<_$StatisticsImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/api/v6/metrics/stats.g.dart b/lib/models/api/v6/metrics/stats.g.dart new file mode 100644 index 00000000..2a3ac113 --- /dev/null +++ b/lib/models/api/v6/metrics/stats.g.dart @@ -0,0 +1,305 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stats.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$StatsSummaryImpl _$$StatsSummaryImplFromJson(Map json) => + _$StatsSummaryImpl( + queries: Queries.fromJson(json['queries'] as Map), + clients: Clients.fromJson(json['clients'] as Map), + gravity: Gravity.fromJson(json['gravity'] as Map), + took: (json['took'] as num).toDouble(), + ); + +Map _$$StatsSummaryImplToJson(_$StatsSummaryImpl instance) => + { + 'queries': instance.queries, + 'clients': instance.clients, + 'gravity': instance.gravity, + 'took': instance.took, + }; + +_$QueriesImpl _$$QueriesImplFromJson(Map json) => + _$QueriesImpl( + total: (json['total'] as num).toInt(), + blocked: (json['blocked'] as num).toInt(), + percentBlocked: (json['percent_blocked'] as num).toDouble(), + uniqueDomains: (json['unique_domains'] as num).toInt(), + forwarded: (json['forwarded'] as num).toInt(), + cached: (json['cached'] as num).toInt(), + types: Types.fromJson(json['types'] as Map), + status: Status.fromJson(json['status'] as Map), + replies: Replies.fromJson(json['replies'] as Map), + ); + +Map _$$QueriesImplToJson(_$QueriesImpl instance) => + { + 'total': instance.total, + 'blocked': instance.blocked, + 'percent_blocked': instance.percentBlocked, + 'unique_domains': instance.uniqueDomains, + 'forwarded': instance.forwarded, + 'cached': instance.cached, + 'types': instance.types, + 'status': instance.status, + 'replies': instance.replies, + }; + +_$TypesImpl _$$TypesImplFromJson(Map json) => _$TypesImpl( + a: (json['A'] as num).toInt(), + aaaa: (json['AAAA'] as num).toInt(), + any: (json['ANY'] as num).toInt(), + srv: (json['SRV'] as num).toInt(), + soa: (json['SOA'] as num).toInt(), + ptr: (json['PTR'] as num).toInt(), + txt: (json['TXT'] as num).toInt(), + naptr: (json['NAPTR'] as num).toInt(), + mx: (json['MX'] as num).toInt(), + ds: (json['DS'] as num).toInt(), + rrsig: (json['RRSIG'] as num).toInt(), + dnskey: (json['DNSKEY'] as num).toInt(), + ns: (json['NS'] as num).toInt(), + svcb: (json['SVCB'] as num).toInt(), + https: (json['HTTPS'] as num).toInt(), + other: (json['OTHER'] as num).toInt(), + ); + +Map _$$TypesImplToJson(_$TypesImpl instance) => + { + 'A': instance.a, + 'AAAA': instance.aaaa, + 'ANY': instance.any, + 'SRV': instance.srv, + 'SOA': instance.soa, + 'PTR': instance.ptr, + 'TXT': instance.txt, + 'NAPTR': instance.naptr, + 'MX': instance.mx, + 'DS': instance.ds, + 'RRSIG': instance.rrsig, + 'DNSKEY': instance.dnskey, + 'NS': instance.ns, + 'SVCB': instance.svcb, + 'HTTPS': instance.https, + 'OTHER': instance.other, + }; + +_$StatusImpl _$$StatusImplFromJson(Map json) => _$StatusImpl( + unknown: (json['UNKNOWN'] as num).toInt(), + gravity: (json['GRAVITY'] as num).toInt(), + forwarded: (json['FORWARDED'] as num).toInt(), + cache: (json['CACHE'] as num).toInt(), + regex: (json['REGEX'] as num).toInt(), + denylist: (json['DENYLIST'] as num).toInt(), + externalBlockedIp: (json['EXTERNAL_BLOCKED_IP'] as num).toInt(), + externalBlockedNull: (json['EXTERNAL_BLOCKED_NULL'] as num).toInt(), + externalBlockedNxra: (json['EXTERNAL_BLOCKED_NXRA'] as num).toInt(), + gravityCname: (json['GRAVITY_CNAME'] as num).toInt(), + regexCname: (json['REGEX_CNAME'] as num).toInt(), + denylistCname: (json['DENYLIST_CNAME'] as num).toInt(), + retried: (json['RETRIED'] as num).toInt(), + retriedDnssec: (json['RETRIED_DNSSEC'] as num).toInt(), + inProgress: (json['IN_PROGRESS'] as num).toInt(), + dbbusy: (json['DBBUSY'] as num).toInt(), + specialDomain: (json['SPECIAL_DOMAIN'] as num).toInt(), + cacheStale: (json['CACHE_STALE'] as num).toInt(), + ); + +Map _$$StatusImplToJson(_$StatusImpl instance) => + { + 'UNKNOWN': instance.unknown, + 'GRAVITY': instance.gravity, + 'FORWARDED': instance.forwarded, + 'CACHE': instance.cache, + 'REGEX': instance.regex, + 'DENYLIST': instance.denylist, + 'EXTERNAL_BLOCKED_IP': instance.externalBlockedIp, + 'EXTERNAL_BLOCKED_NULL': instance.externalBlockedNull, + 'EXTERNAL_BLOCKED_NXRA': instance.externalBlockedNxra, + 'GRAVITY_CNAME': instance.gravityCname, + 'REGEX_CNAME': instance.regexCname, + 'DENYLIST_CNAME': instance.denylistCname, + 'RETRIED': instance.retried, + 'RETRIED_DNSSEC': instance.retriedDnssec, + 'IN_PROGRESS': instance.inProgress, + 'DBBUSY': instance.dbbusy, + 'SPECIAL_DOMAIN': instance.specialDomain, + 'CACHE_STALE': instance.cacheStale, + }; + +_$RepliesImpl _$$RepliesImplFromJson(Map json) => + _$RepliesImpl( + unknown: (json['UNKNOWN'] as num).toInt(), + nodata: (json['NODATA'] as num).toInt(), + nxdomain: (json['NXDOMAIN'] as num).toInt(), + cname: (json['CNAME'] as num).toInt(), + ip: (json['IP'] as num).toInt(), + domain: (json['DOMAIN'] as num).toInt(), + rrname: (json['RRNAME'] as num).toInt(), + servfail: (json['SERVFAIL'] as num).toInt(), + refused: (json['REFUSED'] as num).toInt(), + notimp: (json['NOTIMP'] as num).toInt(), + other: (json['OTHER'] as num).toInt(), + dnssec: (json['DNSSEC'] as num).toInt(), + none: (json['NONE'] as num).toInt(), + blob: (json['BLOB'] as num).toInt(), + ); + +Map _$$RepliesImplToJson(_$RepliesImpl instance) => + { + 'UNKNOWN': instance.unknown, + 'NODATA': instance.nodata, + 'NXDOMAIN': instance.nxdomain, + 'CNAME': instance.cname, + 'IP': instance.ip, + 'DOMAIN': instance.domain, + 'RRNAME': instance.rrname, + 'SERVFAIL': instance.servfail, + 'REFUSED': instance.refused, + 'NOTIMP': instance.notimp, + 'OTHER': instance.other, + 'DNSSEC': instance.dnssec, + 'NONE': instance.none, + 'BLOB': instance.blob, + }; + +_$ClientsImpl _$$ClientsImplFromJson(Map json) => + _$ClientsImpl( + active: (json['active'] as num).toInt(), + total: (json['total'] as num).toInt(), + ); + +Map _$$ClientsImplToJson(_$ClientsImpl instance) => + { + 'active': instance.active, + 'total': instance.total, + }; + +_$GravityImpl _$$GravityImplFromJson(Map json) => + _$GravityImpl( + domainsBeingBlocked: (json['domains_being_blocked'] as num).toInt(), + lastUpdate: (json['last_update'] as num).toInt(), + ); + +Map _$$GravityImplToJson(_$GravityImpl instance) => + { + 'domains_being_blocked': instance.domainsBeingBlocked, + 'last_update': instance.lastUpdate, + }; + +_$StatsTopDomainsImpl _$$StatsTopDomainsImplFromJson( + Map json) => + _$StatsTopDomainsImpl( + domains: (json['domains'] as List) + .map((e) => Domain.fromJson(e as Map)) + .toList(), + totalQueries: (json['total_queries'] as num).toInt(), + blockedQueries: (json['blocked_queries'] as num).toInt(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$StatsTopDomainsImplToJson( + _$StatsTopDomainsImpl instance) => + { + 'domains': instance.domains, + 'total_queries': instance.totalQueries, + 'blocked_queries': instance.blockedQueries, + 'took': instance.took, + }; + +_$DomainImpl _$$DomainImplFromJson(Map json) => _$DomainImpl( + domain: json['domain'] as String, + count: (json['count'] as num).toInt(), + ); + +Map _$$DomainImplToJson(_$DomainImpl instance) => + { + 'domain': instance.domain, + 'count': instance.count, + }; + +_$StatsTopClientsImpl _$$StatsTopClientsImplFromJson( + Map json) => + _$StatsTopClientsImpl( + clients: (json['clients'] as List) + .map((e) => Client.fromJson(e as Map)) + .toList(), + totalQueries: (json['total_queries'] as num).toInt(), + blockedQueries: (json['blocked_queries'] as num).toInt(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$StatsTopClientsImplToJson( + _$StatsTopClientsImpl instance) => + { + 'clients': instance.clients, + 'total_queries': instance.totalQueries, + 'blocked_queries': instance.blockedQueries, + 'took': instance.took, + }; + +_$ClientImpl _$$ClientImplFromJson(Map json) => _$ClientImpl( + ip: json['ip'] as String, + name: json['name'] as String, + count: (json['count'] as num).toInt(), + ); + +Map _$$ClientImplToJson(_$ClientImpl instance) => + { + 'ip': instance.ip, + 'name': instance.name, + 'count': instance.count, + }; + +_$StatsUpstreamsImpl _$$StatsUpstreamsImplFromJson(Map json) => + _$StatsUpstreamsImpl( + upstreams: (json['upstreams'] as List) + .map((e) => Upstream.fromJson(e as Map)) + .toList(), + forwardedQueries: (json['forwarded_queries'] as num).toInt(), + totalQueries: (json['total_queries'] as num).toInt(), + took: (json['took'] as num).toDouble(), + ); + +Map _$$StatsUpstreamsImplToJson( + _$StatsUpstreamsImpl instance) => + { + 'upstreams': instance.upstreams, + 'forwarded_queries': instance.forwardedQueries, + 'total_queries': instance.totalQueries, + 'took': instance.took, + }; + +_$UpstreamImpl _$$UpstreamImplFromJson(Map json) => + _$UpstreamImpl( + ip: json['ip'] as String, + name: json['name'] as String, + port: (json['port'] as num).toInt(), + count: (json['count'] as num).toInt(), + statistics: + Statistics.fromJson(json['statistics'] as Map), + ); + +Map _$$UpstreamImplToJson(_$UpstreamImpl instance) => + { + 'ip': instance.ip, + 'name': instance.name, + 'port': instance.port, + 'count': instance.count, + 'statistics': instance.statistics, + }; + +_$StatisticsImpl _$$StatisticsImplFromJson(Map json) => + _$StatisticsImpl( + response: (json['response'] as num).toDouble(), + variance: (json['variance'] as num).toDouble(), + ); + +Map _$$StatisticsImplToJson(_$StatisticsImpl instance) => + { + 'response': instance.response, + 'variance': instance.variance, + }; diff --git a/lib/models/gateways.dart b/lib/models/gateways.dart index a3e5f430..e039f700 100644 --- a/lib/models/gateways.dart +++ b/lib/models/gateways.dart @@ -1,3 +1,4 @@ +import 'package:pi_hole_client/models/api/v6/domains/domains.dart' as v6; import 'package:pi_hole_client/models/app_log.dart'; import 'package:pi_hole_client/models/domain.dart'; import 'package:pi_hole_client/models/log.dart'; @@ -17,19 +18,19 @@ enum APiResponseType { /// A response object for the login query. /// -/// When Successful [result], [status] and [phpSessId] are returned. +/// When Successful [result], [status] and [sid] are returned. /// When error, [result] and [log] are returned. class LoginQueryResponse { final APiResponseType result; final AppLog? log; final String? status; - final String? phpSessId; + final String? sid; LoginQueryResponse({ required this.result, this.log, this.status, - this.phpSessId, + this.sid, }); } @@ -99,6 +100,31 @@ class DomainResult { ); } + /// Converts a [AddDomains] object to a [DomainResult] object. + /// + /// Warning: This method assumes that the [AddDomains] object has exactly 1 domain. + factory DomainResult.fromV6(v6.AddDomains domains) { + if (domains.domains.length != 1) { + throw ArgumentError('domains must have exactly 1 item'); + } + + if (domains.processed.success.isNotEmpty) { + return DomainResult( + success: true, + message: 'Added ${domains.processed.success[0].item}', + ); + } + + if (domains.processed.errors.isNotEmpty) { + return DomainResult( + success: false, + message: domains.processed.errors[0].error, + ); + } + + throw ArgumentError('domains must have either success or error'); + } + Map toJson() { return { 'success': success, @@ -131,6 +157,43 @@ class DomainListResult { required this.blacklist, required this.blacklistRegex, }); + + factory DomainListResult.fromV6(v6.Domains domains) { + final types = { + "allow_exact": 0, + 'deny_exact': 1, + 'allow_regex': 2, + 'deny_regex': 3, + }; + + List v6DomainsToDomainList( + v6.Domains domains, String type, String kind) { + return domains.domains + .where((domain) => domain.type == type && domain.kind == kind) + .toList() + .map((domain) { + return Domain( + id: domain.id, + type: types['${domain.type}_${domain.kind}']!, + domain: domain.domain, + enabled: domain.enabled ? 1 : 0, + dateAdded: + DateTime.fromMillisecondsSinceEpoch(domain.dateAdded * 1000), + dateModified: + DateTime.fromMillisecondsSinceEpoch(domain.dateModified * 1000), + comment: domain.comment, + groups: domain.groups, + ); + }).toList(); + } + + return DomainListResult( + whitelist: v6DomainsToDomainList(domains, 'allow', 'exact'), + whitelistRegex: v6DomainsToDomainList(domains, 'allow', 'regex'), + blacklist: v6DomainsToDomainList(domains, 'deny', 'exact'), + blacklistRegex: v6DomainsToDomainList(domains, 'deny', 'regex'), + ); + } } class GetDomainLists { diff --git a/lib/models/log.dart b/lib/models/log.dart index ac79542c..4ea2b9ce 100644 --- a/lib/models/log.dart +++ b/lib/models/log.dart @@ -1,3 +1,6 @@ +import 'package:pi_hole_client/constants/query_types.dart'; +import 'package:pi_hole_client/models/api/v6/metrics/query.dart'; + class Log { final DateTime dateTime; final String type; @@ -50,4 +53,34 @@ class Log { ? data[10] : null : null); + + factory Log.fromV6(Query query) { + return Log( + //double to int + dateTime: + DateTime.fromMillisecondsSinceEpoch((query.time * 1000).toInt()), + type: query.type, + url: query.domain, + device: query.client.name ?? query.client.ip, + status: queryStatusesV6 + .firstWhere((status) => status.key == query.status) + .index + .toString(), // TODO: Use query.status + replyType: query.reply.type, + replyTime: BigInt.from(query.reply.time * 1000 * 10), + answeredBy: query.upstream, + ); + } + + //toJson + Map toJson() => { + 'dateTime': dateTime.toIso8601String(), + 'type': type, + 'url': url, + 'device': device, + 'status': status, + 'replyType': replyType, + 'replyTime': replyTime.toString(), + 'answeredBy': answeredBy, + }; } diff --git a/lib/models/overtime_data.dart b/lib/models/overtime_data.dart index 88138a5e..f5d1c06f 100644 --- a/lib/models/overtime_data.dart +++ b/lib/models/overtime_data.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:pi_hole_client/functions/colors.dart'; +import 'package:pi_hole_client/models/api/v6/metrics/history.dart'; OverTimeData overTimeDataFromJson(String str) => OverTimeData.fromJson(json.decode(str)); @@ -50,6 +51,62 @@ class OverTimeData { "over_time": Map.from(overTime).map((k, v) => MapEntry(k, List.from(v.map((x) => x)))), }; + + factory OverTimeData.fromV6(History history, HistoryClients historyClients) { + final domainsOverTime = history.history.isNotEmpty + ? Map.fromEntries( + history.history.map( + (entry) => MapEntry( + entry.timestamp.toInt().toString(), entry.total), + ), + ) + : {}; + + final adsOverTime = history.history.isNotEmpty + ? Map.fromEntries( + history.history.map( + (entry) => MapEntry( + entry.timestamp.toInt().toString(), entry.blocked), + ), + ) + : {}; + + final clients = historyClients.clients.isNotEmpty + ? historyClients.clients.entries.map((entry) { + final ip = entry.key; + final name = entry.value.name ?? ip; + + return Client( + name: name, + ip: ip, + color: generateRandomColor(), + ); + }).toList() + : []; + + final overTimes = historyClients.history.isNotEmpty + ? Map.fromEntries( + historyClients.history.map((entry) { + final timestamp = entry.timestamp.toInt().toString(); + + // Sort the data by clients' order + final sortedData = clients.map((client) { + final ip = client.ip; + return entry.data[ip] ?? 0; // Default to 0 if not found + }).toList(); + + return MapEntry>(timestamp, sortedData); + }), + ) + : >{}; + + return OverTimeData( + domainsOverTime: domainsOverTime, + adsOverTime: adsOverTime, + clients: clients, + overTime: overTimes, + ); + } } class Client { diff --git a/lib/models/query_status.dart b/lib/models/query_status.dart new file mode 100644 index 00000000..648e3aff --- /dev/null +++ b/lib/models/query_status.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class QueryStatus { + final int index; + final String key; + final String text; + final Color color; + final IconData icon; + final bool isShown; + + const QueryStatus({ + required this.index, + required this.key, + required this.text, + required this.color, + required this.icon, + this.isShown = true, + }); +} diff --git a/lib/models/realtime_status.dart b/lib/models/realtime_status.dart index 33228c4a..1d1f3645 100644 --- a/lib/models/realtime_status.dart +++ b/lib/models/realtime_status.dart @@ -1,6 +1,9 @@ import 'dart:convert'; import 'package:pi_hole_client/functions/charts_data_functions.dart'; +import 'package:pi_hole_client/models/api/v6/dns/dns.dart'; +import 'package:pi_hole_client/models/api/v6/flt/ftl.dart'; +import 'package:pi_hole_client/models/api/v6/metrics/stats.dart'; RealtimeStatus realtimeStatusFromJson(String str) => RealtimeStatus.fromJson(json.decode(str)); @@ -126,4 +129,116 @@ class RealtimeStatus { ? sortValues(removeZeroValues(Map.from(json["forward_destinations"]).map((k, v) => MapEntry(k, v.toDouble())))) : {}, queryTypes: ((json["querytypes"].runtimeType != List) && (json["querytypes"] != null)) ? sortValues(removeZeroValues(Map.from(json["querytypes"]).map((k, v) => MapEntry(k, v.toDouble())))) : {}); + + factory RealtimeStatus.fromV6( + StatsSummary summary, + InfoFtl infoFtl, + Blocking blocking, + StatsTopDomains topPermittedDomains, + StatsTopDomains topBlockedDomains, + StatsTopClients topClients, + StatsTopClients topClientsBlocked, + StatsUpstreams upstreams, + ) { + // Calculate the percentage of each query type + final totalQueryTypes = + summary.queries.types.toJson().values.reduce((a, b) => a + b); + final queryTypes = sortValues(removeZeroValues(summary.queries.types + .toJson() + .map((key, value) => MapEntry(key, (value / totalQueryTypes) * 100)))); + + final topQueries = topPermittedDomains.domains.isNotEmpty + ? Map.fromEntries( + topPermittedDomains.domains.map( + (domain) => MapEntry(domain.domain, domain.count)), + ) + : {}; + + final topAds = topBlockedDomains.domains.isNotEmpty + ? Map.fromEntries( + topBlockedDomains.domains.map( + (domain) => MapEntry(domain.domain, domain.count)), + ) + : {}; + + final topSources = topClients.clients.isNotEmpty + ? Map.fromEntries( + topClients.clients.map( + (client) => MapEntry( + client.name.isNotEmpty + ? '${client.name}|${client.ip}' + : client.ip, + client.count), + ), + ) + : {}; + + final topSourcesBlocked = topClientsBlocked.clients.isNotEmpty + ? Map.fromEntries( + topClientsBlocked.clients.map( + (client) => MapEntry( + client.name.isNotEmpty + ? '${client.name}|${client.ip}' + : client.ip, + client.count), + ), + ) + : {}; + + final totalForwardDestinations = upstreams.upstreams.isNotEmpty + ? upstreams.upstreams + .map((upstream) => upstream.count) + .reduce((a, b) => a + b) + : 0; + final forwardDestinations = upstreams.upstreams.isNotEmpty + ? sortValues(removeZeroValues(Map.fromEntries( + upstreams.upstreams.map( + (upstream) => MapEntry( + upstream.port == -1 + ? '${upstream.name}|${upstream.ip}' + : '${upstream.name}#${upstream.port}|${upstream.ip}#${upstream.port}', + upstream.count / totalForwardDestinations * 100), + ), + ))) + : {}; + + // memo: + // dnsQueriesAllTypes: v5 same as dnsQueriesToday number + // dnsQueriesAllReplies: v5 same as dnsQueriesToday number + return RealtimeStatus( + domainsBeingBlocked: summary.gravity.domainsBeingBlocked, + dnsQueriesToday: summary.queries.total, + adsBlockedToday: summary.queries.blocked, + adsPercentageToday: summary.queries.percentBlocked, + uniqueDomains: summary.queries.uniqueDomains, + queriesForwarded: summary.queries.forwarded, + queriesCached: summary.queries.cached, + clientsEverSeen: summary.clients.total, + uniqueClients: summary.clients.active, + dnsQueriesAllTypes: summary.queries.total, + replyUnknown: summary.queries.replies.unknown, + replyNodata: summary.queries.replies.nodata, + replyNxdomain: summary.queries.replies.nxdomain, + replyCname: summary.queries.replies.cname, + replyIp: summary.queries.replies.ip, + replyDomain: summary.queries.replies.domain, + replyRrname: summary.queries.replies.rrname, + replyServfail: summary.queries.replies.servfail, + replyRefused: summary.queries.replies.refused, + replyNotimp: summary.queries.replies.notimp, + replyOther: summary.queries.replies.other, + replyDnssec: summary.queries.replies.dnssec, + replyNone: summary.queries.replies.none, + replyBlob: summary.queries.replies.blob, + dnsQueriesAllReplies: summary.queries.total, + privacyLevel: infoFtl.ftl.privacyLevel, + status: blocking.blocking, + topQueries: topQueries, + topAds: topAds, + topSources: topSources, + topSourcesBlocked: topSourcesBlocked, + forwardDestinations: forwardDestinations, + queryTypes: queryTypes, + ); + } } diff --git a/lib/models/repository/database.dart b/lib/models/repository/database.dart index 08d41897..4caa844d 100644 --- a/lib/models/repository/database.dart +++ b/lib/models/repository/database.dart @@ -28,6 +28,7 @@ class ServerDbData { final String apiVersion; final String? basicAuthUser; final String? basicAuthPassword; + final String? sid; ServerDbData({ required this.address, @@ -37,6 +38,7 @@ class ServerDbData { required this.apiVersion, required this.basicAuthUser, required this.basicAuthPassword, + required this.sid, }); factory ServerDbData.fromMap(Map map) { @@ -48,6 +50,7 @@ class ServerDbData { apiVersion: map['apiVersion'] as String, basicAuthUser: map['basicAuthUser'] as String?, basicAuthPassword: map['basicAuthPassword'] as String?, + sid: map['sid'] as String?, ); } @@ -56,6 +59,7 @@ class ServerDbData { String? token, String? basicAuthUser, String? basicAuthPassword, + String? sid, ) { return ServerDbData( address: instance.address, @@ -65,6 +69,7 @@ class ServerDbData { apiVersion: instance.apiVersion, basicAuthUser: basicAuthUser, basicAuthPassword: basicAuthPassword, + sid: sid, ); } @@ -77,6 +82,7 @@ class ServerDbData { "apiVersion": apiVersion, "basicAuthUser": basicAuthUser, "basicAuthPassword": basicAuthPassword, + "sid": sid, }; } } diff --git a/lib/models/server.dart b/lib/models/server.dart index 26999084..3070cacc 100644 --- a/lib/models/server.dart +++ b/lib/models/server.dart @@ -1,3 +1,6 @@ +import 'package:pi_hole_client/repository/secure_storage.dart'; +import 'package:pi_hole_client/services/session_manager.dart'; + /// Model class for Pi-hole server /// /// This class is used to store information about a Pi-hole server. @@ -8,7 +11,7 @@ class Server { /// Pi-hole server alias final String alias; - /// Pi-hole server API token + /// Pi-hole server API token (Use only v5) final String? token; /// Whether this server is the default server @@ -20,12 +23,15 @@ class Server { /// Pi-hole API version final String apiVersion; - /// Basic authentication username + /// Basic authentication username (Use only v5) final String? basicAuthUser; - /// Basic authentication password + /// Basic authentication password (Use only v5) final String? basicAuthPassword; + /// Session manager (Use only v5) + final SessionManager sm; + Server({ required this.address, required this.alias, @@ -35,7 +41,8 @@ class Server { required this.apiVersion, this.basicAuthUser, this.basicAuthPassword, - }); + SessionManager? sm, + }) : sm = sm ?? SessionManager(SecureStorageRepository(), address); Server copyWith({ String? address, @@ -46,6 +53,7 @@ class Server { String? apiVersion, String? basicAuthUser, String? basicAuthPassword, + SessionManager? sm, }) { return Server( address: address ?? this.address, @@ -56,6 +64,7 @@ class Server { apiVersion: apiVersion ?? this.apiVersion, basicAuthUser: basicAuthUser ?? this.basicAuthUser, basicAuthPassword: basicAuthPassword ?? this.basicAuthPassword, + sm: sm ?? this.sm, ); } } diff --git a/lib/providers/app_config_provider.dart b/lib/providers/app_config_provider.dart index 131acc28..2b9cac88 100644 --- a/lib/providers/app_config_provider.dart +++ b/lib/providers/app_config_provider.dart @@ -13,12 +13,12 @@ class AppConfigProvider with ChangeNotifier { AndroidDeviceInfo? _androidDeviceInfo; IosDeviceInfo? _iosDeviceInfo; PackageInfo? _appInfo; - int? _autoRefreshTime = 2; + int? _autoRefreshTime = 2; // secounds int _selectedTheme = 0; int _overrideSslCheck = 0; int _oneColumnLegend = 0; int _reducedDataCharts = 0; - double _logsPerQuery = 2; + double _logsPerQuery = 2; //hours String? _passCode; bool _biometricsSupport = false; int _useBiometrics = 0; diff --git a/lib/providers/filters_provider.dart b/lib/providers/filters_provider.dart index e51eb534..dd8669c2 100644 --- a/lib/providers/filters_provider.dart +++ b/lib/providers/filters_provider.dart @@ -1,119 +1,142 @@ +import 'package:pi_hole_client/providers/filters_provider/filters_interface.dart'; +import 'package:pi_hole_client/providers/filters_provider/filters_v5.dart'; +import 'package:pi_hole_client/providers/filters_provider/filters_v6.dart'; +import 'package:pi_hole_client/providers/servers_provider.dart'; import 'package:pi_hole_client/screens/logs/logs_filters_modal.dart'; import 'package:flutter/material.dart'; -class FiltersProvider with ChangeNotifier { - List _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; - DateTime? _startTime; - DateTime? _endTime; - List _totalClients = []; - List _selectedClients = []; - String? _selectedDomain; - RequestStatus _requestStatus = RequestStatus.all; +class FiltersProvider with ChangeNotifier implements Filters { + Filters? _filters; + FiltersProvider({ServersProvider? serversProvider}) { + // Default filtersProvider is FiltersProviderV5. + // Update filtersPorviders version when update ServersProvider. + final version = serversProvider?.selectedServer?.apiVersion ?? "v5"; + _updateFiltersVersion(version); + } + + update(ServersProvider? provider) { + final version = provider?.selectedServer?.apiVersion ?? "v5"; + _updateFiltersVersion(version); + } + + _updateFiltersVersion(String version) { + _filters = version == "v5" ? FiltersV5() : FiltersV6(); + } + + @override + List get statusAllowedAndRetried { + return _filters!.statusAllowedAndRetried; + } + + @override + List get defaultSelected { + return _filters!.defaultSelected; + } + + @override List get statusSelected { - return _statusSelected; + return _filters!.statusSelected; + } + + @override + String get statusSelectedString { + return _filters!.statusSelectedString; } + @override DateTime? get startTime { - return _startTime; + return _filters!.startTime; } + @override DateTime? get endTime { - return _endTime; + return _filters!.endTime; } + @override List get totalClients { - return _totalClients; + return _filters!.totalClients; } + @override List get selectedClients { - return _selectedClients; + return _filters!.selectedClients; } + @override String? get selectedDomain { - return _selectedDomain; + return _filters!.selectedDomain; } + @override RequestStatus get requestStatus { - return _requestStatus; + return _filters!.requestStatus; } + @override void setStatusSelected(List values) { - _statusSelected = values; - if (values == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) { - _requestStatus = RequestStatus.all; - } else if (values == [2, 3]) { - _requestStatus = RequestStatus.allowed; - } else if (values == [1, 4, 5, 6, 7, 8, 9, 10, 11, 14]) { - _requestStatus = RequestStatus.blocked; - } + _filters!.setStatusSelected(values); notifyListeners(); } + @override void setStartTime(DateTime value) { - _startTime = value; + _filters!.setStartTime(value); notifyListeners(); } + @override void setEndTime(DateTime value) { - _endTime = value; + _filters!.setEndTime(value); notifyListeners(); } + @override void resetFilters() { - _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; - _requestStatus = RequestStatus.all; - _startTime = null; - _endTime = null; - _selectedClients = _totalClients; - _selectedDomain = null; + _filters!.resetFilters(); notifyListeners(); } + @override void resetTime() { - _startTime = null; - _endTime = null; + _filters!.resetTime(); notifyListeners(); } + @override void resetStatus() { - _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; - _requestStatus = RequestStatus.all; + _filters!.resetStatus(); notifyListeners(); } + @override void setClients(List clients) { - if (_totalClients.isEmpty) { - _selectedClients = clients; - } - _totalClients = clients; + _filters!.setClients(clients); notifyListeners(); } + @override void setSelectedClients(List selectedClients) { - _selectedClients = selectedClients; + _filters!.setSelectedClients(selectedClients); notifyListeners(); } + @override void setSelectedDomain(String? domain) { - _selectedDomain = domain; + _filters!.setSelectedDomain(domain); notifyListeners(); } + @override void resetClients() { - _selectedClients = _totalClients; + _filters!.resetClients(); notifyListeners(); } + @override void setRequestStatus(RequestStatus status) { - _requestStatus = status; - if (status == RequestStatus.all) { - _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; - } else if (status == RequestStatus.allowed) { - _statusSelected = [2, 3]; - } else if (status == RequestStatus.blocked) { - _statusSelected = [1, 4, 5, 6, 7, 8, 9, 10, 11]; - } + _filters!.setRequestStatus(status); notifyListeners(); } } diff --git a/lib/providers/filters_provider/filters_interface.dart b/lib/providers/filters_provider/filters_interface.dart new file mode 100644 index 00000000..3a14aa03 --- /dev/null +++ b/lib/providers/filters_provider/filters_interface.dart @@ -0,0 +1,45 @@ +import 'package:pi_hole_client/screens/logs/logs_filters_modal.dart'; + +abstract interface class Filters { + List get statusAllowedAndRetried; + + List get defaultSelected; + + List get statusSelected; + + String get statusSelectedString; + + DateTime? get startTime; + + DateTime? get endTime; + + List get totalClients; + + List get selectedClients; + + String? get selectedDomain; + + RequestStatus get requestStatus; + + void setStatusSelected(List values); + + void setStartTime(DateTime value); + + void setEndTime(DateTime value); + + void resetFilters(); + + void resetTime(); + + void resetStatus(); + + void setClients(List clients); + + void setSelectedClients(List selectedClients); + + void setSelectedDomain(String? domain); + + void resetClients(); + + void setRequestStatus(RequestStatus status); +} diff --git a/lib/providers/filters_provider/filters_v5.dart b/lib/providers/filters_provider/filters_v5.dart new file mode 100644 index 00000000..65fefdb5 --- /dev/null +++ b/lib/providers/filters_provider/filters_v5.dart @@ -0,0 +1,152 @@ +import 'package:pi_hole_client/constants/query_types.dart'; +import 'package:pi_hole_client/providers/filters_provider/filters_interface.dart'; +import 'package:pi_hole_client/screens/logs/logs_filters_modal.dart'; + +class FiltersV5 implements Filters { + final List _statusAll = + queryStatusesV5.where((e) => e.isShown).map((e) => e.index).toList(); + final List _statusAllowed = [2, 3]; + final List _statusBlocked = [1, 4, 5, 6, 7, 8, 9, 10, 11]; + List _statusSelected; + DateTime? _startTime; + DateTime? _endTime; + List _totalClients = []; + List _selectedClients = []; + String? _selectedDomain; + RequestStatus _requestStatus = RequestStatus.all; + + FiltersV5() : _statusSelected = [] { + _statusSelected = _statusAll; + } + + @override + List get statusAllowedAndRetried { + return [2, 3, 12, 13, 14]; + } + + @override + List get defaultSelected { + return _statusAll; + } + + @override + List get statusSelected { + return _statusSelected; + } + + @override + String get statusSelectedString { + return queryStatusesV5 + .firstWhere((e) => e.index == _statusSelected[0]) + .text; + } + + @override + DateTime? get startTime { + return _startTime; + } + + @override + DateTime? get endTime { + return _endTime; + } + + @override + List get totalClients { + return _totalClients; + } + + @override + List get selectedClients { + return _selectedClients; + } + + @override + String? get selectedDomain { + return _selectedDomain; + } + + @override + RequestStatus get requestStatus { + return _requestStatus; + } + + @override + void setStatusSelected(List values) { + _statusSelected = values; + if (values == _statusAll) { + _requestStatus = RequestStatus.all; + } else if (values == _statusAllowed) { + _requestStatus = RequestStatus.allowed; + } else if (values == _statusBlocked) { + _requestStatus = RequestStatus.blocked; + } + } + + @override + void setStartTime(DateTime value) { + _startTime = value; + } + + @override + void setEndTime(DateTime value) { + _endTime = value; + } + + @override + void resetFilters() { + _statusSelected = _statusAll; + _requestStatus = RequestStatus.all; + _startTime = null; + _endTime = null; + _selectedClients = _totalClients; + _selectedDomain = null; + } + + @override + void resetTime() { + _startTime = null; + _endTime = null; + } + + @override + void resetStatus() { + _statusSelected = _statusAll; + _requestStatus = RequestStatus.all; + } + + @override + void setClients(List clients) { + if (_totalClients.isEmpty) { + _selectedClients = clients; + } + _totalClients = clients; + } + + @override + void setSelectedClients(List selectedClients) { + _selectedClients = selectedClients; + } + + @override + void setSelectedDomain(String? domain) { + _selectedDomain = domain; + } + + @override + void resetClients() { + _selectedClients = _totalClients; + } + + @override + void setRequestStatus(RequestStatus status) { + _requestStatus = status; + if (status == RequestStatus.all) { + _statusSelected = _statusAll; + } else if (status == RequestStatus.allowed) { + _statusSelected = _statusAllowed; + } else if (status == RequestStatus.blocked) { + _statusSelected = _statusBlocked; + } + } +} diff --git a/lib/providers/filters_provider/filters_v6.dart b/lib/providers/filters_provider/filters_v6.dart new file mode 100644 index 00000000..cf9463d1 --- /dev/null +++ b/lib/providers/filters_provider/filters_v6.dart @@ -0,0 +1,152 @@ +import 'package:pi_hole_client/constants/query_types.dart'; +import 'package:pi_hole_client/providers/filters_provider/filters_interface.dart'; +import 'package:pi_hole_client/screens/logs/logs_filters_modal.dart'; + +class FiltersV6 implements Filters { + final List _statusAll = + queryStatusesV6.where((e) => e.isShown).map((e) => e.index).toList(); + final List _statusAllowed = [3, 4]; + final List _statusBlocked = [2, 5, 6, 7, 8, 9, 10, 11, 12]; + List _statusSelected; + DateTime? _startTime; + DateTime? _endTime; + List _totalClients = []; + List _selectedClients = []; + String? _selectedDomain; + RequestStatus _requestStatus = RequestStatus.all; + + FiltersV6() : _statusSelected = [] { + _statusSelected = _statusAll; + } + + @override + List get statusAllowedAndRetried { + return [3, 4, 13, 14, 15]; + } + + @override + List get defaultSelected { + return _statusAll; + } + + @override + List get statusSelected { + return _statusSelected; + } + + @override + String get statusSelectedString { + return queryStatusesV6 + .firstWhere((e) => e.index == _statusSelected[0]) + .text; + } + + @override + DateTime? get startTime { + return _startTime; + } + + @override + DateTime? get endTime { + return _endTime; + } + + @override + List get totalClients { + return _totalClients; + } + + @override + List get selectedClients { + return _selectedClients; + } + + @override + String? get selectedDomain { + return _selectedDomain; + } + + @override + RequestStatus get requestStatus { + return _requestStatus; + } + + @override + void setStatusSelected(List values) { + _statusSelected = values; + if (values == _statusAll) { + _requestStatus = RequestStatus.all; + } else if (values == _statusAllowed) { + _requestStatus = RequestStatus.allowed; + } else if (values == _statusBlocked) { + _requestStatus = RequestStatus.blocked; + } + } + + @override + void setStartTime(DateTime value) { + _startTime = value; + } + + @override + void setEndTime(DateTime value) { + _endTime = value; + } + + @override + void resetFilters() { + _statusSelected = _statusAll; + _requestStatus = RequestStatus.all; + _startTime = null; + _endTime = null; + _selectedClients = _totalClients; + _selectedDomain = null; + } + + @override + void resetTime() { + _startTime = null; + _endTime = null; + } + + @override + void resetStatus() { + _statusSelected = _statusAll; + _requestStatus = RequestStatus.all; + } + + @override + void setClients(List clients) { + if (_totalClients.isEmpty) { + _selectedClients = clients; + } + _totalClients = clients; + } + + @override + void setSelectedClients(List selectedClients) { + _selectedClients = selectedClients; + } + + @override + void setSelectedDomain(String? domain) { + _selectedDomain = domain; + } + + @override + void resetClients() { + _selectedClients = _totalClients; + } + + @override + void setRequestStatus(RequestStatus status) { + _requestStatus = status; + if (status == RequestStatus.all) { + _statusSelected = _statusAll; + } else if (status == RequestStatus.allowed) { + _statusSelected = _statusAllowed; + } else if (status == RequestStatus.blocked) { + _statusSelected = _statusBlocked; + } + } +} diff --git a/lib/providers/servers_provider.dart b/lib/providers/servers_provider.dart index 3ab5c21b..e09968e6 100644 --- a/lib/providers/servers_provider.dart +++ b/lib/providers/servers_provider.dart @@ -1,9 +1,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; +import 'package:pi_hole_client/constants/query_types.dart'; import 'package:pi_hole_client/gateways/api_gateway_factory.dart'; import 'package:pi_hole_client/gateways/api_gateway_interface.dart'; -import 'package:pi_hole_client/gateways/v5/api_gateway_v5.dart'; -import 'package:pi_hole_client/models/gateways.dart'; +import 'package:pi_hole_client/models/query_status.dart'; import 'package:pi_hole_client/models/repository/database.dart'; import 'package:pi_hole_client/repository/database.dart'; import 'package:pi_hole_client/providers/app_config_provider.dart'; @@ -13,6 +14,8 @@ import 'package:pi_hole_client/models/server.dart'; class ServersProvider with ChangeNotifier { AppConfigProvider? _appConfigProvider; final DatabaseRepository _repository; + final List _queryStatusesV5 = queryStatusesV5; + final List _queryStatusesV6 = queryStatusesV6; ServersProvider(this._repository); @@ -40,10 +43,67 @@ class ServersProvider with ChangeNotifier { ? _serverGateways[_selectedServer?.address] : null; + ApiGateway? loadApiGateway(Server server) { + final gateway = _serverGateways[server.address]; + if (gateway == null) { + return ApiGatewayFactory.create(server); + } + + return _serverGateways[server.address]; + } + + List get queryStatuses { + switch (_selectedServer?.apiVersion) { + case 'v5': + return _queryStatusesV5; + case 'v6': + return _queryStatusesV6; + default: + return []; + } + } + + QueryStatus? getQueryStatus(String key) { + switch (_selectedServer?.apiVersion) { + case 'v5': + return _queryStatusesV5.firstWhereOrNull((status) => status.key == key); + case 'v6': + return _queryStatusesV6 + .firstWhereOrNull((status) => status.index.toString() == key); + default: + return null; + } + } + + int get numShown { + switch (_selectedServer?.apiVersion) { + case 'v5': + return _queryStatusesV5.where((status) => status.isShown).length; + case 'v6': + return _queryStatusesV6.where((status) => status.isShown).length; + default: + return 0; + } + } + + /// Returns the query status object for the given key. + /// + /// If the key is not found, returns null. + QueryStatus? findQueryStatus(String key) { + switch (_selectedServer?.apiVersion) { + case 'v5': + return _queryStatusesV5.firstWhereOrNull((status) => status.key == key); + case 'v6': + return _queryStatusesV6.firstWhereOrNull((status) => status.key == key); + default: + return null; + } + } + Future addServer(Server server) async { final saved = await _repository.saveServerQuery(server); if (saved == true) { - _serverGateways[server.address] = ApiGatewayV5(server); + _serverGateways[server.address] = ApiGatewayFactory.create(server); if (server.defaultServer == true) { final defaultServer = await setDefaultServer(server); if (defaultServer == true) { @@ -114,23 +174,23 @@ class ServersProvider with ChangeNotifier { } } - Future setToken(Server server) async { - final result = - await _repository.setServerTokenQuery(server.token, server.address); - if (result == true) { - _serversList = _serversList.map((s) { - if (s.address == server.address) { - return server; - } else { - return s; - } - }).toList(); - notifyListeners(); - return true; - } else { - return false; - } - } + // Future setToken(Server server) async { + // final result = + // await _repository.setServerTokenQuery(server.token, server.address); + // if (result == true) { + // _serversList = _serversList.map((s) { + // if (s.address == server.address) { + // return server; + // } else { + // return s; + // } + // }).toList(); + // notifyListeners(); + // return true; + // } else { + // return false; + // } + // } Future saveFromDb(List? servers, bool connect) async { if (servers != null) { @@ -146,7 +206,8 @@ class ServersProvider with ChangeNotifier { basicAuthPassword: server.basicAuthPassword, ); _serversList.add(serverObj); - _serverGateways[serverObj.address] = ApiGatewayV5(serverObj); + _serverGateways[serverObj.address] = + ApiGatewayFactory.create(serverObj); if (convertFromIntToBool(server.isDefaultServer) == true) { defaultServer = serverObj; } @@ -162,19 +223,6 @@ class ServersProvider with ChangeNotifier { } } - Future login(Server serverObj) async { - final result = await ApiGatewayFactory.create(serverObj).loginQuery(); - if (result.result == APiResponseType.success) { - _selectedServer = serverObj; - notifyListeners(); - return true; - } else { - _selectedServer = serverObj; - notifyListeners(); - return false; - } - } - FutureOr> checkUrlExists(String url) async { return await _repository.checkUrlExistsQuery(url); } @@ -186,7 +234,7 @@ class ServersProvider with ChangeNotifier { } void updateselectedServerStatus(bool enabled) { - if (_selectedServer != null) { + if (_selectedServer != null && _selectedServer!.enabled != enabled) { _selectedServer = _selectedServer!.copyWith(enabled: enabled); notifyListeners(); } @@ -203,4 +251,10 @@ class ServersProvider with ChangeNotifier { return false; } } + + Future resetSelectedServer() async { + _selectedServer = null; + notifyListeners(); + return true; + } } diff --git a/lib/repository/database.dart b/lib/repository/database.dart index 017bf58b..8ce5b403 100644 --- a/lib/repository/database.dart +++ b/lib/repository/database.dart @@ -148,13 +148,11 @@ class DatabaseRepository { .getValue('${server.address}_basicAuthUser'); final basicAuthPassword = await _secureStorage .getValue('${server.address}_basicAuthPassword'); + final sid = + await _secureStorage.getValue('${server.address}_sid'); servers![i] = ServerDbData.withSecrets( - server, - token, - basicAuthUser, - basicAuthPassword, - ); + server, token, basicAuthUser, basicAuthPassword, sid); } } }); @@ -191,6 +189,14 @@ class DatabaseRepository { '${server.address}_basicAuthPassword', server.basicAuthPassword!); } + final password = await server.sm.password; + if (password != null) { + await _secureStorage.saveValue('${server.address}_password', password); + } + if (server.sm.sid != null) { + await _secureStorage.saveValue('${server.address}_sid', server.sm.sid); + } + await _dbInstance.transaction((txn) async { await txn.insert('servers', { 'address': server.address, @@ -241,6 +247,13 @@ class DatabaseRepository { await _secureStorage.saveValue( '${server.address}_basicAuthPassword', server.basicAuthPassword!); } + final password = await server.sm.password; + if (password != null) { + await _secureStorage.saveValue('${server.address}_password', password); + } + if (server.sm.sid != null) { + await _secureStorage.saveValue('${server.address}_sid', server.sm.sid!); + } return await _dbInstance.transaction((txn) async { await txn.update( @@ -300,15 +313,33 @@ class DatabaseRepository { /// Returns: /// - A `Future` that resolves to `null` on success, or the error if the /// operation fails. - Future setServerTokenQuery(String? token, String address) async { - try { - if (token != null) { - await _secureStorage.saveValue('${address}_token', token); - } - } catch (e) { - return e; - } - } + // Future setServerTokenQuery(String? token, String address) async { + // try { + // if (token != null) { + // await _secureStorage.saveValue('${address}_token', token); + // } + // } catch (e) { + // return e; + // } + // } + + /// Updates the basic authentication credentials for a server in the database. + /// + /// This method updates the `password` field of the server identified by + /// [address] in the `servers` table. + /// + /// Parameters: + /// - [password]: The new password value for the server. If `null`, an empty + /// - [address]: The address of the server to update. + // Future setPsswordQuery(String? password, String address) async { + // try { + // if (password != null) { + // await _secureStorage.saveValue('${address}_password', password); + // } + // } catch (e) { + // return e; + // } + // } /// Removes a server from the database. /// @@ -327,6 +358,9 @@ class DatabaseRepository { await _secureStorage.deleteValue('${address}_token'); await _secureStorage.deleteValue('${address}_basicAuthUser'); await _secureStorage.deleteValue('${address}_basicAuthPassword'); + await _secureStorage.deleteValue('${address}_password'); + await _secureStorage.deleteValue('${address}_sid'); + logger.d((await _secureStorage.readAll()).toString()); return await _dbInstance.transaction((txn) async { await txn.delete('servers', where: 'address = ?', whereArgs: [address]); diff --git a/lib/screens/home/home_appbar.dart b/lib/screens/home/home_appbar.dart index 93d5d00c..6a7865a4 100644 --- a/lib/screens/home/home_appbar.dart +++ b/lib/screens/home/home_appbar.dart @@ -1,7 +1,6 @@ // ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; -import 'package:pi_hole_client/gateways/api_gateway_factory.dart'; import 'package:pi_hole_client/models/gateways.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -94,9 +93,9 @@ class HomeAppBar extends StatelessWidget implements PreferredSizeWidget { final ProcessModal process = ProcessModal(context: context); process.open(AppLocalizations.of(context)!.connecting); - final result = await ApiGatewayFactory.create(server).loginQuery(); + final result = await serversProvider.loadApiGateway(server)?.loginQuery(); process.close(); - if (result.result == APiResponseType.success) { + if (result?.result == APiResponseType.success) { await connectSuccess(result); } else { showSnackBar( diff --git a/lib/screens/logs/log_details_screen.dart b/lib/screens/logs/log_details_screen.dart index cf161497..46954d05 100644 --- a/lib/screens/logs/log_details_screen.dart +++ b/lib/screens/logs/log_details_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:pi_hole_client/providers/filters_provider.dart'; import 'package:pi_hole_client/screens/logs/log_status.dart'; import 'package:pi_hole_client/widgets/custom_list_tile.dart'; @@ -8,6 +9,7 @@ import 'package:pi_hole_client/functions/open_url.dart'; import 'package:pi_hole_client/models/log.dart'; import 'package:pi_hole_client/constants/search_domain_base_url.dart'; import 'package:pi_hole_client/functions/format.dart'; +import 'package:provider/provider.dart'; class LogDetailsScreen extends StatelessWidget { final Log log; @@ -18,6 +20,8 @@ class LogDetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { + final filterProvider = Provider.of(context); + Widget item(IconData icon, String label, Widget value) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), @@ -46,11 +50,8 @@ class LogDetailsScreen extends StatelessWidget { } Widget blackWhiteListButton() { - if (log.status == '2' || - log.status == '3' || - log.status == '12' || - log.status == '13' || - log.status == '14') { + if (filterProvider.statusAllowedAndRetried + .contains(int.parse(log.status!))) { return IconButton( onPressed: () { Navigator.pop(context); diff --git a/lib/screens/logs/log_status.dart b/lib/screens/logs/log_status.dart index 5653d85d..c4142292 100644 --- a/lib/screens/logs/log_status.dart +++ b/lib/screens/logs/log_status.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:pi_hole_client/providers/servers_provider.dart'; +import 'package:provider/provider.dart'; class LogStatus extends StatelessWidget { final String status; @@ -12,6 +14,8 @@ class LogStatus extends StatelessWidget { @override Widget build(BuildContext context) { + final serverProvider = Provider.of(context); + Widget logStatusWidget( {required IconData icon, required Color color, required String text}) { return Row( @@ -42,98 +46,16 @@ class LogStatus extends StatelessWidget { ]); } - switch (status) { - case "1": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (gravity)"); - - case "2": - return logStatusWidget( - icon: Icons.verified_user_rounded, - color: Colors.green, - text: "OK (forwarded)"); - - case "3": - return logStatusWidget( - icon: Icons.verified_user_rounded, - color: Colors.green, - text: "OK (cache)"); - - case "4": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (regex blacklist)"); - - case "5": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (exact blacklist)"); - - case "6": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (external, IP)"); - - case "7": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (external, NULL)"); - - case "8": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (external, NXRA)"); - - case "9": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (gravity, CNAME)"); - - case "10": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (regex blacklist, CNAME)"); - - case "11": - return logStatusWidget( - icon: Icons.gpp_bad_rounded, - color: Colors.red, - text: "Blocked (exact blacklist, CNAME)"); - - case "12": - return logStatusWidget( - icon: Icons.refresh_rounded, color: Colors.blue, text: "Retried"); - - case "13": - return logStatusWidget( - icon: Icons.refresh_rounded, - color: Colors.blue, - text: "Retried (ignored)"); - - case "14": - return logStatusWidget( - icon: Icons.verified_user_rounded, - color: Colors.green, - text: "OK (already forwarded)"); - - case "15": - return logStatusWidget( - icon: Icons.storage_rounded, - color: Colors.orange, - text: "Database is busy"); - - default: - return logStatusWidget( - icon: Icons.shield_rounded, color: Colors.grey, text: "Unknown"); + final queryStatus = serverProvider.getQueryStatus(status); + if (queryStatus == null) { + return logStatusWidget( + icon: Icons.shield_rounded, color: Colors.grey, text: "Unknown"); } + + return logStatusWidget( + icon: queryStatus.icon, + color: queryStatus.color, + text: queryStatus.text, + ); } } diff --git a/lib/screens/logs/logs.dart b/lib/screens/logs/logs.dart index 74fd8240..69246957 100644 --- a/lib/screens/logs/logs.dart +++ b/lib/screens/logs/logs.dart @@ -1,6 +1,7 @@ // ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; +import 'package:pi_hole_client/functions/logger.dart'; import 'package:pi_hole_client/models/gateways.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -14,7 +15,6 @@ import 'package:pi_hole_client/widgets/custom_radio.dart'; import 'package:pi_hole_client/config/system_overlay_style.dart'; import 'package:pi_hole_client/providers/app_config_provider.dart'; import 'package:pi_hole_client/functions/snackbar.dart'; -import 'package:pi_hole_client/constants/log_status.dart'; import 'package:pi_hole_client/providers/filters_provider.dart'; import 'package:pi_hole_client/classes/process_modal.dart'; import 'package:pi_hole_client/models/log.dart'; @@ -124,6 +124,7 @@ class _LogsState extends State { List items = []; if (result!.data != null) { result.data?.forEach((item) => items.add(item)); + logger.d('Logs fetched: ${items.map((e) => e.toJson()).toList()}'); } if (replaceOldLogs == true) { setState(() { @@ -442,7 +443,8 @@ class _LogsState extends State { } bool areFiltersApplied() { - if (filtersProvider.statusSelected.length < 13 || + if (filtersProvider.statusSelected.length < + serversProvider.numShown - 1 || filtersProvider.startTime != null || filtersProvider.endTime != null || filtersProvider.selectedClients.length < @@ -612,12 +614,10 @@ class _LogsState extends State { loadLogs(replaceOldLogs: true); }), if (filtersProvider.statusSelected.length < - 13) + serversProvider.numShown - 1) buildChip( filtersProvider.statusSelected.length == 1 - ? logStatusString[filtersProvider - .statusSelected[0] - - 1] + ? filtersProvider.statusSelectedString : "${filtersProvider.statusSelected.length} ${AppLocalizations.of(context)!.statusSelected}", const Icon(Icons.shield), () { diff --git a/lib/screens/logs/logs_filters_modal.dart b/lib/screens/logs/logs_filters_modal.dart index fb270ea4..b9c16dd1 100644 --- a/lib/screens/logs/logs_filters_modal.dart +++ b/lib/screens/logs/logs_filters_modal.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:pi_hole_client/providers/servers_provider.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -37,6 +38,7 @@ class _LogsFiltersModalState extends State { @override Widget build(BuildContext context) { final filtersProvider = Provider.of(context); + final serverProvider = Provider.of(context); final width = MediaQuery.of(context).size.width; @@ -397,7 +399,8 @@ class _LogsFiltersModalState extends State { const SizedBox(height: 5), Text( statusText( - filtersProvider.statusSelected.length, 14), + filtersProvider.statusSelected.length, + serverProvider.numShown), style: TextStyle( color: Theme.of(context) .colorScheme diff --git a/lib/screens/logs/status_filters_modal.dart b/lib/screens/logs/status_filters_modal.dart index 84e91914..80b15ef6 100644 --- a/lib/screens/logs/status_filters_modal.dart +++ b/lib/screens/logs/status_filters_modal.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:pi_hole_client/providers/servers_provider.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -22,7 +23,7 @@ class StatusFiltersModal extends StatefulWidget { } class _StatusFiltersModalState extends State { - List _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; + late List _statusSelected; void _updateStatusSelected(int option) { if (_statusSelected.contains(option) == true) { @@ -48,6 +49,7 @@ class _StatusFiltersModalState extends State { @override Widget build(BuildContext context) { final filtersProvider = Provider.of(context); + final serversProvider = Provider.of(context); void updateList() { filtersProvider.setStatusSelected(_statusSelected); @@ -79,9 +81,9 @@ class _StatusFiltersModalState extends State { } void checkUncheckAll() { - if (_statusSelected.length < 14) { + if (_statusSelected.length < serversProvider.numShown) { setState(() { - _statusSelected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; + _statusSelected = filtersProvider.defaultSelected; }); } else { setState(() { @@ -90,6 +92,18 @@ class _StatusFiltersModalState extends State { } } + List generateListItems() { + return serversProvider.queryStatuses + .where((item) => item.isShown) + .map((item) { + return listItem( + icon: item.icon, + label: item.text, + value: item.index, + ); + }).toList(); + } + Widget content() { return Wrap( alignment: WrapAlignment.center, @@ -119,60 +133,7 @@ class _StatusFiltersModalState extends State { ), ], ), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (gravity)", - value: 1), - listItem( - icon: Icons.verified_user_rounded, - label: "OK (forwarded)", - value: 2), - listItem( - icon: Icons.verified_user_rounded, - label: "OK (cache)", - value: 3), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (regex blacklist", - value: 4), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (exact blacklist)", - value: 5), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (external, IP)", - value: 6), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (external, NULL)", - value: 7), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (external, NXRA)", - value: 8), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (gravity, CNAME)", - value: 9), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (regex blacklist, CNAME)", - value: 10), - listItem( - icon: Icons.gpp_bad_rounded, - label: "Blocked (exact blacklist, CNAME)", - value: 11), - listItem( - icon: Icons.refresh_rounded, label: "Retried", value: 12), - listItem( - icon: Icons.refresh_rounded, - label: "Retried (ignored)", - value: 13), - listItem( - icon: Icons.gpp_bad_rounded, - label: "OK (already forwarded)", - value: 14), + ...generateListItems(), ], ), ), @@ -183,9 +144,10 @@ class _StatusFiltersModalState extends State { children: [ TextButton( onPressed: checkUncheckAll, - child: Text(_statusSelected.length == 14 - ? AppLocalizations.of(context)!.uncheckAll - : AppLocalizations.of(context)!.checkAll)), + child: Text( + _statusSelected.length == serversProvider.numShown + ? AppLocalizations.of(context)!.uncheckAll + : AppLocalizations.of(context)!.checkAll)), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ diff --git a/lib/screens/servers/add_server_fullscreen.dart b/lib/screens/servers/add_server_fullscreen.dart index 13512dba..af5ddabe 100644 --- a/lib/screens/servers/add_server_fullscreen.dart +++ b/lib/screens/servers/add_server_fullscreen.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:pi_hole_client/constants/api_versions.dart'; import 'package:pi_hole_client/constants/urls.dart'; -import 'package:pi_hole_client/gateways/api_gateway_factory.dart'; import 'package:pi_hole_client/models/gateways.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -22,8 +21,14 @@ import 'package:pi_hole_client/models/server.dart'; class AddServerFullscreen extends StatefulWidget { final Server? server; final bool window; + final String title; - const AddServerFullscreen({super.key, this.server, required this.window}); + const AddServerFullscreen({ + super.key, + this.server, + required this.window, + required this.title, + }); @override State createState() => _AddServerFullscreenState(); @@ -40,6 +45,7 @@ class _AddServerFullscreenState extends State { String? subrouteFieldError; TextEditingController aliasFieldController = TextEditingController(); TextEditingController tokenFieldController = TextEditingController(); + TextEditingController passwordFieldController = TextEditingController(); ConnectionType connectionType = ConnectionType.http; String piHoleVersion = SupportedApiVersions.v5; TextEditingController basicAuthUser = TextEditingController(); @@ -62,6 +68,7 @@ class _AddServerFullscreenState extends State { portFieldError == null && aliasFieldController.text != '' && tokenFieldController.text != '' && + passwordFieldController.text != '' && ((basicAuthUser.text != '' && basicAuthPassword.text != '') || (basicAuthUser.text == '' && basicAuthPassword.text == ''))) { setState(() { @@ -136,6 +143,31 @@ class _AddServerFullscreenState extends State { checkDataValid(); } + Future _loadPassword() async { + if (widget.server != null) { + try { + final password = await widget.server!.sm.password; + if (mounted) { + setState(() { + passwordFieldController.text = password ?? ''; + }); + } + } catch (e) { + if (mounted) { + setState(() { + passwordFieldController.text = ''; + }); + } + } + } else { + if (mounted) { + setState(() { + passwordFieldController.text = ''; + }); + } + } + } + @override void initState() { super.initState(); @@ -147,13 +179,12 @@ class _AddServerFullscreenState extends State { tokenFieldController.text = widget.server!.token ?? ''; basicAuthUser.text = widget.server!.basicAuthUser ?? ''; basicAuthPassword.text = widget.server!.basicAuthPassword ?? ''; - setState(() { - connectionType = widget.server!.address.split(':')[0] == 'https' - ? ConnectionType.https - : ConnectionType.http; - piHoleVersion = widget.server!.apiVersion; - defaultCheckbox = widget.server!.defaultServer; - }); + connectionType = widget.server!.address.split(':')[0] == 'https' + ? ConnectionType.https + : ConnectionType.http; + piHoleVersion = widget.server!.apiVersion; + defaultCheckbox = widget.server!.defaultServer; + _loadPassword(); } } @@ -191,67 +222,72 @@ class _AddServerFullscreenState extends State { errorUrl = null; }); final serverObj = Server( - address: url, - alias: aliasFieldController.text, - token: tokenFieldController.text, - defaultServer: false, - apiVersion: piHoleVersion, - basicAuthUser: basicAuthUser.text, - basicAuthPassword: basicAuthPassword.text); - final result = await ApiGatewayFactory.create(serverObj).loginQuery(); + address: url, + alias: aliasFieldController.text, + token: tokenFieldController.text, + defaultServer: false, + apiVersion: piHoleVersion, + basicAuthUser: basicAuthUser.text, + basicAuthPassword: basicAuthPassword.text, + ); + serverObj.sm.savePassword(passwordFieldController.text); + final result = + await serversProvider.loadApiGateway(serverObj)?.loginQuery(); if (!mounted) return; - if (result.result == APiResponseType.success) { + if (result?.result == APiResponseType.success) { Navigator.pop(context); serversProvider.addServer(Server( - address: serverObj.address, - alias: serverObj.alias, - token: serverObj.token, - defaultServer: defaultCheckbox, - apiVersion: piHoleVersion, - enabled: result.status == 'enabled' ? true : false, - basicAuthUser: basicAuthUser.text, - basicAuthPassword: basicAuthPassword.text)); + address: serverObj.address, + alias: serverObj.alias, + token: serverObj.token, + defaultServer: defaultCheckbox, + apiVersion: piHoleVersion, + enabled: result!.status == 'enabled' ? true : false, + basicAuthUser: basicAuthUser.text, + basicAuthPassword: basicAuthPassword.text, + sm: serverObj.sm, + )); } else { if (mounted) { setState(() { isConnecting = false; }); - if (result.result == APiResponseType.socket) { + if (result?.result == APiResponseType.socket) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.checkAddress, color: Colors.red); - appConfigProvider.addLog(result.log!); - } else if (result.result == APiResponseType.timeout) { + appConfigProvider.addLog(result!.log!); + } else if (result?.result == APiResponseType.timeout) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.connectionTimeout, color: Colors.red); - appConfigProvider.addLog(result.log!); - } else if (result.result == APiResponseType.noConnection) { + appConfigProvider.addLog(result!.log!); + } else if (result?.result == APiResponseType.noConnection) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.cantReachServer, color: Colors.red); - appConfigProvider.addLog(result.log!); - } else if (result.result == APiResponseType.authError) { + appConfigProvider.addLog(result!.log!); + } else if (result?.result == APiResponseType.authError) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.tokenNotValid, color: Colors.red); - appConfigProvider.addLog(result.log!); - } else if (result.result == APiResponseType.sslError) { + appConfigProvider.addLog(result!.log!); + } else if (result?.result == APiResponseType.sslError) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.sslErrorLong, color: Colors.red); - appConfigProvider.addLog(result.log!); + appConfigProvider.addLog(result!.log!); } else { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.unknownError, color: Colors.red); - appConfigProvider.addLog(result.log!); + appConfigProvider.addLog(result!.log!); } } else { isConnecting = false; @@ -268,23 +304,28 @@ class _AddServerFullscreenState extends State { }); final serverObj = Server( + address: widget.server!.address, + alias: aliasFieldController.text, + token: tokenFieldController.text, + defaultServer: false, + apiVersion: piHoleVersion, + basicAuthUser: basicAuthUser.text, + basicAuthPassword: basicAuthPassword.text, + ); + serverObj.sm.savePassword(passwordFieldController.text); + final result = + await serversProvider.loadApiGateway(serverObj)?.loginQuery(); + if (result?.result == APiResponseType.success) { + Server server = Server( address: widget.server!.address, alias: aliasFieldController.text, token: tokenFieldController.text, - defaultServer: false, + defaultServer: defaultCheckbox, apiVersion: piHoleVersion, basicAuthUser: basicAuthUser.text, - basicAuthPassword: basicAuthPassword.text); - final result = await ApiGatewayFactory.create(serverObj).loginQuery(); - if (result.result == APiResponseType.success) { - Server server = Server( - address: widget.server!.address, - alias: aliasFieldController.text, - token: tokenFieldController.text, - defaultServer: defaultCheckbox, - apiVersion: piHoleVersion, - basicAuthUser: basicAuthUser.text, - basicAuthPassword: basicAuthPassword.text); + basicAuthPassword: basicAuthPassword.text, + ); + server.sm.savePassword(passwordFieldController.text); final result = await serversProvider.editServer(server); if (mounted) { if (result == true) { @@ -304,27 +345,27 @@ class _AddServerFullscreenState extends State { setState(() { isConnecting = false; }); - if (result.result == APiResponseType.socket) { + if (result?.result == APiResponseType.socket) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.checkAddress, color: Colors.red); - } else if (result.result == APiResponseType.timeout) { + } else if (result?.result == APiResponseType.timeout) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.connectionTimeout, color: Colors.red); - } else if (result.result == APiResponseType.noConnection) { + } else if (result?.result == APiResponseType.noConnection) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.cantReachServer, color: Colors.red); - } else if (result.result == APiResponseType.authError) { + } else if (result?.result == APiResponseType.authError) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.tokenNotValid, color: Colors.red); - } else if (result.result == APiResponseType.sslError) { + } else if (result?.result == APiResponseType.sslError) { showSnackBar( appConfigProvider: appConfigProvider, label: AppLocalizations.of(context)!.sslErrorLong, @@ -484,7 +525,7 @@ class _AddServerFullscreenState extends State { child: TextField( obscureText: true, keyboardType: TextInputType.visiblePassword, - controller: tokenFieldController, + controller: passwordFieldController, onChanged: (value) => checkDataValid(), decoration: InputDecoration( prefixIcon: const Icon(Icons.key_rounded), @@ -708,7 +749,7 @@ class _AddServerFullscreenState extends State { icon: const Icon(Icons.clear_rounded)), const SizedBox(width: 8), Text( - AppLocalizations.of(context)!.createConnection, + widget.title, style: const TextStyle(fontSize: 20), ), ], @@ -751,7 +792,7 @@ class _AddServerFullscreenState extends State { children: [ Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.createConnection), + title: Text(widget.title), actions: [ IconButton( onPressed: () => openUrl(createAConnectionUrl), diff --git a/lib/screens/servers/servers.dart b/lib/screens/servers/servers.dart index d9286e77..22e20a50 100644 --- a/lib/screens/servers/servers.dart +++ b/lib/screens/servers/servers.dart @@ -84,9 +84,10 @@ class _ServersPageState extends State { showDialog( context: context, builder: (context) => AddServerFullscreen( - server: server, - window: true, - ), + server: server, + window: true, + title: + AppLocalizations.of(context)!.createConnection), barrierDismissible: false) } else @@ -97,9 +98,10 @@ class _ServersPageState extends State { fullscreenDialog: true, builder: (BuildContext context) => AddServerFullscreen( - server: server, - window: false, - ))) + server: server, + window: false, + title: AppLocalizations.of(context)! + .createConnection))) } })); } diff --git a/lib/screens/servers/servers_list_item.dart b/lib/screens/servers/servers_list_item.dart deleted file mode 100644 index 26bc3210..00000000 --- a/lib/screens/servers/servers_list_item.dart +++ /dev/null @@ -1,417 +0,0 @@ -// ignore_for_file: use_build_context_synchronously - -import 'package:flutter/material.dart'; -import 'package:expandable/expandable.dart'; -import 'package:pi_hole_client/gateways/api_gateway_factory.dart'; -import 'package:pi_hole_client/models/gateways.dart'; -import 'package:provider/provider.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - -import 'package:pi_hole_client/screens/servers/add_server_fullscreen.dart'; -import 'package:pi_hole_client/screens/servers/delete_modal.dart'; - -import 'package:pi_hole_client/classes/process_modal.dart'; -import 'package:pi_hole_client/functions/snackbar.dart'; -import 'package:pi_hole_client/providers/app_config_provider.dart'; -import 'package:pi_hole_client/providers/servers_provider.dart'; -import 'package:pi_hole_client/providers/status_provider.dart'; -import 'package:pi_hole_client/models/server.dart'; - -class ServersListItem extends StatefulWidget { - final ExpandableController expandableController; - final Server server; - final int index; - final void Function(int) onChange; - - const ServersListItem( - {super.key, - required this.expandableController, - required this.server, - required this.index, - required this.onChange}); - - @override - State createState() => _ServersListItemState(); -} - -class _ServersListItemState extends State - with SingleTickerProviderStateMixin { - late AnimationController animationController; - late Animation animation; - - @override - void initState() { - widget.expandableController.addListener(() async { - await Future.delayed(const Duration(milliseconds: 200)); - if (widget.expandableController.value == false) { - animationController.animateTo(0); - } else { - animationController.animateBack(1); - } - }); - - animationController = AnimationController( - duration: const Duration(milliseconds: 200), - vsync: this, - ); - animation = Tween( - begin: 0.0, - end: 0.5, - ).animate( - CurvedAnimation(parent: animationController, curve: Curves.easeInOut)); - - super.initState(); - } - - @override - Widget build(BuildContext context) { - final serversProvider = Provider.of(context); - final statusProvider = Provider.of(context); - final appConfigProvider = Provider.of(context); - final apiGateway = serversProvider.selectedApiGateway; - - final width = MediaQuery.of(context).size.width; - - void showDeleteModal(Server server) async { - await Future.delayed( - const Duration(seconds: 0), - () => { - showDialog( - context: context, - builder: (context) => DeleteModal( - serverToDelete: server, - ), - barrierDismissible: false) - }); - } - - void openAddServerBottomSheet({Server? server}) async { - await Future.delayed( - const Duration(seconds: 0), - (() => { - if (width > 700) - { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) => AddServerFullscreen( - server: server, - window: true, - ), - ) - } - else - { - Navigator.push( - context, - MaterialPageRoute( - fullscreenDialog: true, - builder: (BuildContext context) => - AddServerFullscreen( - server: server, - window: false, - ))) - } - })); - } - - void connectToServer(Server server) async { - Future connectSuccess(result) async { - serversProvider.setselectedServer( - server: Server( - address: server.address, - alias: server.alias, - token: server.token!, - defaultServer: server.defaultServer, - apiVersion: server.apiVersion, - enabled: result.status == 'enabled' ? true : false), - toHomeTab: true); - final statusResult = await apiGateway?.realtimeStatus(); - if (statusResult?.result == APiResponseType.success) { - statusProvider.setRealtimeStatus(statusResult!.data!); - } - final overtimeDataResult = await apiGateway?.fetchOverTimeData(); - if (overtimeDataResult?.result == APiResponseType.success) { - statusProvider.setOvertimeData(overtimeDataResult!.data!); - statusProvider.setOvertimeDataLoadingStatus(1); - } else { - statusProvider.setOvertimeDataLoadingStatus(2); - } - statusProvider.setIsServerConnected(true); - statusProvider.setRefreshServerStatus(true); - } - - final ProcessModal process = ProcessModal(context: context); - process.open(AppLocalizations.of(context)!.connecting); - - final result = await ApiGatewayFactory.create(server).loginQuery(); - process.close(); - if (result.result == APiResponseType.success) { - await connectSuccess(result); - } else { - showSnackBar( - appConfigProvider: appConfigProvider, - label: AppLocalizations.of(context)!.cannotConnect, - color: Colors.red); - } - } - - void setDefaultServer(Server server) async { - final result = await serversProvider.setDefaultServer(server); - if (result == true) { - showSnackBar( - appConfigProvider: appConfigProvider, - label: AppLocalizations.of(context)!.connectionDefaultSuccessfully, - color: Colors.green); - } else { - showSnackBar( - appConfigProvider: appConfigProvider, - label: AppLocalizations.of(context)!.connectionDefaultFailed, - color: Colors.red); - } - } - - Widget leadingIcon(Server server) { - if (server.defaultServer == true) { - return Stack( - alignment: Alignment.center, - children: [ - Icon( - Icons.storage_rounded, - color: serversProvider.selectedServer != null && - serversProvider.selectedServer?.address == server.address - ? statusProvider.isServerConnected == true - ? Colors.green - : Colors.orange - : null, - ), - SizedBox( - width: 25, - height: 25, - child: Stack( - alignment: Alignment.bottomRight, - children: [ - Container( - padding: const EdgeInsets.all(1), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primaryContainer, - borderRadius: BorderRadius.circular(20)), - child: Icon( - Icons.star, - color: Theme.of(context).colorScheme.onPrimaryContainer, - size: 10, - ), - ), - ], - ), - ) - ], - ); - } else { - return Icon( - Icons.storage_rounded, - color: serversProvider.selectedServer != null && - serversProvider.selectedServer?.address == server.address - ? statusProvider.isServerConnected == true - ? Colors.green - : Colors.orange - : null, - ); - } - } - - Widget topRow(Server server, int index) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 16), - child: leadingIcon(server), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - server.address, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Theme.of(context).colorScheme.onSurface), - ), - Column( - children: [ - const SizedBox(height: 3), - Text( - server.alias, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Theme.of(context) - .colorScheme - .onSurfaceVariant), - ) - ], - ) - ], - ), - ), - ], - ), - ), - RotationTransition( - turns: animation, - child: const Icon(Icons.keyboard_arrow_down_rounded), - ), - ], - ); - } - - Widget bottomRow(Server server, int index) { - return Column( - children: [ - const SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - PopupMenuButton( - // color: Theme.of(context).dialogBackgroundColor, - itemBuilder: (context) => [ - PopupMenuItem( - enabled: - server.defaultServer == false ? true : false, - onTap: server.defaultServer == false - ? (() => setDefaultServer(server)) - : null, - child: SizedBox( - child: Row( - children: [ - const Icon(Icons.star), - const SizedBox(width: 15), - Text( - server.defaultServer == true - ? AppLocalizations.of(context)! - .defaultConnection - : AppLocalizations.of(context)! - .setDefault, - ) - ], - ), - )), - PopupMenuItem( - onTap: (() => - openAddServerBottomSheet(server: server)), - child: Row( - children: [ - const Icon(Icons.edit), - const SizedBox(width: 15), - Text(AppLocalizations.of(context)!.edit) - ], - )), - PopupMenuItem( - onTap: (() => showDeleteModal(server)), - child: Row( - children: [ - const Icon(Icons.delete), - const SizedBox(width: 15), - Text(AppLocalizations.of(context)!.delete) - ], - )), - ]), - SizedBox( - child: serversProvider.selectedServer != null && - serversProvider.selectedServer?.address == - serversProvider.getServersList[index].address - ? Container( - margin: const EdgeInsets.only(right: 12), - padding: const EdgeInsets.symmetric( - vertical: 5, horizontal: 10), - decoration: BoxDecoration( - color: statusProvider.isServerConnected == true - ? Colors.green - : Colors.orange, - borderRadius: BorderRadius.circular(30)), - child: Row( - children: [ - Icon( - statusProvider.isServerConnected == true - ? Icons.check - : Icons.warning, - color: Colors.white, - ), - const SizedBox(width: 10), - Text( - statusProvider.isServerConnected == true - ? AppLocalizations.of(context)!.connected - : AppLocalizations.of(context)! - .selectedDisconnected, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w500), - ) - ], - ), - ) - : Container( - margin: const EdgeInsets.only(right: 10), - child: TextButton( - onPressed: () => connectToServer(server), - child: Text(AppLocalizations.of(context)!.connect), - ), - ), - ) - ], - ) - ], - ); - } - - return Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Theme.of(context).colorScheme.surfaceContainerHighest, - width: 1))), - child: ExpandableNotifier( - controller: widget.expandableController, - child: Column( - children: [ - Expandable( - collapsed: Material( - color: Colors.transparent, - child: InkWell( - onTap: () => widget.onChange(widget.index), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, vertical: 12), - child: topRow(widget.server, widget.index), - ), - ), - ), - expanded: Material( - color: Colors.transparent, - child: InkWell( - onTap: () => widget.onChange(widget.index), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, vertical: 12), - child: Column( - children: [ - topRow(widget.server, widget.index), - bottomRow(widget.server, widget.index) - ], - ), - ), - ), - )) - ], - ), - ), - ); - } -} diff --git a/lib/screens/servers/servers_tile_item.dart b/lib/screens/servers/servers_tile_item.dart index 8b86e614..f4516614 100644 --- a/lib/screens/servers/servers_tile_item.dart +++ b/lib/screens/servers/servers_tile_item.dart @@ -1,7 +1,6 @@ // ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; -import 'package:pi_hole_client/gateways/api_gateway_factory.dart'; import 'package:pi_hole_client/models/gateways.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -43,6 +42,7 @@ class _ServersTileItemState extends State final width = MediaQuery.of(context).size.width; + /// Delete void showDeleteModal(Server server) async { await Future.delayed( const Duration(seconds: 0), @@ -56,6 +56,7 @@ class _ServersTileItemState extends State }); } + /// Edit void openAddServerBottomSheet({Server? server}) async { await Future.delayed( const Duration(seconds: 0), @@ -66,9 +67,9 @@ class _ServersTileItemState extends State context: context, barrierDismissible: false, builder: (context) => AddServerFullscreen( - server: server, - window: true, - ), + server: server, + window: true, + title: AppLocalizations.of(context)!.editConnection), ) } else @@ -79,13 +80,15 @@ class _ServersTileItemState extends State fullscreenDialog: true, builder: (BuildContext context) => AddServerFullscreen( - server: server, - window: false, - ))) + server: server, + window: false, + title: AppLocalizations.of(context)! + .editConnection))) } })); } + /// Connect to the server button void connectToServer(Server server) async { Future connectSuccess(result) async { serversProvider.setselectedServer( @@ -95,7 +98,8 @@ class _ServersTileItemState extends State token: server.token!, defaultServer: server.defaultServer, apiVersion: server.apiVersion, - enabled: result.status == 'enabled' ? true : false), + enabled: result.status == 'enabled' ? true : false, + sm: server.sm), toHomeTab: true); final apiGateway = serversProvider.selectedApiGateway; final statusResult = await apiGateway?.realtimeStatus(); @@ -114,12 +118,12 @@ class _ServersTileItemState extends State appConfigProvider.setSelectedTab(0); } + await serversProvider.resetSelectedServer(); final ProcessModal process = ProcessModal(context: context); process.open(AppLocalizations.of(context)!.connecting); - final result = await ApiGatewayFactory.create(server).loginQuery(); - process.close(); - if (result.result == APiResponseType.success) { + final result = await serversProvider.loadApiGateway(server)?.loginQuery(); + if (result?.result == APiResponseType.success) { await connectSuccess(result); } else if (mounted) { showSnackBar( @@ -127,8 +131,10 @@ class _ServersTileItemState extends State label: AppLocalizations.of(context)!.cannotConnect, color: Colors.red); } + process.close(); } + /// Set default server void setDefaultServer(Server server) async { final result = await serversProvider.setDefaultServer(server); if (result == true) { diff --git a/lib/services/session_manager.dart b/lib/services/session_manager.dart new file mode 100644 index 00000000..bc546960 --- /dev/null +++ b/lib/services/session_manager.dart @@ -0,0 +1,57 @@ +import 'package:pi_hole_client/repository/secure_storage.dart'; + +class SessionManager { + final SecureStorageRepository _storage; + final String _address; + String? _sid; + + SessionManager(this._storage, this._address); + + get sid => _sid; + + get password async { + try { + return await _storage.getValue('${_address}_password'); + } catch (e) { + return null; + } + } + + Future save(String sid) async { + try { + await _storage.saveValue('${_address}_sid', sid); + _sid = sid; + return true; + } catch (e) { + return false; + } + } + + Future load() async { + try { + _sid = await _storage.getValue('${_address}_sid'); + return true; + } catch (e) { + return false; + } + } + + Future delete() async { + try { + await _storage.deleteValue('${_address}_sid'); + _sid = null; + return true; + } catch (e) { + return false; + } + } + + Future savePassword(String password) async { + try { + await _storage.saveValue('${_address}_password', password); + return true; + } catch (e) { + return false; + } + } +} diff --git a/lib/widgets/connecting_modal.dart b/lib/widgets/connecting_modal.dart deleted file mode 100644 index 6eeb342c..00000000 --- a/lib/widgets/connecting_modal.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - -class ConnectingModal extends StatelessWidget { - const ConnectingModal({super.key}); - - @override - Widget build(BuildContext context) { - return Dialog( - backgroundColor: Theme.of(context).dialogBackgroundColor, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - child: Padding( - padding: const EdgeInsets.all(20), - child: Row( - children: [ - const CircularProgressIndicator(), - const SizedBox(width: 30), - Text(AppLocalizations.of(context)!.connecting) - ], - ), - ), - ); - } -} diff --git a/lib/widgets/no_server_selected.dart b/lib/widgets/no_server_selected.dart index 79f26127..c3714219 100644 --- a/lib/widgets/no_server_selected.dart +++ b/lib/widgets/no_server_selected.dart @@ -23,9 +23,10 @@ class NoServerSelected extends StatelessWidget { { showDialog( context: context, - builder: (context) => const AddServerFullscreen( - window: true, - ), + builder: (context) => AddServerFullscreen( + window: true, + title: AppLocalizations.of(context)! + .createConnection), barrierDismissible: false) } } @@ -38,8 +39,10 @@ class NoServerSelected extends StatelessWidget { MaterialPageRoute( fullscreenDialog: true, builder: (BuildContext context) => - const AddServerFullscreen( + AddServerFullscreen( window: false, + title: AppLocalizations.of(context)! + .createConnection, ))) } } diff --git a/lib/widgets/selected_server_disconnected.dart b/lib/widgets/selected_server_disconnected.dart deleted file mode 100644 index 32964661..00000000 --- a/lib/widgets/selected_server_disconnected.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - -import 'package:pi_hole_client/functions/refresh_server_status.dart'; - -class SelectedServerDisconnected extends StatelessWidget { - const SelectedServerDisconnected({super.key}); - - @override - Widget build(BuildContext context) { - final height = MediaQuery.of(context).size.height; - - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - height: height - 180, - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - AppLocalizations.of(context)!.selectedDisconnected, - textAlign: TextAlign.center, - style: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant, - fontSize: 26), - ), - const SizedBox(height: 30), - TextButton.icon( - onPressed: () => refreshServerStatus(context), - icon: const Icon(Icons.refresh), - label: Text(AppLocalizations.of(context)!.tryReconnect)) - ], - ), - ), - ), - ], - ); - } -} diff --git a/pubspec.lock b/pubspec.lock index da5fdc1f..4d453040 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -183,7 +183,7 @@ packages: source: hosted version: "4.10.0" collection: - dependency: transitive + dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a @@ -614,10 +614,10 @@ packages: dependency: "direct dev" description: name: json_serializable - sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c url: "https://pub.dev" source: hosted - version: "6.8.0" + version: "6.9.0" leak_tracker: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9dfd827c..b094be22 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,6 +73,7 @@ dependencies: freezed_annotation: ^2.4.4 json_annotation: ^4.9.0 flutter_secure_storage: ^9.2.2 + collection: ^1.18.0 dev_dependencies: flutter_test: @@ -88,7 +89,7 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^5.0.0 freezed: ^2.5.7 - json_serializable: ^6.8.0 + json_serializable: ^6.9.0 mockito: ^5.4.4 diff --git a/test/gateways/v5/api_gateway_v5_test.dart b/test/gateways/v5/api_gateway_v5_test.dart index 292698f2..bb2a29c3 100644 --- a/test/gateways/v5/api_gateway_v5_test.dart +++ b/test/gateways/v5/api_gateway_v5_test.dart @@ -100,14 +100,13 @@ void main() { Uri.parse('http://example.com/admin/api.php?auth=xxx123&enable=0'), headers: {})).thenAnswer((_) async => http.Response( jsonEncode({"status": "enabled"}), 200, headers: { - 'set-cookie': - 'PHPSESSID=$sessinId; path=/; HttpOnly; SameSite=Strict' + 'set-cookie': 'sid=$sessinId; path=/; HttpOnly; SameSite=Strict' })); final response = await apiGateway.loginQuery(); expect(response.result, APiResponseType.success); - expect(response.phpSessId, sessinId); + expect(response.sid, sessinId); expect(response.status, 'enabled'); expect(response.log, isNull); }); @@ -122,7 +121,7 @@ void main() { final response = await apiGateway.loginQuery(); expect(response.result, APiResponseType.authError); - expect(response.phpSessId, isNull); + expect(response.sid, isNull); expect(response.status, isNull); expect(response.log, isNotNull); expect(response.log?.type, 'login'); @@ -191,7 +190,7 @@ void main() { final response = await apiGateway.loginQuery(); expect(response.result, APiResponseType.noConnection); - expect(response.phpSessId, isNull); + expect(response.sid, isNull); expect(response.status, isNull); expect(response.log, isNotNull); expect(response.log?.type, 'login'); @@ -210,7 +209,7 @@ void main() { final response = await apiGateway.loginQuery(); expect(response.result, APiResponseType.error); - expect(response.phpSessId, isNull); + expect(response.sid, isNull); expect(response.status, isNull); expect(response.log?.type, 'login'); expect(response.log?.message, 'Exception: Unexpected error test'); diff --git a/test/gateways/v6/api_gateway_v6_test.dart b/test/gateways/v6/api_gateway_v6_test.dart new file mode 100644 index 00000000..0520a862 --- /dev/null +++ b/test/gateways/v6/api_gateway_v6_test.dart @@ -0,0 +1,1248 @@ +import 'dart:convert'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:http/http.dart' as http; +import 'package:mockito/mockito.dart'; +import 'package:mockito/annotations.dart'; +import 'package:pi_hole_client/constants/api_versions.dart'; +import 'package:pi_hole_client/gateways/v6/api_gateway_v6.dart'; +import 'package:pi_hole_client/models/domain.dart'; +import 'package:pi_hole_client/models/gateways.dart'; +import 'package:pi_hole_client/models/server.dart'; +import 'package:pi_hole_client/services/session_manager.dart'; +import './api_gateway_v6_test.mocks.dart'; + +class SessionManagerMock implements SessionManager { + String? _sid; + String? _password; + + SessionManagerMock(this._sid, this._password); + + @override + get sid => _sid; + + @override + get password async { + try { + return _password; + } catch (e) { + return null; + } + } + + @override + Future save(String sid) async { + _sid = sid; + return true; + } + + @override + Future load() async { + return true; + } + + @override + Future delete() async { + _sid = null; + return true; + } + + @override + Future savePassword(String password) async { + _password = password; + return true; + } +} + +@GenerateMocks([http.Client]) +void main() async { + TestWidgetsFlutterBinding.ensureInitialized(); + await dotenv.load(fileName: '.env'); + + group('loginQuery', () { + late Server server; + final sessinId = 'n9n9f6c3umrumfq2ese1lvu2pg'; + final urls = [ + 'http://example.com/api/auth', + 'http://example.com/api/dns/blocking' + ]; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + sm: SessionManagerMock(sessinId, 'xxx123'), + ); + }); + test('Return success with valid password', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.post( + Uri.parse(urls[0]), + headers: anyNamed('headers'), + body: anyNamed('body'), + )).thenAnswer((_) async => http.Response( + jsonEncode({ + "session": { + "valid": true, + "totp": false, + "sid": "n9n9f6c3umrumfq2ese1lvu2pg", + "csrf": "Ux87YTIiMOf/GKCefVIOMw=", + "validity": 300, + "message": "correct password" + }, + "took": 0.039638996124267578 + }), + 200)); + + int callCount = 0; + + when(mockClient.get( + Uri.parse(urls[1]), + headers: anyNamed('headers'), + )).thenAnswer((_) async { + callCount++; + if (callCount == 1) { + return http.Response( + jsonEncode({ + "error": { + "key": "unauthorized", + "message": "Unauthorized", + "hint": null + }, + "took": 4.1484832763671875e-05 + }), + 401, + ); + } else { + // 2回目以降の呼び出し: 正常なレスポンスを返す + return http.Response( + jsonEncode({"blocking": "enabled", "timer": null, "took": 0.003}), + 200, + ); + } + }); + + final response = await apiGateway.loginQuery(); + + expect(response.result, APiResponseType.success); + expect(response.sid, sessinId); + expect(response.status, 'enabled'); + expect(response.log, isNull); + }); + + test('Return success with exist sid', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get( + Uri.parse(urls[1]), + headers: anyNamed('headers'), + )).thenAnswer((_) async { + return http.Response( + jsonEncode({"blocking": "enabled", "timer": null, "took": 0.003}), + 200, + ); + }); + + final response = await apiGateway.loginQuery(); + + expect(response.result, APiResponseType.success); + expect(response.sid, sessinId); + expect(response.status, 'enabled'); + expect(response.log, isNull); + }); + + test('Return error with invalid password', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get( + Uri.parse(urls[1]), + headers: anyNamed('headers'), + )).thenAnswer((_) async { + return http.Response( + jsonEncode({ + "error": { + "key": "unauthorized", + "message": "Unauthorized", + "hint": null + }, + "took": 4.1484832763671875e-05 + }), + 401, + ); + }); + + when(mockClient.post( + Uri.parse(urls[0]), + headers: anyNamed('headers'), + body: anyNamed('body'), + )).thenAnswer((_) async => http.Response( + jsonEncode({ + "session": { + "valid": false, + "totp": false, + "sid": null, + "validity": -1, + "message": "password incorrect" + }, + "took": 0.039638996124267578 + }), + 401)); + + final response = await apiGateway.loginQuery(); + + expect(response.result, APiResponseType.authError); + expect(response.sid, isNull); + expect(response.status, isNull); + expect(response.log, isNotNull); + expect(response.log?.type, 'login'); + expect(response.log?.message, 'auth_error'); + expect(response.log?.statusCode, '401'); + expect(response.log?.resBody, isNotNull); + }); + + test('Return error when accessing non Pi-hole server', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + // example.com's 404 page + final htmlString = ''' + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + + ''' + .trimLeft(); + + when(mockClient.get( + Uri.parse(urls[1]), + headers: anyNamed('headers'), + )).thenAnswer((_) async { + return http.Response( + jsonEncode({ + "error": { + "key": "unauthorized", + "message": "Unauthorized", + "hint": null + }, + "took": 4.1484832763671875e-05 + }), + 401, + ); + }); + + when(mockClient.post( + Uri.parse(urls[0]), + headers: anyNamed('headers'), + body: anyNamed('body'), + )).thenAnswer((_) async => http.Response(htmlString, 404)); + + final response = await apiGateway.loginQuery(); + + expect(response.result, APiResponseType.noConnection); + expect(response.sid, isNull); + expect(response.status, isNull); + expect(response.log, isNotNull); + expect(response.log?.type, 'login'); + expect(response.log?.message, 'no_connection_2'); + expect(response.log?.statusCode, '404'); + expect(response.log?.resBody, htmlString); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get( + Uri.parse(urls[1]), + headers: anyNamed('headers'), + )).thenAnswer((_) async { + return http.Response( + jsonEncode({ + "error": { + "key": "unauthorized", + "message": "Unauthorized", + "hint": null + }, + "took": 4.1484832763671875e-05 + }), + 401, + ); + }); + + when(mockClient.post( + Uri.parse(urls[0]), + headers: anyNamed('headers'), + body: anyNamed('body'), + )).thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway.loginQuery(); + + expect(response.result, APiResponseType.error); + expect(response.sid, isNull); + expect(response.status, isNull); + expect(response.log?.type, 'login'); + expect(response.log?.message, 'Exception: Unexpected error test'); + }); + }); + + group('realtimeStatus', () { + late Server server; + final urls = [ + 'http://example.com/api/stats/summary', + 'http://example.com/api/info/ftl', + 'http://example.com/api/dns/blocking', + 'http://example.com/api/stats/top_domains', + 'http://example.com/api/stats/top_domains?blocked=true', + 'http://example.com/api/stats/top_clients', + 'http://example.com/api/stats/top_clients?blocked=true', + 'http://example.com/api/stats/upstreams', + ]; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + server.sm.savePassword('xxx123'); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = [ + { + "queries": { + "total": 7497, + "blocked": 3465, + "percent_blocked": 34.5, + "unique_domains": 445, + "forwarded": 4574, + "cached": 9765, + "types": { + "A": 3643, + "AAAA": 123, + "ANY": 3423, + "SRV": 345, + "SOA": 7567, + "PTR": 456, + "TXT": 85, + "NAPTR": 346, + "MX": 457, + "DS": 456, + "RRSIG": 345, + "DNSKEY": 55, + "NS": 868, + "SVCB": 645, + "HTTPS": 4, + "OTHER": 845 + }, + "status": { + "UNKNOWN": 3, + "GRAVITY": 72, + "FORWARDED": 533, + "CACHE": 32, + "REGEX": 84, + "DENYLIST": 31, + "EXTERNAL_BLOCKED_IP": 0, + "EXTERNAL_BLOCKED_NULL": 0, + "EXTERNAL_BLOCKED_NXRA": 0, + "GRAVITY_CNAME": 0, + "REGEX_CNAME": 0, + "DENYLIST_CNAME": 0, + "RETRIED": 0, + "RETRIED_DNSSEC": 0, + "IN_PROGRESS": 0, + "DBBUSY": 0, + "SPECIAL_DOMAIN": 0, + "CACHE_STALE": 0 + }, + "replies": { + "UNKNOWN": 3, + "NODATA": 72, + "NXDOMAIN": 533, + "CNAME": 32, + "IP": 84, + "DOMAIN": 31, + "RRNAME": 0, + "SERVFAIL": 0, + "REFUSED": 0, + "NOTIMP": 0, + "OTHER": 0, + "DNSSEC": 31, + "NONE": 0, + "BLOB": 0 + } + }, + "clients": {"active": 10, "total": 22}, + "gravity": { + "domains_being_blocked": 104756, + "last_update": 1725194639 + }, + "took": 0.003 + }, + { + "ftl": { + "database": { + "gravity": 67906, + "groups": 6, + "lists": 1, + "clients": 5, + "domains": {"allowed": 10, "denied": 3} + }, + "privacy_level": 0, + "clients": {"total": 10, "active": 8}, + "pid": 1234, + "uptime": 123456789, + "%mem": 0.1, + "%cpu": 1.2, + "allow_destructive": true, + "dnsmasq": { + "dns_cache_inserted": 8, + "dns_cache_live_freed": 0, + "dns_queries_forwarded": 2, + "dns_auth_answered": 0, + "dns_local_answered": 74, + "dns_stale_answered": 0, + "dns_unanswered": 0, + "bootp": 0, + "pxe": 0, + "dhcp_ack": 0, + "dhcp_decline": 0, + "dhcp_discover": 0, + "dhcp_inform": 0, + "dhcp_nak": 0, + "dhcp_offer": 0, + "dhcp_release": 0, + "dhcp_request": 0, + "noanswer": 0, + "leases_allocated_4": 0, + "leases_pruned_4": 0, + "leases_allocated_6": 0, + "leases_pruned_6": 0, + "tcp_connections": 0, + "dnssec_max_crypto_use": 0, + "dnssec_max_sig_fail": 0, + "dnssec_max_work": 0 + } + }, + "took": 0.003 + }, + {"blocking": "enabled", "timer": 15, "took": 0.003}, + { + "domains": [ + {"domain": "pi-hole.net", "count": 8516} + ], + "total_queries": 29160, + "blocked_queries": 6379, + "took": 0.003 + }, + { + "domains": [ + {"domain": "pi-hole.net", "count": 8516} + ], + "total_queries": 29160, + "blocked_queries": 6379, + "took": 0.003 + }, + { + "clients": [ + {"ip": "192.168.0.44", "name": "raspberrypi.lan", "count": 5896} + ], + "total_queries": 29160, + "blocked_queries": 6379, + "took": 0.003 + }, + { + "clients": [ + {"ip": "192.168.0.44", "name": "raspberrypi.lan", "count": 5896} + ], + "total_queries": 29160, + "blocked_queries": 6379, + "took": 0.003 + }, + { + "upstreams": [ + { + "ip": "blocklist", + "name": "blocklist", + "port": -1, + "count": 0, + "statistics": {"response": 0, "variance": 0} + }, + { + "ip": "cache", + "name": "cache", + "port": -1, + "count": 2, + "statistics": {"response": 0, "variance": 0} + }, + { + "ip": "8.8.8.8", + "name": "dns.google", + "port": 53, + "count": 8, + "statistics": { + "response": 0.0516872935824924, + "variance": 0.0049697216173868828 + } + }, + ], + "total_queries": 8, + "forwarded_queries": 6, + "took": 5.6982040405273438e-05 + } + ]; + for (int i = 0; i < urls.length; i++) { + when(mockClient.get( + Uri.parse(urls[i]), + headers: anyNamed('headers'), + )).thenAnswer((_) async => http.Response(jsonEncode(data[i]), 200)); + } + + final response = await apiGateway.realtimeStatus(); + + expect(response.result, APiResponseType.success); + expect(response.data, isNotNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + for (final url in urls) { + when(mockClient.get(Uri.parse(url), headers: {})) + .thenThrow(Exception('Unexpected error test')); + } + + final response = await apiGateway.realtimeStatus(); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + }); + }); + + group('disableServerRequest', () { + late Server server; + final url = 'http://example.com/api/dns/blocking'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + server.sm.savePassword('xxx123'); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = {"blocking": "disabled", "timer": 15, "took": 0.003}; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({"blocking": false, "timer": 15}))) + .thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final response = await apiGateway.disableServerRequest(15); + + expect(response.result, APiResponseType.success); + expect(response.status, 'disabled'); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({"blocking": false, "timer": 15}))) + .thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway.disableServerRequest(5); + + expect(response.result, APiResponseType.error); + expect(response.status, isNull); + }); + }); + + group('enableServerRequest', () { + late Server server; + final url = 'http://example.com/api/dns/blocking'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = {"blocking": "enabled", "timer": null, "took": 0.03}; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({"blocking": true, "timer": null}))) + .thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final response = await apiGateway.enableServerRequest(); + + expect(response.result, APiResponseType.success); + expect(response.status, 'enabled'); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({"blocking": true, "timer": null}))) + .thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway.enableServerRequest(); + + expect(response.result, APiResponseType.error); + expect(response.status, isNull); + }); + }); + + group('fetchOverTimeData', () { + late Server server; + final urls = [ + 'http://example.com/api/history', + 'http://example.com/api/history/clients' + ]; + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = [ + { + "history": [ + { + "timestamp": 1511819900.539157, + "total": 2134, + "cached": 525, + "blocked": 413, + "forwarded": 1196 + }, + { + "timestamp": 1511820500.583821, + "total": 2014, + "cached": 52, + "blocked": 43, + "forwarded": 1910 + } + ], + "took": 0.003 + }, + { + "clients": { + "127.0.0.1": {"name": "localhost", "total": 13428}, + "::1": {"name": "ip6-localnet", "total": 2100}, + "192.168.1.1": {"name": null, "total": 254}, + "::": {"name": "pi.hole", "total": 29}, + "0.0.0.0": {"name": "other clients", "total": 14} + }, + "history": [ + { + "timestamp": 1511819900.539157, + "data": { + "127.0.0.1": 35, + "::1": 63, + "192.168.1.1": 20, + "::": 9, + "0.0.0.0": 0 + } + }, + { + "timestamp": 1511820500.583821, + "data": {"127.0.0.1": 10, "::1": 44, "192.168.1.1": 56, "::": 52} + } + ], + "took": 0.003 + }, + ]; + + for (int i = 0; i < urls.length; i++) { + when(mockClient.get( + Uri.parse(urls[i]), + headers: anyNamed('headers'), + )).thenAnswer((_) async => http.Response(jsonEncode(data[i]), 200)); + } + + final response = await apiGateway.fetchOverTimeData(); + + expect(response.result, APiResponseType.success); + expect(response.data, isNotNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + for (final url in urls) { + when(mockClient.get(Uri.parse(url), headers: {})) + .thenThrow(Exception('Unexpected error test')); + } + + final response = await apiGateway.fetchOverTimeData(); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + }); + }); + + group('fetchLogs', () { + late Server server; + final url = + 'http://example.com/api/queries?from=1733472267&until=1733479467'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "queries": [ + { + "id": 1, + "time": 1581907991.539157, + "type": "A", + "domain": "community.stoplight.io", + "cname": null, + "status": "FORWARDED", + "client": {"ip": "192.168.0.14", "name": "desktop.lan"}, + "dnssec": "INSECURE", + "reply": {"type": "IP", "time": 19}, + "list_id": null, + "upstream": "localhost#5353", + "dbid": 112421354 + }, + { + "id": 2, + "time": 1581907871.583821, + "type": "AAAA", + "domain": "api.github.com", + "cname": null, + "status": "FORWARDED", + "client": {"ip": "127.0.0.1", "name": "localhost"}, + "dnssec": "UNKNOWN", + "reply": {"type": "IP", "time": 12.3}, + "list_id": null, + "upstream": "localhost#5353", + "dbid": 112421355 + } + ], + "cursor": 175881, + "recordsTotal": 1234, + "recordsFiltered": 1234, + "draw": 1, + "took": 0.003 + }; + when(mockClient.get(Uri.parse(url), headers: anyNamed('headers'))) + .thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final from = DateTime.fromMillisecondsSinceEpoch(1733472267 * 1000); + final until = DateTime.fromMillisecondsSinceEpoch(1733479467 * 1000); + final response = await apiGateway.fetchLogs(from, until); + + expect(response.result, APiResponseType.success); + expect(response.data, isNotNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get(Uri.parse(url), headers: anyNamed('headers'))) + .thenThrow(Exception('Unexpected error test')); + + final from = DateTime.fromMillisecondsSinceEpoch(1733472267 * 1000); + final until = DateTime.fromMillisecondsSinceEpoch(1733479467 * 1000); + final response = await apiGateway.fetchLogs(from, until); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + }); + }); + + group('setWhiteBlacklist', () { + late Server server; + final url = 'http://example.com/api/domains/deny/exact'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success when add new domain', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "domains": [ + { + "domain": "google.com", + "unicode": "google.com", + "type": "deny", + "kind": "exact", + "comment": null, + "groups": [0], + "enabled": true, + "id": 1, + "date_added": 1734008144, + "date_modified": 1734008144 + } + ], + "processed": { + "errors": [], + "success": [ + {"item": "google.com"} + ] + }, + "took": 0.0042212009429931641 + }; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({ + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + }))).thenAnswer((_) async => http.Response(jsonEncode(data), 201)); + + final response = + await apiGateway.setWhiteBlacklist('google.com', 'black'); + + expect(response.result, APiResponseType.success); + expect(response.data!.toJson(), + {'success': true, 'message': 'Added google.com'}); + expect(response.message, isNull); + }); + + test('Return success when add exist domain', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "domains": [ + { + "domain": "google.com", + "unicode": "google.com", + "type": "deny", + "kind": "exact", + "comment": null, + "groups": [0], + "enabled": true, + "id": 8, + "date_added": 1734005851, + "date_modified": 1734005851 + } + ], + "processed": { + "errors": [ + { + "item": "google.com", + "error": + "UNIQUE constraint failed: domainlist.domain, domainlist.type" + } + ], + "success": [] + }, + "took": 0.000306844711303711 + }; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({ + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + }))).thenAnswer((_) async => http.Response(jsonEncode(data), 201)); + + final response = + await apiGateway.setWhiteBlacklist('google.com', 'black'); + + expect(response.result, APiResponseType.success); + expect(response.data!.toJson(), { + 'success': false, + 'message': + 'UNIQUE constraint failed: domainlist.domain, domainlist.type' + }); + expect(response.message, isNull); + }); + + test('Return error with invalid list type', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "error": { + "key": "uri_error", + "message": "Invalid request: Specify list to modify more precisely", + "hint": "/api/domains/xxxx/exact" + }, + "took": 0.00055241584777832031 + }; + when(mockClient.post(Uri.parse(url), headers: anyNamed('headers'), body: { + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + })).thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final response = + await apiGateway.setWhiteBlacklist('google.com', 'black'); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + expect(response.message, isNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get(Uri.parse(url), headers: {})) + .thenThrow(Exception('Unexpected error test')); + + final response = + await apiGateway.setWhiteBlacklist('google.com', 'black'); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + expect(response.message, isNull); + }); + }); + + group('getDomainLists', () { + late Server server; + final url = 'http://example.com/api/domains'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "domains": [ + { + "domain": "allowed.com", + "unicode": "allowed.com", + "type": "allow", + "kind": "exact", + "comment": null, + "groups": [0], + "enabled": true, + "id": 299, + "date_added": 1611239095, + "date_modified": 1612163756 + }, + { + "domain": "xn--4ca.com", + "unicode": "ä.com", + "type": "allow", + "kind": "regex", + "comment": "Some text", + "groups": [0], + "enabled": true, + "id": 305, + "date_added": 1611240635, + "date_modified": 1611241276 + } + ], + "took": 0.012, + "processed": null + }; + when(mockClient.get(Uri.parse(url), headers: anyNamed('headers'))) + .thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final response = await apiGateway.getDomainLists(); + + expect(response.result, APiResponseType.success); + expect(response.data, isNotNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + when(mockClient.get(Uri.parse(url), headers: {})) + .thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway.getDomainLists(); + + expect(response.result, APiResponseType.error); + expect(response.data, isNull); + }); + }); + + group('removeDomainFromList', () { + late Server server; + final url = 'http://example.com/api/domains/allow/exact/google.com'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = {"success": true, "message": null}; + when(mockClient.delete(Uri.parse(url), headers: anyNamed('headers'))) + .thenAnswer((_) async => http.Response(jsonEncode(data), 204)); + + final response = await apiGateway.removeDomainFromList(Domain( + id: 1, + domain: 'google.com', + type: 0, + enabled: 1, + dateAdded: DateTime.now(), + dateModified: DateTime.now(), + comment: '', + groups: [])); + + expect(response.result, APiResponseType.success); + expect(response.message, isNull); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.delete(Uri.parse(url), headers: anyNamed('headers'))) + .thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway.removeDomainFromList(Domain( + id: 1, + domain: 'google.com', + type: 0, + enabled: 1, + dateAdded: DateTime.now(), + dateModified: DateTime.now(), + comment: '', + groups: [])); + + expect(response.result, APiResponseType.error); + expect(response.message, isNull); + }); + }); + + group('addDomainToList', () { + late Server server; + final url = 'http://example.com/api/domains/deny/exact'; + + setUp(() { + server = Server( + address: 'http://example.com', + alias: 'example', + defaultServer: true, + apiVersion: SupportedApiVersions.v6, + ); + }); + + test('Return success when add new domain', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "domains": [ + { + "domain": "google.com", + "unicode": "google.com", + "type": "deny", + "kind": "exact", + "comment": null, + "groups": [0], + "enabled": true, + "id": 1, + "date_added": 1734008144, + "date_modified": 1734008144 + } + ], + "processed": { + "errors": [], + "success": [ + {"item": "google.com"} + ] + }, + "took": 0.0042212009429931641 + }; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({ + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + }))).thenAnswer((_) async => http.Response(jsonEncode(data), 201)); + + final response = await apiGateway + .addDomainToList({"list": "black", "domain": "google.com"}); + + expect(response.result, APiResponseType.success); + }); + + test('Return success when add exist domain', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "domains": [ + { + "domain": "google.com", + "unicode": "google.com", + "type": "deny", + "kind": "exact", + "comment": null, + "groups": [0], + "enabled": true, + "id": 8, + "date_added": 1734005851, + "date_modified": 1734005851 + } + ], + "processed": { + "errors": [ + { + "item": "google.com", + "error": + "UNIQUE constraint failed: domainlist.domain, domainlist.type" + } + ], + "success": [] + }, + "took": 0.000306844711303711 + }; + when(mockClient.post(Uri.parse(url), + headers: anyNamed('headers'), + body: jsonEncode({ + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + }))).thenAnswer((_) async => http.Response(jsonEncode(data), 201)); + + final response = await apiGateway + .addDomainToList({"list": "black", "domain": "google.com"}); + + expect(response.result, APiResponseType.alreadyAdded); + }); + + test('Return error with invalid list type', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + final data = { + "error": { + "key": "uri_error", + "message": "Invalid request: Specify list to modify more precisely", + "hint": "/api/domains/xxxx/exact" + }, + "took": 0.00055241584777832031 + }; + when(mockClient.post(Uri.parse(url), headers: anyNamed('headers'), body: { + "domain": "google.com", + "comment": null, + "groups": [0], + "enabled": true + })).thenAnswer((_) async => http.Response(jsonEncode(data), 200)); + + final response = await apiGateway + .addDomainToList({"list": "black", "domain": "google.com"}); + + expect(response.result, APiResponseType.error); + }); + + test('Return error when unexpected exception occurs', () async { + final mockClient = MockClient(); + final apiGateway = ApiGatewayV6(server, client: mockClient); + + when(mockClient.get(Uri.parse(url), headers: {})) + .thenThrow(Exception('Unexpected error test')); + + final response = await apiGateway + .addDomainToList({"list": "black", "domain": "google.com"}); + + expect(response.result, APiResponseType.error); + }); + }); +} diff --git a/test/gateways/v6/api_gateway_v6_test.mocks.dart b/test/gateways/v6/api_gateway_v6_test.mocks.dart new file mode 100644 index 00000000..b77ec812 --- /dev/null +++ b/test/gateways/v6/api_gateway_v6_test.mocks.dart @@ -0,0 +1,282 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in pi_hole_client/test/gateways/v6/api_gateway_v6_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i3; +import 'dart:convert' as _i4; +import 'dart:typed_data' as _i6; + +import 'package:http/http.dart' as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i5; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { + _FakeResponse_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeStreamedResponse_1 extends _i1.SmartFake + implements _i2.StreamedResponse { + _FakeStreamedResponse_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [Client]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockClient extends _i1.Mock implements _i2.Client { + MockClient() { + _i1.throwOnMissingStub(this); + } + + @override + _i3.Future<_i2.Response> head( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future<_i2.Response> get( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future<_i2.Response> post( + Uri? url, { + Map? headers, + Object? body, + _i4.Encoding? encoding, + }) => + (super.noSuchMethod( + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future<_i2.Response> put( + Uri? url, { + Map? headers, + Object? body, + _i4.Encoding? encoding, + }) => + (super.noSuchMethod( + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future<_i2.Response> patch( + Uri? url, { + Map? headers, + Object? body, + _i4.Encoding? encoding, + }) => + (super.noSuchMethod( + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future<_i2.Response> delete( + Uri? url, { + Map? headers, + Object? body, + _i4.Encoding? encoding, + }) => + (super.noSuchMethod( + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + )), + ) as _i3.Future<_i2.Response>); + + @override + _i3.Future read( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future.value(_i5.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + )), + ) as _i3.Future); + + @override + _i3.Future<_i6.Uint8List> readBytes( + Uri? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), + ) as _i3.Future<_i6.Uint8List>); + + @override + _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: + _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( + this, + Invocation.method( + #send, + [request], + ), + )), + ) as _i3.Future<_i2.StreamedResponse>); + + @override + void close() => super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); +}