├── .circleci └── config.yml ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── semantic.yml ├── .gitignore ├── .jazzy.yml ├── .swift-version ├── .swiftlint.yml ├── CHANGELOG.md ├── Examples ├── AsyncAwait │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── AsyncAwait │ │ └── AsyncAwait.swift ├── CreateNewBucket │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── CreateNewBucket │ │ └── CreateNewBucket.swift ├── DeleteData │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── DeleteData │ │ └── DeleteData.swift ├── InfluxDBStatus │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── InfluxDBStatus │ │ └── InfluxDBStatus.swift ├── InvokableScripts │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── InvokableScripts │ │ └── InvokableScripts.swift ├── ParameterizedQuery │ ├── .swiftlint.yml │ ├── Images │ │ ├── api-token.png │ │ ├── create-bucket.png │ │ ├── generate-api-token.png │ │ └── organization-settings.png │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ └── ParameterizedQuery │ │ │ └── ParameterizedQuery.swift │ └── telegraf.conf ├── QueryCpu │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ └── QueryCpu │ │ │ └── QueryCpu.swift │ └── telegraf.conf ├── QueryCpuData │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ └── QueryCpuData │ │ │ └── QueryCpuData.swift │ └── telegraf.conf ├── README.md ├── RecordRow │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── RecordRow │ │ └── RecordRow.swift ├── WriteData │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── WriteData │ │ └── WriteData.swift └── WriteDataInBatches │ ├── .swiftlint.yml │ ├── Package.swift │ ├── README.md │ └── Sources │ └── WriteDataInBatches │ ├── main.swift │ └── vix-daily.csv ├── LICENSE ├── Makefile ├── Package.swift ├── README.md ├── Scripts ├── generate-sources.sh ├── influxdb-onboarding.sh ├── influxdb-restart.sh ├── pom.xml ├── publish-site.sh └── templates │ ├── APIs.mustache │ ├── CodableHelper.mustache │ ├── Extensions.mustache │ ├── JSONDataEncoding.mustache │ ├── JSONEncodingHelper.mustache │ ├── Models.mustache │ ├── OpenISO8601DateFormatter.mustache │ ├── api.mustache │ └── libraries │ └── urlsession │ └── URLSessionImplementations.mustache ├── Sources ├── InfluxDBSwift │ ├── DeleteAPI.swift │ ├── FluxCSVParser.swift │ ├── Generated │ │ ├── APIHelper.swift │ │ ├── CodableHelper.swift │ │ ├── Cursor.swift │ │ ├── Models │ │ │ ├── DeletePredicateRequest.swift │ │ │ ├── Dialect.swift │ │ │ ├── Query.swift │ │ │ ├── Script.swift │ │ │ ├── ScriptCreateRequest.swift │ │ │ ├── ScriptInvocationParams.swift │ │ │ ├── ScriptLanguage.swift │ │ │ ├── ScriptUpdateRequest.swift │ │ │ └── Scripts.swift │ │ └── OpenISO8601DateFormatter.swift │ ├── InfluxDBClient.swift │ ├── Internal │ │ └── LoggingHelper.swift │ ├── InvokableScriptsAPI.swift │ ├── Point.swift │ ├── QueryAPI.swift │ └── WriteAPI.swift └── InfluxDBSwiftApis │ ├── Generated │ ├── APIs.swift │ ├── APIs │ │ ├── AuthorizationsAPI.swift │ │ ├── BucketsAPI.swift │ │ ├── DBRPsAPI.swift │ │ ├── HealthAPI.swift │ │ ├── LabelsAPI.swift │ │ ├── OrganizationsAPI.swift │ │ ├── PingAPI.swift │ │ ├── ReadyAPI.swift │ │ ├── ScraperTargetsAPI.swift │ │ ├── SecretsAPI.swift │ │ ├── SetupAPI.swift │ │ ├── SourcesAPI.swift │ │ ├── TasksAPI.swift │ │ ├── UsersAPI.swift │ │ └── VariablesAPI.swift │ ├── Extensions.swift │ ├── JSONDataEncoding.swift │ ├── JSONEncodingHelper.swift │ ├── Models.swift │ ├── Models │ │ ├── AddResourceMemberRequestBody.swift │ │ ├── Authorization.swift │ │ ├── AuthorizationLinks.swift │ │ ├── AuthorizationPostRequest.swift │ │ ├── AuthorizationUpdateRequest.swift │ │ ├── Authorizations.swift │ │ ├── Bucket.swift │ │ ├── BucketLinks.swift │ │ ├── Buckets.swift │ │ ├── DBRP.swift │ │ ├── DBRPCreate.swift │ │ ├── DBRPGet.swift │ │ ├── DBRPUpdate.swift │ │ ├── DBRPs.swift │ │ ├── HealthCheck.swift │ │ ├── IsOnboarding.swift │ │ ├── Label.swift │ │ ├── LabelCreateRequest.swift │ │ ├── LabelMapping.swift │ │ ├── LabelResponse.swift │ │ ├── LabelUpdate.swift │ │ ├── LabelsResponse.swift │ │ ├── Links.swift │ │ ├── LogEvent.swift │ │ ├── Logs.swift │ │ ├── OnboardingRequest.swift │ │ ├── OnboardingResponse.swift │ │ ├── Organization.swift │ │ ├── OrganizationLinks.swift │ │ ├── Organizations.swift │ │ ├── PasswordResetBody.swift │ │ ├── PatchBucketRequest.swift │ │ ├── PatchOrganizationRequest.swift │ │ ├── PatchRetentionRule.swift │ │ ├── Permission.swift │ │ ├── PostBucketRequest.swift │ │ ├── PostOrganizationRequest.swift │ │ ├── Ready.swift │ │ ├── Resource.swift │ │ ├── ResourceMember.swift │ │ ├── ResourceMembers.swift │ │ ├── ResourceMembersLinks.swift │ │ ├── ResourceOwner.swift │ │ ├── ResourceOwners.swift │ │ ├── RetentionRule.swift │ │ ├── Run.swift │ │ ├── RunLinks.swift │ │ ├── RunManually.swift │ │ ├── Runs.swift │ │ ├── SchemaType.swift │ │ ├── ScraperTargetRequest.swift │ │ ├── ScraperTargetResponse.swift │ │ ├── ScraperTargetResponseAllOfLinks.swift │ │ ├── ScraperTargetResponses.swift │ │ ├── SecretKeys.swift │ │ ├── SecretKeysResponse.swift │ │ ├── SecretKeysResponseAllOfLinks.swift │ │ ├── Source.swift │ │ ├── SourceLinks.swift │ │ ├── Sources.swift │ │ ├── Task.swift │ │ ├── TaskCreateRequest.swift │ │ ├── TaskLinks.swift │ │ ├── TaskStatusType.swift │ │ ├── TaskUpdateRequest.swift │ │ ├── Tasks.swift │ │ ├── User.swift │ │ ├── UserResponse.swift │ │ ├── UserResponseLinks.swift │ │ ├── Users.swift │ │ ├── Variable.swift │ │ ├── VariableLinks.swift │ │ ├── VariableProperties.swift │ │ └── Variables.swift │ ├── SynchronizedDictionary.swift │ └── URLSessionImplementations.swift │ └── InfluxDB2API.swift ├── Tests ├── .swiftlint.yml ├── InfluxDBSwiftApisTests │ ├── AuthorizationsAPITests.swift │ ├── BucketsAPITests.swift │ ├── DBRPsAPITests.swift │ ├── HealthAPITests.swift │ ├── InfluxDB2APITests.swift │ ├── LabelsAPITests.swift │ ├── OrganizationsAPITests.swift │ ├── PingAPITests.swift │ ├── ReadyAPITests.swift │ ├── ScraperTargetsAPITests.swift │ ├── SecretsAPITests.swift │ ├── SetupAPITests.swift │ ├── SourcesAPITests.swift │ ├── TasksAPITests.swift │ ├── UsersAPITests.swift │ ├── VariablesAPITests.swift │ └── XCTestManifests.swift ├── InfluxDBSwiftTests │ ├── AAJunitReportInitializerTests.swift │ ├── DeleteAPITests.swift │ ├── FluxCSVParserTests.swift │ ├── InfluxDBClientTests.swift │ ├── IntegrationTests.swift │ ├── InvokableScriptsAPITests.swift │ ├── MockHTTP.swift │ ├── PointSettingsTests.swift │ ├── PointTests.swift │ ├── QueryAPITests.swift │ ├── WriteAPITests.swift │ └── XCTestManifests.swift └── LinuxMain.swift └── codecov.yml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | **Describe the bug** 7 | A clear and concise description of what the bug is. 8 | 9 | **To Reproduce** 10 | Steps to reproduce the behavior: 11 | 1. step1 12 | 2. ... 13 | 14 | **Expected behavior** 15 | A clear and concise description of what you expected to happen. 16 | 17 | **Specifications:** 18 | - Client Version: 19 | - InfluxDB Version: 20 | - Platform: 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Opening a feature request kicks off a discussion 4 | --- 5 | 6 | 14 | 15 | **Proposal:** 16 | Short summary of the feature. 17 | 18 | **Current behavior:** 19 | Describe what currently happens. 20 | 21 | **Desired behavior:** 22 | Describe what you want. 23 | 24 | **Alternatives considered:** 25 | Describe other solutions or features you considered. 26 | 27 | **Use case:** 28 | Why is this important (helps with prioritizing requests)? 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Closes # 2 | 3 | ## Proposed Changes 4 | 5 | _Briefly describe your proposed changes:_ 6 | 7 | ## Checklist 8 | 9 | - [ ] CHANGELOG.md updated 10 | - [ ] Rebased/mergeable 11 | - [ ] A test has been added if appropriate 12 | - [ ] `swift test` completes successfully 13 | - [ ] Commit messages are [conventional](https://www.conventionalcommits.org/en/v1.0.0/) 14 | - [ ] Sign [CLA](https://www.influxdata.com/legal/cla/) (if not already signed) 15 | -------------------------------------------------------------------------------- /.github/workflows/semantic.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Semantic PR and Commit Messages" 3 | 4 | on: 5 | pull_request: 6 | types: [opened, reopened, synchronize, edited] 7 | branches: 8 | - master 9 | 10 | jobs: 11 | semantic: 12 | uses: influxdata/validate-semantic-github-messages/.github/workflows/semantic.yml@main 13 | with: 14 | CHECK_PR_TITLE_OR_ONE_COMMIT: true 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | Packages/ 41 | Package.pins 42 | Package.resolved 43 | *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | 92 | # JetBrains 93 | .idea/ 94 | 95 | # Documentation 96 | docs/ 97 | doc*.json 98 | SourceKitten/ 99 | 100 | # Swagger 101 | .m2/ 102 | 103 | # Junit 104 | junit.xml 105 | tests.xml 106 | 107 | Scripts/*.yml 108 | Scripts/influxdb-clients-apigen/ 109 | .DS_Store 110 | -------------------------------------------------------------------------------- /.jazzy.yml: -------------------------------------------------------------------------------- 1 | author: InfluxData 2 | author_url: https://www.influxdata.com 3 | github_url: https://github.com/influxdata/influxdb-client-swift 4 | module: influxdb_client_swift 5 | swift_build_tool: spm 6 | theme: fullwidth 7 | clean: true 8 | 9 | custom_categories: 10 | - name: Client 11 | children: 12 | - InfluxDBClient 13 | - WriteAPI 14 | - QueryAPI 15 | - DeleteAPI 16 | - Query 17 | - Dialect 18 | - DeletePredicateRequest 19 | 20 | - name: APIs 21 | children: 22 | - InfluxDB2API 23 | 24 | - name: APIs / Models 25 | children: 26 | - AddResourceMemberRequestBody 27 | - Authorization 28 | - AuthorizationAllOfLinks 29 | - Authorizations 30 | - AuthorizationUpdateRequest 31 | - Bucket 32 | - BucketLinks 33 | - Buckets 34 | - DBRP 35 | - DBRPUpdate 36 | - DBRPs 37 | - HealthCheck 38 | - IsOnboarding 39 | - Label 40 | - LabelCreateRequest 41 | - LabelMapping 42 | - LabelResponse 43 | - LabelUpdate 44 | - LabelsResponse 45 | - Links 46 | - LogEvent 47 | - Logs 48 | - OnboardingRequest 49 | - OnboardingResponse 50 | - Organization 51 | - Organizations 52 | - OrganizationLinks 53 | - PasswordResetBody 54 | - Permission 55 | - PostBucketRequest 56 | - Ready 57 | - Resource 58 | - ResourceMember 59 | - ResourceMembers 60 | - ResourceOwner 61 | - ResourceOwners 62 | - RetentionRule 63 | - Run 64 | - RunLinks 65 | - RunLog 66 | - RunManually 67 | - Runs 68 | - ScraperTargetRequest 69 | - ScraperTargetResponse 70 | - ScraperTargetResponseAllOfLinks 71 | - ScraperTargetResponses 72 | - SecretKeysResponse 73 | - SecretKeysResponseAllOfLinks 74 | - SecretKeys 75 | - Source 76 | - SourceLinks 77 | - Sources 78 | - Task 79 | - TaskCreateRequest 80 | - TaskLinks 81 | - TaskUpdateRequest 82 | - TaskStatusType 83 | - Tasks 84 | - User 85 | - Users 86 | - UserLinks 87 | - UsersLinks 88 | - Variable 89 | - VariableLinks 90 | - VariableProperties 91 | - Variables 92 | 93 | - name: Supporting Files 94 | children: 95 | - AnyCursor 96 | - APIHelper 97 | - CodableHelper 98 | - Cursor 99 | - DecodableRequestBuilderError 100 | - DownloadException 101 | - HTTPMethod 102 | - JSONDataEncoding 103 | - JSONEncodingHelper 104 | - KeyedDecodingContainerProtocol 105 | - KeyedEncodingContainerProtocol 106 | - OpenISO8601DateFormatter 107 | - ParameterEncoding 108 | - Response 109 | - String -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.3 -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - force_unwrapping 15 | - implicit_return 16 | - missing_docs 17 | - modifier_order 18 | - multiline_arguments 19 | - multiline_literal_brackets 20 | - multiline_parameters 21 | - operator_usage_whitespace 22 | - pattern_matching_keywords 23 | - redundant_nil_coalescing 24 | - redundant_type_annotation 25 | - sorted_first_last 26 | - sorted_imports 27 | - trailing_closure 28 | - unneeded_parentheses_in_closure_argument 29 | - unused_import 30 | - unused_declaration 31 | - vertical_parameter_alignment_on_call 32 | - vertical_whitespace_closing_braces 33 | - vertical_whitespace_opening_braces 34 | 35 | excluded: 36 | - build 37 | - .build 38 | - Examples 39 | - Package.swift 40 | - Sources/InfluxDBSwift/Generated 41 | - Sources/InfluxDBSwiftApis/Generated 42 | - Tests/LinuxMain.swift 43 | - Tests/InfluxDBSwiftTests/XCTestManifests.swift 44 | - Tests/InfluxDBSwiftApisTests/XCTestManifests.swift 45 | 46 | type_body_length: 47 | warning: 500 48 | 49 | file_length: 50 | warning: 1000 51 | 52 | cyclomatic_complexity: 53 | warning: 15 54 | -------------------------------------------------------------------------------- /Examples/AsyncAwait/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/AsyncAwait/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "AsyncAwait", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "async-await", targets: ["AsyncAwait"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "AsyncAwait", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser"), 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/AsyncAwait/README.md: -------------------------------------------------------------------------------- 1 | # AsyncAwait 2 | 3 | This is an example how to use `async/await` with the InfluxDB client. 4 | 5 | ## Prerequisites: 6 | - Docker 7 | - Cloned examples: 8 | ```bash 9 | git clone git@github.com:influxdata/influxdb-client-swift.git 10 | cd Examples/AsyncAwait 11 | ``` 12 | 13 | ## Sources: 14 | - [Package.swift](/Examples/AsyncAwait/Package.swift) 15 | - [AsyncAwait.swift](/Examples/AsyncAwait/Sources/AsyncAwait/AsyncAwait.swift) 16 | 17 | ## How to test: 18 | 1. Start InfluxDB: 19 | ```bash 20 | docker run --rm \ 21 | --name influxdb_v2 \ 22 | --detach \ 23 | --publish 8086:8086 \ 24 | influxdb:latest 25 | ``` 26 | 1. Configure your username, password, organization, bucket and token: 27 | ```bash 28 | docker run --rm \ 29 | --link influxdb_v2 \ 30 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 31 | -H 'accept: application/json' \ 32 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 33 | ``` 34 | 1. Start SwiftCLI by: 35 | ```bash 36 | docker run --rm \ 37 | --link influxdb_v2 \ 38 | --privileged \ 39 | --interactive \ 40 | --tty \ 41 | --volume $PWD/../..:/client \ 42 | --workdir /client/Examples/AsyncAwait \ 43 | swift:5.7 /bin/bash 44 | ``` 45 | 1. Use `async/await` with `WriteAPI`, `QueryAPI` and `BucketsAPI`: 46 | ```bash 47 | swift run async-await --bucket my-bucket --org my-org --token my-token --url http://influxdb_v2:8086 48 | ``` 49 | 50 | ## Expected output 51 | 52 | ```bash 53 | Written data: 54 | > Optional("demo,type=point value=2i") 55 | Query results: 56 | > value: 2 57 | Buckets: 58 | > Optional("10c59301e9077c50"): my-bucket 59 | > Optional("552d1011d2cdab2d"): _tasks 60 | > Optional("a1a02f67f7189b89"): _monitoring 61 | ``` 62 | -------------------------------------------------------------------------------- /Examples/AsyncAwait/Sources/AsyncAwait/AsyncAwait.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/22/2022. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct AsyncAwait: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "The name or id of the bucket destination.") 13 | private var bucket: String 14 | 15 | @Option(name: .shortAndLong, help: "The name or id of the organization destination.") 16 | private var org: String 17 | 18 | @Option(name: .shortAndLong, help: "Authentication token.") 19 | private var token: String 20 | 21 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 22 | private var url: String 23 | } 24 | 25 | extension AsyncAwait { 26 | mutating func run() async throws { 27 | // 28 | // Initialize Client with default Bucket and Organization 29 | // 30 | let client = InfluxDBClient( 31 | url: url, 32 | token: token, 33 | options: InfluxDBClient.InfluxDBOptions(bucket: self.bucket, org: self.org)) 34 | 35 | // 36 | // Asynchronous write 37 | // 38 | let point = InfluxDBClient 39 | .Point("demo") 40 | .addTag(key: "type", value: "point") 41 | .addField(key: "value", value: .int(2)) 42 | try await client.makeWriteAPI().write(point: point) 43 | print("Written data:\n > \(try point.toLineProtocol())") 44 | 45 | // 46 | // Asynchronous query 47 | // 48 | let query = """ 49 | from(bucket: "\(self.bucket)") 50 | |> range(start: -10m) 51 | |> filter(fn: (r) => r["_measurement"] == "demo") 52 | """ 53 | let records = try await client.queryAPI.query(query: query) 54 | print("Query results:") 55 | try records.forEach { print(" > \($0.values["_field"]!): \($0.values["_value"]!)") } 56 | 57 | // 58 | // List all Buckets 59 | // 60 | let api = InfluxDB2API(client: client) 61 | let buckets = try await api.bucketsAPI.getBuckets() 62 | print("Buckets:") 63 | buckets?.buckets?.forEach { print(" > \($0.id): \($0.name)") } 64 | 65 | client.close() 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Examples/CreateNewBucket/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/CreateNewBucket/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "CreateNewBucket", 7 | platforms: [ 8 | .macOS(.v11) 9 | ], 10 | products: [ 11 | .executable(name: "create-new-bucket", targets: ["CreateNewBucket"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "CreateNewBucket", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/CreateNewBucket/README.md: -------------------------------------------------------------------------------- 1 | # CreateNewBucket 2 | 3 | This is an example how to create new bucket with permission to write. 4 | 5 | ## Prerequisites: 6 | - Docker 7 | - Cloned examples: 8 | ```bash 9 | git clone git@github.com:influxdata/influxdb-client-swift.git 10 | cd Examples/CreateNewBucket 11 | ``` 12 | 13 | ## Sources: 14 | - [Package.swift](/Examples/CreateNewBucket/Package.swift) 15 | - [CreateNewBucket.swift](/Examples/CreateNewBucket/Sources/CreateNewBucket/CreateNewBucket.swift) 16 | 17 | 18 | ## How to test: 19 | 1. Start InfluxDB: 20 | ```bash 21 | docker run --rm \ 22 | --name influxdb_v2 \ 23 | --detach \ 24 | --publish 8086:8086 \ 25 | influxdb:latest 26 | ``` 27 | 1. Configure your username, password, organization, bucket and token: 28 | ```bash 29 | docker run --rm \ 30 | --link influxdb_v2 \ 31 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 32 | -H 'accept: application/json' \ 33 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 34 | ``` 35 | 1. Start SwiftCLI by: 36 | ```bash 37 | docker run --rm \ 38 | --link influxdb_v2 \ 39 | --privileged \ 40 | --interactive \ 41 | --tty \ 42 | --volume $PWD/../..:/client \ 43 | --workdir /client/Examples/CreateNewBucket \ 44 | swift:5.7 /bin/bash 45 | ``` 46 | 1. Create a new Bucket by: 47 | ```bash 48 | swift run create-new-bucket --name new-bucket --org my-org --token my-token --url http://influxdb_v2:8086 49 | ``` 50 | ## Expected output 51 | 52 | ```bash 53 | The bucket: 'new-bucket' is successfully created. 54 | The following token could be use to read/write: 55 | 224axj_OaOOVIaEnSQgx2GTrrt18ZqUATS1I0Hsha3M7Bbbsn_yX9EiXTMnlq5aHz-f8h9iNcRJGd1_ImAD7fA== 56 | ``` 57 | -------------------------------------------------------------------------------- /Examples/CreateNewBucket/Sources/CreateNewBucket/CreateNewBucket.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 05/11/2020. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct CreateNewBucket: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "New bucket name.") 13 | private var name: String 14 | 15 | @Option(name: .shortAndLong, help: "Duration bucket will retain data.") 16 | private var retention: Int64 = 3600 17 | 18 | @Option(name: .shortAndLong, help: "Specifies the organization name.") 19 | private var org: String 20 | 21 | @Option(name: .shortAndLong, help: "Authentication token.") 22 | private var token: String 23 | 24 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 25 | private var url: String 26 | } 27 | 28 | extension CreateNewBucket { 29 | mutating func run() async throws { 30 | // Initialize Client and API 31 | let client = InfluxDBClient(url: url, token: token) 32 | let api = InfluxDB2API(client: client) 33 | 34 | let orgId = (try await api.organizationsAPI.getOrgs(org: org)!).orgs?.first?.id 35 | 36 | // Bucket configuration 37 | let request = PostBucketRequest( 38 | orgID: orgId!, 39 | name: name, 40 | retentionRules: [RetentionRule(type: RetentionRule.ModelType.expire, everySeconds: retention)]) 41 | 42 | // Create Bucket 43 | let bucket = try await api.bucketsAPI.postBuckets(postBucketRequest: request)! 44 | 45 | // Create Authorization with permission to read/write created bucket 46 | let bucketResource = Resource( 47 | type: Resource.ModelType.buckets, 48 | id: bucket.id, 49 | orgID: orgId 50 | ) 51 | 52 | // Authorization configuration 53 | let authorizationRequest = AuthorizationPostRequest( 54 | description: "Authorization to read/write bucket: \(name)", 55 | orgID: orgId!, 56 | permissions: [ 57 | Permission(action: Permission.Action.read, resource: bucketResource), 58 | Permission(action: Permission.Action.write, resource: bucketResource) 59 | ]) 60 | 61 | // Create Authorization 62 | let authorization = 63 | try await api.authorizationsAPI.postAuthorizations(authorizationPostRequest: authorizationRequest)! 64 | 65 | print("The bucket: '\(bucket.name)' is successfully created.") 66 | print("The following token could be use to read/write:") 67 | print("\t\(authorization.token!)") 68 | 69 | client.close() 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Examples/DeleteData/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/DeleteData/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "DeleteData", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "delete-data", targets: ["DeleteData"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "DeleteData", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/DeleteData/README.md: -------------------------------------------------------------------------------- 1 | # DeleteData 2 | 3 | This is an example how to delete data with specified predicate. 4 | See delete predicate syntax in InfluxDB docs - [delete-predicate](https://docs.influxdata.com/influxdb/cloud/reference/syntax/delete-predicate/). 5 | 6 | ## Prerequisites: 7 | - Docker 8 | - Cloned examples: 9 | ```bash 10 | git clone git@github.com:influxdata/influxdb-client-swift.git 11 | cd Examples/DeleteData 12 | ``` 13 | 14 | ## Sources: 15 | - [Package.swift](/Examples/DeleteData/Package.swift) 16 | - [DeleteData.swift](/Examples/DeleteData/Sources/DeleteData/DeleteData.swift) 17 | 18 | ## How to test: 19 | 1. Start InfluxDB: 20 | ```bash 21 | docker run --rm \ 22 | --name influxdb_v2 \ 23 | --detach \ 24 | --publish 8086:8086 \ 25 | influxdb:latest 26 | ``` 27 | 1. Configure your username, password, organization, bucket and token: 28 | ```bash 29 | docker run --rm \ 30 | --link influxdb_v2 \ 31 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 32 | -H 'accept: application/json' \ 33 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 34 | ``` 35 | 1. Write following data into InfluxDB: 36 | ```bash 37 | docker exec influxdb_v2 influx write -b my-bucket -o my-org -t my-token \ 38 | " 39 | server,provider=aws,production=no,app=gitlab cpu_usage=98,mem_usage=68 40 | server,provider=azure,production=yes,app=balancer cpu_usage=63,mem_usage=54 41 | server,provider=azure,production=no,app=jira cpu_usage=12,mem_usage=13 42 | server,provider=azure,production=yes,app=db cpu_usage=84,mem_usage=75 43 | server,provider=aws,production=yes,app=web cpu_usage=16,mem_usage=42 44 | " 45 | ``` 46 | 1. Start SwiftCLI by: 47 | ```bash 48 | docker run --rm \ 49 | --link influxdb_v2 \ 50 | --privileged \ 51 | --interactive \ 52 | --tty \ 53 | --volume $PWD/../..:/client \ 54 | --workdir /client/Examples/DeleteData \ 55 | swift:5.7 /bin/bash 56 | ``` 57 | 1. Delete date where tag `production` is `no`: 58 | ```bash 59 | swift run delete-data --org my-org --bucket my-bucket --token my-token --url http://influxdb_v2:8086 \ 60 | --predicate "_measurement=\"server\" AND production=\"no\"" 61 | ``` 62 | 63 | ## Expected output 64 | 65 | ```bash 66 | Deleted data by predicate: 67 | 68 | DeletePredicateRequest(start: 1970-01-01 00:00:00 +0000, stop: 2021-01-07 09:03:24 +0000, predicate: Optional("_measurement=\"server\" AND production=\"no\"")) 69 | 70 | Remaining data after delete: 71 | 72 | azure,production=yes,app=balancer 73 | azure,production=yes,app=db 74 | aws,production=yes,app=web 75 | ``` 76 | -------------------------------------------------------------------------------- /Examples/DeleteData/Sources/DeleteData/DeleteData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 05/11/2020. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct DeleteData: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "Specifies the bucket name to delete data from.") 13 | private var bucket: String 14 | 15 | @Option(name: .shortAndLong, 16 | help: "Specifies the organization name to delete data from.") 17 | private var org: String 18 | 19 | @Option(name: .shortAndLong, help: "Authentication token.") 20 | private var token: String 21 | 22 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 23 | private var url: String 24 | 25 | @Option(name: .shortAndLong, help: "InfluxQL-like delete predicate statement.") 26 | private var predicate: String 27 | } 28 | 29 | extension DeleteData { 30 | mutating func run() async throws { 31 | // Initialize Client with default Organization 32 | let client = InfluxDBClient( 33 | url: url, 34 | token: token, 35 | options: InfluxDBClient.InfluxDBOptions(org: self.org)) 36 | 37 | // Create DeletePredicateRequest 38 | let predicateRequest = DeletePredicateRequest( 39 | start: Date(timeIntervalSince1970: 0), 40 | stop: Date(), 41 | predicate: predicate) 42 | 43 | try await client.deleteAPI.delete(predicate: predicateRequest, bucket: bucket, org: org) 44 | 45 | print("\nDeleted data by predicate:\n\n\t\(predicateRequest)") 46 | 47 | // Print date after Delete 48 | try await queryData(client: client) 49 | 50 | client.close() 51 | } 52 | 53 | private func queryData(client: InfluxDBClient) async throws { 54 | let query = """ 55 | from(bucket: "\(bucket)") 56 | |> range(start: 0) 57 | |> filter(fn: (r) => r["_measurement"] == "server") 58 | |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") 59 | """ 60 | 61 | let response = try await client.queryAPI.query(query: query) 62 | 63 | print("\nRemaining data after delete:\n") 64 | 65 | try response.forEach { record in 66 | let provider = record.values["provider"]! 67 | let production = record.values["production"] 68 | let app = record.values["app"] 69 | return print("\t\(provider),production=\(production!),app=\(app!)") 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Examples/InfluxDBStatus/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/InfluxDBStatus/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "InfluxDBStatus", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "influxdb-status", targets: ["InfluxDBStatus"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "InfluxDBStatus", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/InfluxDBStatus/README.md: -------------------------------------------------------------------------------- 1 | # InfluxDBStatus 2 | 3 | This is an example how to check status of InfluxDB. 4 | 5 | ## Prerequisites: 6 | - Docker 7 | - Cloned examples: 8 | ```bash 9 | git clone git@github.com:influxdata/influxdb-client-swift.git 10 | cd Examples/InfluxDBStatus 11 | ``` 12 | 13 | ## Sources: 14 | - [Package.swift](/Examples/InfluxDBStatus/Package.swift) 15 | - [InfluxDBStatus.swift](/Examples/InfluxDBStatus/Sources/InfluxDBStatus/InfluxDBStatus.swift) 16 | 17 | 18 | ## How to test: 19 | 1. Start InfluxDB: 20 | ```bash 21 | docker run --rm \ 22 | --name influxdb_v2 \ 23 | --detach \ 24 | --publish 8086:8086 \ 25 | influxdb:latest 26 | ``` 27 | 1. Configure your username, password, organization, bucket and token: 28 | ```bash 29 | docker run --rm \ 30 | --link influxdb_v2 \ 31 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 32 | -H 'accept: application/json' \ 33 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 34 | ``` 35 | 1. Start SwiftCLI by: 36 | ```bash 37 | docker run --rm \ 38 | --link influxdb_v2 \ 39 | --privileged \ 40 | --interactive \ 41 | --tty \ 42 | --volume $PWD/../..:/client \ 43 | --workdir /client/Examples/InfluxDBStatus \ 44 | swift:5.7 /bin/bash 45 | ``` 46 | 1. Check status of InfluxDB by: 47 | ```bash 48 | swift run influxdb-status --token my-token --url http://influxdb_v2:8086 49 | ``` 50 | ## Expected output 51 | 52 | ```bash 53 | InfluxDB status: UP, version: v2.4.0, build: OSS 54 | ``` 55 | -------------------------------------------------------------------------------- /Examples/InfluxDBStatus/Sources/InfluxDBStatus/InfluxDBStatus.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 10/13/2021. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct InfluxDBStatus: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "Authentication token.") 13 | private var token: String 14 | 15 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 16 | private var url: String 17 | } 18 | 19 | extension InfluxDBStatus { 20 | mutating func run() async throws { 21 | // Initialize Client and API 22 | let client = InfluxDBClient(url: url, token: token) 23 | let api = InfluxDB2API(client: client) 24 | 25 | let headers = try await api.pingAPI.getPing()! 26 | 27 | let version = headers["X-Influxdb-Version"]! 28 | let build = headers["X-Influxdb-Build"]! 29 | 30 | print("InfluxDB status: UP, version: \(version), build: \(build)") 31 | 32 | client.close() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Examples/InvokableScripts/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/InvokableScripts/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "InvokableScripts", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "invokable-scripts", targets: ["InvokableScripts"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "InvokableScripts", dependencies: [ 19 | .product(name: "InfluxDBSwift", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Images/api-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/influxdata/influxdb-client-swift/787612619545afbf9913b6210da1da7f79092bae/Examples/ParameterizedQuery/Images/api-token.png -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Images/create-bucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/influxdata/influxdb-client-swift/787612619545afbf9913b6210da1da7f79092bae/Examples/ParameterizedQuery/Images/create-bucket.png -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Images/generate-api-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/influxdata/influxdb-client-swift/787612619545afbf9913b6210da1da7f79092bae/Examples/ParameterizedQuery/Images/generate-api-token.png -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Images/organization-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/influxdata/influxdb-client-swift/787612619545afbf9913b6210da1da7f79092bae/Examples/ParameterizedQuery/Images/organization-settings.png -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "ParameterizedQuery", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "parameterized-query", targets: ["ParameterizedQuery"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "ParameterizedQuery", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/README.md: -------------------------------------------------------------------------------- 1 | # ParameterizedQuery 2 | 3 | This is an example how to query with query parameters in InfluxDB Cloud (no support in InfluxDB OSS). 4 | 5 | ## Prerequisites: 6 | - Cloned examples: 7 | ```bash 8 | git clone git@github.com:influxdata/influxdb-client-swift.git 9 | cd Examples/ParameterizedQuery 10 | ``` 11 | 12 | ## Sources: 13 | - [Package.swift](/Examples/ParameterizedQuery/Package.swift) 14 | - [ParameterizedQuery.swift](/Examples/ParameterizedQuery/Sources/ParameterizedQuery/ParameterizedQuery.swift) 15 | 16 | ## How to test: 17 | 1. Start [InfluxDB cloud](https://cloud2.influxdata.com/) 18 | 19 | 20 | 2. Get Url and Organization name - @url, @org 21 | 22 | drawing 23 | 24 | 3. Create bucket - @bucketName 25 | 26 | drawing 27 | 28 | 4. Generate API token - @apiToken 29 | 30 | drawing 31 | drawing 32 | 33 | 34 | 5. Start SwiftCLI by: 35 | ```bash 36 | docker run --rm \ 37 | --link influxdb_v2 \ 38 | --privileged \ 39 | --interactive \ 40 | --tty \ 41 | --volume $PWD/../..:/client \ 42 | --workdir /client/Examples/ParameterizedQuery \ 43 | swift:5.7 /bin/bash 44 | ``` 45 | 46 | 6. Execute Query by: 47 | ```bash 48 | swift run parameterized-query --org @org --bucket @bucketName --token @apiToken --url @url 49 | ``` 50 | 51 | ## Expected output 52 | 53 | ```bash 54 | Query to execute: 55 | 56 | from(bucket: params.bucketParam) 57 | |> range(start: -10m) 58 | |> filter(fn: (r) => r["_measurement"] == params.measurement) 59 | 60 | ["measurement": "demo", "bucketParam": "my-bucket"] 61 | 62 | Success response... 63 | 64 | > value: 1 65 | > value: 2 66 | > value: 3 67 | ``` -------------------------------------------------------------------------------- /Examples/ParameterizedQuery/Sources/ParameterizedQuery/ParameterizedQuery.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Warning: Parameterized Queries are supported only in InfluxDB Cloud, currently there is no support in InfluxDB OSS. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct ParameterizedQuery: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "The bucket to query. The name or id of the bucket destination.") 13 | private var bucket: String 14 | 15 | @Option(name: .shortAndLong, 16 | help: "The organization executing the query. Takes either the `ID` or `Name` interchangeably.") 17 | private var org: String 18 | 19 | @Option(name: .shortAndLong, help: "Authentication token.") 20 | private var token: String 21 | 22 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 23 | private var url: String 24 | } 25 | 26 | extension ParameterizedQuery { 27 | mutating func run() async throws { 28 | // Initialize Client with default Organization 29 | let client = InfluxDBClient( 30 | url: url, 31 | token: token, 32 | options: InfluxDBClient.InfluxDBOptions(bucket: bucket, org: org)) 33 | 34 | for index in 1...3 { 35 | let point = InfluxDBClient 36 | .Point("demo") 37 | .addTag(key: "type", value: "point") 38 | .addField(key: "value", value: .int(index)) 39 | try await client.makeWriteAPI().write(point: point) 40 | } 41 | 42 | // Flux query 43 | let query = """ 44 | from(bucket: params.bucketParam) 45 | |> range(start: -10m) 46 | |> filter(fn: (r) => r["_measurement"] == params.measurement) 47 | """ 48 | 49 | // Query parameters [String:String] 50 | let queryParams = ["bucketParam": "\(bucket)", "measurement": "demo"] 51 | 52 | print("\nQuery to execute:\n\n\(query)\n\n\(queryParams)") 53 | 54 | let records = try await client.queryAPI.query(query: query, params: queryParams) 55 | 56 | print("\nSuccess response...\n") 57 | 58 | try records.forEach { print(" > \($0.values["_field"]!): \($0.values["_value"]!)") } 59 | 60 | client.close() 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Examples/QueryCpu/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/QueryCpu/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "QueryCpu", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "query-cpu", targets: ["QueryCpu"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "QueryCpu", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser"), 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/QueryCpu/README.md: -------------------------------------------------------------------------------- 1 | # QueryCpu 2 | 3 | This is an example how to query data into sequence of `FluxRecord`. 4 | The Telegraf sends data from [CPU Input Plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/cpu/README.md) into InfluxDB 2.x. 5 | 6 | ## Prerequisites: 7 | - Docker 8 | - Cloned examples: 9 | ```bash 10 | git clone git@github.com:influxdata/influxdb-client-swift.git 11 | cd Examples/QueryCpu 12 | ``` 13 | 14 | ## Sources: 15 | - [Package.swift](/Examples/QueryCpu/Package.swift) 16 | - [QueryCpu.swift](/Examples/QueryCpu/Sources/QueryCpu/QueryCpu.swift) 17 | 18 | ## How to test: 19 | 1. Start InfluxDB: 20 | ```bash 21 | docker run --rm \ 22 | --name influxdb_v2 \ 23 | --detach \ 24 | --publish 8086:8086 \ 25 | influxdb:latest 26 | ``` 27 | 1. Configure your username, password, organization, bucket and token: 28 | ```bash 29 | docker run --rm \ 30 | --link influxdb_v2 \ 31 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 32 | -H 'accept: application/json' \ 33 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 34 | ``` 35 | 1. Start Telegraf as a source of data: 36 | ```bash 37 | docker run --rm \ 38 | --name telegraf \ 39 | --link influxdb_v2 \ 40 | --detach \ 41 | --env HOST_ETC=/hostfs/etc \ 42 | --env HOST_PROC=/hostfs/proc \ 43 | --env HOST_SYS=/hostfs/sys \ 44 | --env HOST_VAR=/hostfs/var \ 45 | --env HOST_RUN=/hostfs/run \ 46 | --env HOST_MOUNT_PREFIX=/hostfs \ 47 | --volume /:/hostfs:ro \ 48 | --volume $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \ 49 | telegraf 50 | ``` 51 | 1. Start SwiftCLI by: 52 | ```bash 53 | docker run --rm \ 54 | --link influxdb_v2 \ 55 | --privileged \ 56 | --interactive \ 57 | --tty \ 58 | --volume $PWD/../..:/client \ 59 | --workdir /client/Examples/QueryCpu \ 60 | swift:5.7 /bin/bash 61 | ``` 62 | 1. Execute Query by: 63 | ```bash 64 | swift run query-cpu --org my-org --bucket my-bucket --token my-token --url http://influxdb_v2:8086 65 | ``` 66 | 67 | ## Expected output 68 | 69 | ```bash 70 | Query to execute: 71 | 72 | from(bucket: "my-bucket") 73 | |> range(start: -10m) 74 | |> filter(fn: (r) => r["_measurement"] == "cpu") 75 | |> filter(fn: (r) => r["cpu"] == "cpu-total") 76 | |> filter(fn: (r) => r["_field"] == "usage_user" or r["_field"] == "usage_system") 77 | |> last() 78 | 79 | Success response... 80 | 81 | CPU usage: 82 | usage_system: 22.717622080683473 83 | usage_user: 61.46496815287725 84 | ``` 85 | -------------------------------------------------------------------------------- /Examples/QueryCpu/Sources/QueryCpu/QueryCpu.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 05/11/2020. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct QueryCpu: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "The name or id of the bucket destination.") 13 | private var bucket: String 14 | 15 | @Option(name: .shortAndLong, help: "The name or id of the organization destination.") 16 | private var org: String 17 | 18 | @Option(name: .shortAndLong, help: "Authentication token.") 19 | private var token: String 20 | 21 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 22 | private var url: String 23 | } 24 | 25 | extension QueryCpu { 26 | mutating func run() async throws { 27 | // 28 | // Initialize Client with default Bucket and Organization 29 | // 30 | let client = InfluxDBClient( 31 | url: url, 32 | token: token, 33 | options: InfluxDBClient.InfluxDBOptions(bucket: bucket, org: org)) 34 | 35 | // Flux query 36 | let query = """ 37 | from(bucket: "\(self.bucket)") 38 | |> range(start: -10m) 39 | |> filter(fn: (r) => r["_measurement"] == "cpu") 40 | |> filter(fn: (r) => r["cpu"] == "cpu-total") 41 | |> filter(fn: (r) => r["_field"] == "usage_user" or r["_field"] == "usage_system") 42 | |> last() 43 | """ 44 | 45 | print("\nQuery to execute:\n\(query)\n") 46 | 47 | let records = try await client.queryAPI.query(query: query) 48 | 49 | print("Query results:") 50 | try records.forEach { print(" > \($0.values["_field"]!): \($0.values["_value"]!)") } 51 | 52 | client.close() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Examples/QueryCpuData/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/QueryCpuData/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "QueryCpuData", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "query-cpu-data", targets: ["QueryCpuData"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "QueryCpuData", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser"), 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/QueryCpuData/Sources/QueryCpuData/QueryCpuData.swift: -------------------------------------------------------------------------------- 1 | import ArgumentParser 2 | import Foundation 3 | import InfluxDBSwift 4 | import InfluxDBSwiftApis 5 | 6 | @main 7 | struct QueryCpuData: AsyncParsableCommand { 8 | @Option(name: .shortAndLong, help: "The name or id of the bucket destination.") 9 | private var bucket: String 10 | 11 | @Option(name: .shortAndLong, help: "The name or id of the organization destination.") 12 | private var org: String 13 | 14 | @Option(name: .shortAndLong, help: "Authentication token.") 15 | private var token: String 16 | 17 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 18 | private var url: String 19 | } 20 | 21 | extension QueryCpuData { 22 | mutating func run() async throws { 23 | // 24 | // Initialize Client with default Bucket and Organization 25 | // 26 | let client = InfluxDBClient( 27 | url: url, 28 | token: token, 29 | options: InfluxDBClient.InfluxDBOptions(bucket: bucket, org: org)) 30 | 31 | // Flux query 32 | let query = """ 33 | from(bucket: "\(self.bucket)") 34 | |> range(start: -10m) 35 | |> filter(fn: (r) => r["_measurement"] == "cpu") 36 | |> filter(fn: (r) => r["cpu"] == "cpu-total") 37 | |> filter(fn: (r) => r["_field"] == "usage_user" or r["_field"] == "usage_system") 38 | |> last() 39 | """ 40 | 41 | print("\nQuery to execute:\n\(query)\n") 42 | 43 | let response = try await client.queryAPI.queryRaw(query: query) 44 | 45 | let csv = String(decoding: response, as: UTF8.self) 46 | print("InfluxDB response: \(csv)") 47 | 48 | client.close() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | ## Writes 4 | - [WriteData](WriteData#writedata) - How to write data with Data Point structure 5 | - [WriteDataInBatches](WriteDataInBatches#writedatainbatches) - How to use Combine to prepare batches for write into InfluxDB 6 | 7 | ## Queries 8 | - [QueryCpu](QueryCpu#querycpu) - How to query data into sequence of `FluxRecord` 9 | - [ParameterizedQuery](ParameterizedQuery#parameterizedquery) - How to use parameterized Flux queries 10 | 11 | ## Management 12 | - [CreateNewBucket](CreateNewBucket#createnewbucket) - How to create new bucket with permission to write 13 | 14 | ## Others 15 | - [DeleteData](DeleteData#deletedata) - How to delete data with specified predicate 16 | - [AsyncAwait](AsyncAwait#asyncawait) - How to use `async/await` with the InfluxDB client. 17 | - [InfluxDBStatus](InfluxDBStatus#influxdbstatus) - This is an example how to check status of InfluxDB 18 | - [InvokableScripts](InvokableScripts#invokablescripts) - How to use Invokable scripts Cloud API to create custom endpoints that query data 19 | - [RecordRow](RecordRow#recordrow) - How to use `FluxRecord.row` instead of `FluxRecord.values`, 20 | in case of duplicity column names -------------------------------------------------------------------------------- /Examples/RecordRow/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/RecordRow/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "RecordRow", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "record-row", targets: ["RecordRow"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "RecordRow", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser"), 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/RecordRow/Sources/RecordRow/RecordRow.swift: -------------------------------------------------------------------------------- 1 | import ArgumentParser 2 | import Foundation 3 | import InfluxDBSwift 4 | import InfluxDBSwiftApis 5 | 6 | @main 7 | struct RecordRow: AsyncParsableCommand { 8 | @Option(name: .shortAndLong, help: "The name or id of the bucket destination.") 9 | private var bucket: String 10 | 11 | @Option(name: .shortAndLong, help: "The name or id of the organization destination.") 12 | private var org: String 13 | 14 | @Option(name: .shortAndLong, help: "Authentication token.") 15 | private var token: String 16 | 17 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 18 | private var url: String 19 | } 20 | 21 | extension RecordRow { 22 | mutating func run() async throws { 23 | // 24 | // Creating client 25 | // 26 | let client = InfluxDBClient( 27 | url: url, 28 | token: token, 29 | options: InfluxDBClient.InfluxDBOptions(bucket: bucket, org: org)) 30 | 31 | // 32 | // Write test data into InfluxDB 33 | // 34 | for i in 1...5 { 35 | let point = InfluxDBClient 36 | .Point("point") 37 | .addField(key: "table", value: .string("my-table")) 38 | .addField(key: "result", value: .double(Double(i))) 39 | try await client.makeWriteAPI().write(point: point) 40 | } 41 | 42 | // 43 | // Query data with pivot 44 | // 45 | let query = """ 46 | from(bucket: "\(self.bucket)") 47 | |> range(start: -1m) 48 | |> filter(fn: (r) => (r["_measurement"] == "point")) 49 | |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") 50 | """ 51 | 52 | let records = try await client.queryAPI.query(query: query) 53 | 54 | // 55 | // Write data to output 56 | // 57 | var values: Array = Array() 58 | var row: Array = Array() 59 | 60 | try records.forEach { record in 61 | values.append(record.values.sorted(by: { $0.0 < $1.0 }).map { 62 | val in 63 | "\(val.key): \(val.value)" 64 | } 65 | .joined(separator: ", ")) 66 | row.append(record.row.compactMap { val in 67 | "\(val)" 68 | } 69 | .joined(separator: ", ")) 70 | } 71 | 72 | print("------------------------------------------ FluxRecord.values ------------------------------------------") 73 | print(values.joined(separator: "\n")) 74 | print("-------------------------------------------- FluxRecord.row -------------------------------------------") 75 | print(row.joined(separator: "\n")) 76 | 77 | client.close() 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Examples/WriteData/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/WriteData/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "WriteData", 7 | platforms: [ 8 | .macOS(.v10_15) 9 | ], 10 | products: [ 11 | .executable(name: "write-data", targets: ["WriteData"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2") 16 | ], 17 | targets: [ 18 | .executableTarget(name: "WriteData", dependencies: [ 19 | .product(name: "InfluxDBSwiftApis", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser"), 21 | ]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/WriteData/README.md: -------------------------------------------------------------------------------- 1 | # WriteData 2 | 3 | This is an example how to write data with Data Point structure. 4 | 5 | ## Prerequisites: 6 | - Docker 7 | - Cloned examples: 8 | ```bash 9 | git clone git@github.com:influxdata/influxdb-client-swift.git 10 | cd Examples/WriteData 11 | ``` 12 | 13 | ## Sources: 14 | - [Package.swift](/Examples/WriteData/Package.swift) 15 | - [WriteData.swift](/Examples/WriteData/Sources/WriteData/WriteData.swift) 16 | 17 | ## How to test: 18 | 1. Start InfluxDB: 19 | ```bash 20 | docker run --rm \ 21 | --name influxdb_v2 \ 22 | --detach \ 23 | --publish 8086:8086 \ 24 | influxdb:latest 25 | ``` 26 | 1. Configure your username, password, organization, bucket and token: 27 | ```bash 28 | docker run --rm \ 29 | --link influxdb_v2 \ 30 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 31 | -H 'accept: application/json' \ 32 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 33 | ``` 34 | 1. Start SwiftCLI by: 35 | ```bash 36 | docker run --rm \ 37 | --link influxdb_v2 \ 38 | --privileged \ 39 | --interactive \ 40 | --tty \ 41 | --volume $PWD/../..:/client \ 42 | --workdir /client/Examples/WriteData \ 43 | swift:5.7 /bin/bash 44 | ``` 45 | 1. Write data by: 46 | ```bash 47 | swift run write-data --bucket my-bucket --org my-org --token my-token --url http://influxdb_v2:8086 48 | ``` 49 | 50 | ## Expected output 51 | 52 | ```bash 53 | Written data: 54 | 55 | - Point: measurement:demo, tags:["type": Optional("point")], fields:["value": Optional(2)], time:nil 56 | - Point: measurement:demo, tags:["type": Optional("point-timestamp")], fields:["value": Optional(2)], time:2020-12-10 11:16:29 +0000 57 | 58 | Success! 59 | ``` -------------------------------------------------------------------------------- /Examples/WriteData/Sources/WriteData/WriteData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 05/11/2020. 3 | // 4 | 5 | import ArgumentParser 6 | import Foundation 7 | import InfluxDBSwift 8 | import InfluxDBSwiftApis 9 | 10 | @main 11 | struct WriteData: AsyncParsableCommand { 12 | @Option(name: .shortAndLong, help: "The name or id of the bucket destination.") 13 | private var bucket: String 14 | 15 | @Option(name: .shortAndLong, help: "The name or id of the organization destination.") 16 | private var org: String 17 | 18 | @Option(name: .shortAndLong, help: "Authentication token.") 19 | private var token: String 20 | 21 | @Option(name: .shortAndLong, help: "HTTP address of InfluxDB.") 22 | private var url: String 23 | } 24 | 25 | extension WriteData { 26 | mutating func run() async throws { 27 | // 28 | // Initialize Client with default Bucket and Organization 29 | // 30 | let client = InfluxDBClient( 31 | url: url, 32 | token: token, 33 | options: InfluxDBClient.InfluxDBOptions(bucket: bucket, org: org)) 34 | 35 | // 36 | // Record defined as Data Point 37 | // 38 | let recordPoint = InfluxDBClient 39 | .Point("demo") 40 | .addTag(key: "type", value: "point") 41 | .addField(key: "value", value: .int(2)) 42 | // 43 | // Record defined as Data Point with Timestamp 44 | // 45 | let recordPointDate = InfluxDBClient 46 | .Point("demo") 47 | .addTag(key: "type", value: "point-timestamp") 48 | .addField(key: "value", value: .int(2)) 49 | .time(time: .date(Date())) 50 | 51 | try await client.makeWriteAPI().write(points: [recordPoint, recordPointDate]) 52 | print("Written data:\n\n\([recordPoint, recordPointDate].map { "\t- \($0)" }.joined(separator: "\n"))") 53 | print("\nSuccess!") 54 | 55 | client.close() 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Examples/WriteDataInBatches/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - array_init 3 | - collection_alignment 4 | - contains_over_first_not_nil 5 | - closure_end_indentation 6 | - closure_spacing 7 | - conditional_returns_on_newline 8 | - empty_count 9 | - empty_string 10 | - explicit_init 11 | - explicit_self 12 | - fatal_error_message 13 | - first_where 14 | - implicit_return 15 | - missing_docs 16 | - modifier_order 17 | - multiline_arguments 18 | - multiline_literal_brackets 19 | - multiline_parameters 20 | - operator_usage_whitespace 21 | - pattern_matching_keywords 22 | - redundant_nil_coalescing 23 | - redundant_type_annotation 24 | - sorted_first_last 25 | - sorted_imports 26 | - trailing_closure 27 | - unneeded_parentheses_in_closure_argument 28 | - unused_import 29 | - unused_declaration 30 | - vertical_parameter_alignment_on_call 31 | - vertical_whitespace_closing_braces 32 | - vertical_whitespace_opening_braces 33 | 34 | excluded: 35 | - Package.swift 36 | - .build/ 37 | -------------------------------------------------------------------------------- /Examples/WriteDataInBatches/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "WriteDataInBatches", 7 | platforms: [ 8 | .macOS(.v11) 9 | ], 10 | products: [ 11 | .executable(name: "write-data-in-batches", targets: ["WriteDataInBatches"]) 12 | ], 13 | dependencies: [ 14 | .package(name: "influxdb-client-swift", path: "../../"), 15 | .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0") 16 | ], 17 | targets: [ 18 | .target(name: "WriteDataInBatches", dependencies: [ 19 | .product(name: "InfluxDBSwift", package: "influxdb-client-swift"), 20 | .product(name: "ArgumentParser", package: "swift-argument-parser") 21 | ], resources: [.process("vix-daily.csv")]) 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Examples/WriteDataInBatches/README.md: -------------------------------------------------------------------------------- 1 | # WriteDataInBatches 2 | 3 | How to use Combine to prepare batches for write into InfluxDB 4 | 5 | ## Prerequisites: 6 | - macOS 11+ 7 | - Cloned examples: 8 | ```bash 9 | git clone git@github.com:influxdata/influxdb-client-swift.git 10 | cd Examples/WriteDataInBatches 11 | ``` 12 | 13 | ## Sources: 14 | - [Package.swift](/Examples/WriteDataInBatches/Package.swift) 15 | - [main.swift](/Examples/WriteDataInBatches/Sources/WriteDataInBatches/main.swift) 16 | 17 | ## How to test: 18 | 1. Start InfluxDB: 19 | ```bash 20 | docker run --rm \ 21 | --name influxdb_v2 \ 22 | --detach \ 23 | --publish 8086:8086 \ 24 | influxdb:latest 25 | ``` 26 | 1. Configure your username, password, organization, bucket and token: 27 | ```bash 28 | docker run --rm \ 29 | --link influxdb_v2 \ 30 | curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ 31 | -H 'accept: application/json' \ 32 | -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' 33 | ``` 34 | 1. Write data by: 35 | ```bash 36 | swift run write-data-in-batches --bucket my-bucket --org my-org --token my-token --url http://localhost:8086 37 | ``` 38 | 39 | ## Expected output 40 | 41 | ```bash 42 | Writing 500 items ... 43 | > success 44 | Writing 500 items ... 45 | > success 46 | Writing 500 items ... 47 | > success 48 | Writing 500 items ... 49 | > success 50 | Writing 500 items ... 51 | > success 52 | Writing 500 items ... 53 | > success 54 | Writing 500 items ... 55 | > success 56 | Writing 452 items ... 57 | > success 58 | Import finished! 59 | ``` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 InfluxData, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: help 2 | .DEFAULT_GOAL := help 3 | 4 | help: 5 | @awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-46s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 6 | 7 | .PHONY: build test clean 8 | build: ## Build both source and test targets 9 | swift build --target InfluxDBSwift 10 | swift build --target InfluxDBSwiftApis 11 | swift build --build-tests 12 | 13 | lint: ## Format code 14 | swiftlint --fix 15 | 16 | check-lint: ## Check that all files are formatted properly 17 | swiftlint lint --strict 18 | 19 | test: ## Run tests 20 | $(MAKE) build 21 | swift test 22 | 23 | generate-sources: ## Generate Models and APIs from swagger 24 | docker run --rm -it \ 25 | -v "${PWD}":/code \ 26 | -v "${PWD}/Scripts/.m2":/root/.m2 \ 27 | -w /code \ 28 | maven:3-openjdk-8 /code/Scripts/generate-sources.sh 29 | $(MAKE) build 30 | 31 | generate-test: ## Generate LinuxMain.swift entries for the package 32 | swift test --generate-linuxmain 33 | 34 | generate-doc: ## Generate documentation 35 | $(MAKE) build 36 | sourcekitten doc --spm --module-name InfluxDBSwift > doc_swift.json 37 | sourcekitten doc --spm --module-name InfluxDBSwiftApis > doc_swift_apis.json 38 | jazzy --clean --hide-documentation-coverage --sourcekitten-sourcefile doc_swift.json,doc_swift_apis.json --config .jazzy.yml 39 | 40 | publish-doc: ## Publish documentation as GH-Pages 41 | $(MAKE) generate-doc 42 | docker run --rm -it \ 43 | -v "${PWD}/docs":/code/docs \ 44 | -v "${PWD}/Scripts":/code/Scripts \ 45 | -v "${PWD}/.circleci":/code/.circleci \ 46 | -v ~/.ssh:/root/.ssh \ 47 | -v ~/.gitconfig:/root/.gitconfig \ 48 | -w /code \ 49 | ubuntu /code/Scripts/publish-site.sh 50 | 51 | docker-cli: ## Start and connect into swift:5.3 container 52 | docker run --rm --privileged --interactive --tty --network influx_network --env INFLUXDB_URL=http://influxdb_v2:8086 -v "${PWD}":/project -w /project -it swift:5.3 /bin/bash 53 | 54 | clean: ## Clean builds, generated docs, resolved dependencies, ... 55 | rm -rf Packages || true 56 | rm -rf .build || true 57 | rm -rf build || true 58 | rm -rf docs || true 59 | rm -rf doc*.json || true 60 | rm Package.resolved || true 61 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "influxdb-client-swift", 8 | products: [ 9 | .library(name: "InfluxDBSwift", targets: ["InfluxDBSwift"]), 10 | .library(name: "InfluxDBSwiftApis", targets: ["InfluxDBSwiftApis"]) 11 | ], 12 | dependencies: [ 13 | // Dependencies declare other packages that this package depends on. 14 | .package(name: "Gzip", url: "https://github.com/1024jp/GzipSwift", from: "5.1.1"), 15 | .package(name: "CSV.swift", url: "https://github.com/yaslab/CSV.swift", from: "2.4.2"), 16 | .package(name: "SwiftTestReporter", url: "https://github.com/allegro/swift-junit.git", from: "2.0.0"), 17 | .package(name: "swift-log", url: "https://github.com/apple/swift-log.git", from: "1.0.0"), 18 | ], 19 | targets: [ 20 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 21 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 22 | .target(name: "InfluxDBSwift", dependencies: [ 23 | "Gzip", 24 | .product(name: "CSV", package: "CSV.swift"), 25 | .product(name: "Logging", package: "swift-log") 26 | ]), 27 | .target(name: "InfluxDBSwiftApis", dependencies: ["InfluxDBSwift"]), 28 | .testTarget(name: "InfluxDBSwiftTests", dependencies: ["InfluxDBSwift", "SwiftTestReporter"]), 29 | .testTarget(name: "InfluxDBSwiftApisTests", dependencies: ["InfluxDBSwiftApis", "SwiftTestReporter"]), 30 | ] 31 | ) 32 | -------------------------------------------------------------------------------- /Scripts/influxdb-onboarding.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # The MIT License 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | 24 | set -e 25 | 26 | echo "Wait to start InfluxDB 2.x" 27 | wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8086/metrics 28 | 29 | echo 30 | echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)" 31 | echo 32 | curl -i -X POST http://localhost:8086/api/v2/setup -H 'accept: application/json' \ 33 | -d '{ 34 | "username": "my-user", 35 | "password": "my-password", 36 | "org": "my-org", 37 | "bucket": "my-bucket", 38 | "token": "my-token" 39 | }' 40 | -------------------------------------------------------------------------------- /Scripts/influxdb-restart.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # The MIT License 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | 24 | set -e 25 | 26 | DEFAULT_INFLUXDB_V2_VERSION="latest" 27 | INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}" 28 | INFLUXDB_V2_IMAGE=influxdb:${INFLUXDB_V2_VERSION} 29 | 30 | SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" 31 | 32 | docker kill influxdb_v2 || true 33 | docker rm influxdb_v2 || true 34 | docker network rm influx_network || true 35 | docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1 36 | 37 | # 38 | # InfluxDB 2.x 39 | # 40 | echo 41 | echo "Restarting InfluxDB 2.x [${INFLUXDB_V2_IMAGE}] ... " 42 | echo 43 | 44 | docker pull "${INFLUXDB_V2_IMAGE}" || true 45 | docker run \ 46 | --detach \ 47 | --env INFLUXD_HTTP_BIND_ADDRESS=:8086 \ 48 | --name influxdb_v2 \ 49 | --network influx_network \ 50 | --publish 8086:8086 \ 51 | "${INFLUXDB_V2_IMAGE}" 52 | 53 | # 54 | # Post onBoarding request to InfluxDB 2 55 | # 56 | "${SCRIPT_PATH}"/influxdb-onboarding.sh -------------------------------------------------------------------------------- /Scripts/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.influxdata 5 | influxdb-client-swift 6 | jar 7 | 1.0-SNAPSHOT 8 | influxdb-client-swift 9 | 10 | 11 | 12 | 13 | org.openapitools 14 | openapi-generator-maven-plugin 15 | 5.1.0 16 | 17 | ./oss.yml 18 | swift5 19 | 20 | InfluxDB2 21 | true 22 | 23 | false 24 | false 25 | true 26 | false 27 | true 28 | false 29 | false 30 | generated 31 | templates 32 | 33 | 34 | 35 | 36 | 37 | 38 | oss.sonatype.org-snapshot 39 | Maven Plugin Snapshots 40 | http://oss.sonatype.org/content/repositories/snapshots 41 | 42 | false 43 | 44 | 45 | true 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Scripts/publish-site.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | SCRIPT_PATH="$( cd "$(dirname "$0")" || exit ; pwd -P )" 6 | cd "$SCRIPT_PATH"/.. 7 | 8 | echo "# Install Git" 9 | apt-get update \ 10 | && apt-get install git --yes \ 11 | 12 | echo "# Clone client and switch to branch for GH-Pages" 13 | git clone git@github.com:influxdata/influxdb-client-swift.git \ 14 | && cd influxdb-client-swift \ 15 | && git checkout -B gh-pages 16 | 17 | echo "# Remove old pages" 18 | rm -r "$SCRIPT_PATH"/../influxdb-client-swift/* 19 | 20 | echo "# Copy new docs" 21 | cp -Rf "$SCRIPT_PATH"/../docs/* "$SCRIPT_PATH"/../influxdb-client-swift/ 22 | 23 | echo "# Copy CircleCI" 24 | cp -R "${SCRIPT_PATH}"/../.circleci/ "$SCRIPT_PATH"/../influxdb-client-swift/ 25 | 26 | echo "# Deploy site" 27 | git add -f . 28 | git commit -m "Pushed the latest Docs to GitHub pages [skip CI]" 29 | git push -fq origin gh-pages -------------------------------------------------------------------------------- /Scripts/templates/APIs.mustache: -------------------------------------------------------------------------------- 1 | // APIs.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | #if canImport(FoundationNetworking) 9 | import FoundationNetworking 10 | #endif 11 | import InfluxDBSwift 12 | 13 | internal class RequestBuilder { 14 | var credential: URLCredential? 15 | var headers: [String:String] 16 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let parameters: [String:Any]? 17 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let isBody: Bool 18 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let method: String 19 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let URLString: String 20 | internal let influxDB2API: InfluxDB2API 21 | 22 | /// Optional block to obtain a reference to the request's progress instance when available.{{#useURLSession}} 23 | /// With the URLSession http client the request's progress only works on iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0. 24 | /// If you need to get the request's progress in older OS versions, please use Alamofire http client.{{/useURLSession}} 25 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var onProgressReady: ((Progress) -> ())? 26 | 27 | internal init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:], influxDB2API: InfluxDB2API) { 28 | self.method = method 29 | self.URLString = URLString 30 | self.parameters = parameters 31 | self.isBody = isBody 32 | self.headers = headers 33 | self.influxDB2API = influxDB2API 34 | } 35 | 36 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func addHeaders(_ aHeaders:[String:String]) { 37 | for (header, value) in aHeaders { 38 | headers[header] = value 39 | } 40 | } 41 | 42 | internal func execute(_ apiResponseQueue: DispatchQueue, _ completion: @escaping (_ result: Swift.Result, InfluxDBClient.InfluxDBError>) -> Void) { } 43 | 44 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func addHeader(name: String, value: String) -> Self { 45 | if !value.isEmpty { 46 | headers[name] = value 47 | } 48 | return self 49 | } 50 | 51 | internal func addCredential() -> Self { 52 | self 53 | } 54 | } 55 | 56 | internal protocol RequestBuilderFactory { 57 | func getRequestNonDecodableBuilder(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String], influxDB2API: InfluxDB2API) -> RequestBuilder 58 | func getRequestDecodableBuilder(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String], influxDB2API: InfluxDB2API) -> RequestBuilder 59 | } 60 | -------------------------------------------------------------------------------- /Scripts/templates/CodableHelper.mustache: -------------------------------------------------------------------------------- 1 | // 2 | // CodableHelper.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class CodableHelper { 11 | 12 | private static var customDateFormatter: DateFormatter? 13 | private static var defaultDateFormatter: DateFormatter = OpenISO8601DateFormatter() 14 | private static var customJSONDecoder: JSONDecoder? 15 | private static var defaultJSONDecoder: JSONDecoder = { 16 | let decoder = JSONDecoder() 17 | decoder.dateDecodingStrategy = .formatted(CodableHelper.dateFormatter) 18 | return decoder 19 | }() 20 | private static var customJSONEncoder: JSONEncoder? 21 | private static var defaultJSONEncoder: JSONEncoder = { 22 | let encoder = JSONEncoder() 23 | encoder.dateEncodingStrategy = .formatted(CodableHelper.dateFormatter) 24 | encoder.outputFormatting = .prettyPrinted 25 | return encoder 26 | }() 27 | 28 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var dateFormatter: DateFormatter { 29 | get { return self.customDateFormatter ?? self.defaultDateFormatter } 30 | set { self.customDateFormatter = newValue } 31 | } 32 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var jsonDecoder: JSONDecoder { 33 | get { return self.customJSONDecoder ?? self.defaultJSONDecoder } 34 | set { self.customJSONDecoder = newValue } 35 | } 36 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var jsonEncoder: JSONEncoder { 37 | get { return self.customJSONEncoder ?? self.defaultJSONEncoder } 38 | set { self.customJSONEncoder = newValue } 39 | } 40 | 41 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func decode(_ type: T.Type, from data: Data) -> Swift.Result where T: Decodable { 42 | return Swift.Result { try self.jsonDecoder.decode(type, from: data) } 43 | } 44 | 45 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func encode(_ value: T) -> Swift.Result where T: Encodable { 46 | return Swift.Result { try self.jsonEncoder.encode(value) } 47 | } 48 | 49 | open class func toErrorBody(_ data: Data?) -> [String: Any]? { 50 | 51 | if let data = data { 52 | let decodeResult = self.decode([String: String].self, from: data) 53 | 54 | switch decodeResult { 55 | case let .success(decodeResult): 56 | return decodeResult 57 | case .failure(_): 58 | return ["message": String(decoding: data, as: UTF8.self)] 59 | } 60 | } 61 | 62 | return nil 63 | } 64 | } -------------------------------------------------------------------------------- /Scripts/templates/JSONDataEncoding.mustache: -------------------------------------------------------------------------------- 1 | // 2 | // JSONDataEncoding.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | #if canImport(FoundationNetworking) 10 | import FoundationNetworking 11 | #endif 12 | 13 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct JSONDataEncoding { 14 | 15 | // MARK: Properties 16 | 17 | private static let jsonDataKey = "jsonData" 18 | 19 | // MARK: Encoding 20 | 21 | /// Creates a URL request by encoding parameters and applying them onto an existing request. 22 | /// 23 | /// - parameter urlRequest: The request to have parameters applied. 24 | /// - parameter parameters: The parameters to apply. This should have a single key/value 25 | /// pair with "jsonData" as the key and a Data object as the value. 26 | /// 27 | /// - throws: An `Error` if the encoding process encounters an error. 28 | /// 29 | /// - returns: The encoded request. 30 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) -> URLRequest { 31 | var urlRequest = urlRequest 32 | 33 | guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else { 34 | return urlRequest 35 | } 36 | 37 | if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { 38 | urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") 39 | } 40 | 41 | urlRequest.httpBody = jsonData 42 | 43 | return urlRequest 44 | } 45 | 46 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static func encodingParameters(jsonData: Data?) -> [String: Any]? { 47 | var returnedParams: [String: Any]? = nil 48 | if let jsonData = jsonData, !jsonData.isEmpty { 49 | var params: [String: Any] = [:] 50 | params[jsonDataKey] = jsonData 51 | returnedParams = params 52 | } 53 | return returnedParams 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Scripts/templates/JSONEncodingHelper.mustache: -------------------------------------------------------------------------------- 1 | // 2 | // JSONEncodingHelper.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | import InfluxDBSwift 10 | 11 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class JSONEncodingHelper { 12 | 13 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func encodingParameters(forEncodableObject encodableObj: T?) -> [String: Any]? { 14 | var params: [String: Any]? = nil 15 | 16 | // Encode the Encodable object 17 | if let encodableObj = encodableObj { 18 | let encodeResult = CodableHelper.encode(encodableObj) 19 | do { 20 | let data = try encodeResult.get() 21 | params = JSONDataEncoding.encodingParameters(jsonData: data) 22 | } catch { 23 | print(error.localizedDescription) 24 | } 25 | } 26 | 27 | return params 28 | } 29 | 30 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? { 31 | var params: [String: Any]? = nil 32 | 33 | if let encodableObj = encodableObj { 34 | do { 35 | let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted) 36 | params = JSONDataEncoding.encodingParameters(jsonData: data) 37 | } catch { 38 | print(error.localizedDescription) 39 | return nil 40 | } 41 | } 42 | 43 | return params 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Scripts/templates/Models.mustache: -------------------------------------------------------------------------------- 1 | // Models.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | #if canImport(FoundationNetworking) 9 | import FoundationNetworking 10 | #endif 11 | 12 | protocol JSONEncodable { 13 | func encodeToJSON() -> Any 14 | } 15 | 16 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum DownloadException : Error { 17 | case responseDataMissing 18 | case responseFailed 19 | case requestMissing 20 | case requestMissingPath 21 | case requestMissingURL 22 | } 23 | 24 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum DecodableRequestBuilderError: Error { 25 | case emptyDataResponse 26 | case nilHTTPResponse 27 | case unsuccessfulHTTPStatusCode 28 | case jsonDecoding(DecodingError) 29 | case generalError(Error) 30 | } 31 | 32 | 33 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class Response { 34 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let statusCode: Int 35 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let header: [String: String] 36 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let body: T? 37 | 38 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(statusCode: Int, header: [String: String], body: T?) { 39 | self.statusCode = statusCode 40 | self.header = header 41 | self.body = body 42 | } 43 | 44 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} convenience init(response: HTTPURLResponse, body: T?) { 45 | let rawHeader = response.allHeaderFields 46 | var header = [String:String]() 47 | for (key, value) in rawHeader { 48 | if let key = key.base as? String, let value = value as? String { 49 | header[key] = value 50 | } 51 | } 52 | self.init(statusCode: response.statusCode, header: header, body: body) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Scripts/templates/OpenISO8601DateFormatter.mustache: -------------------------------------------------------------------------------- 1 | // 2 | // OpenISO8601DateFormatter.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | // https://stackoverflow.com/a/50281094/976628 11 | {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class OpenISO8601DateFormatter: DateFormatter { 12 | static let utcTimeZone = TimeZone(abbreviation: "UTC")! 13 | static let withoutSeconds: DateFormatter = { 14 | let formatter = DateFormatter() 15 | formatter.calendar = Calendar(identifier: .iso8601) 16 | formatter.locale = Locale(identifier: "en_US_POSIX") 17 | formatter.timeZone = OpenISO8601DateFormatter.utcTimeZone 18 | formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" 19 | return formatter 20 | }() 21 | 22 | private func setup() { 23 | calendar = Calendar(identifier: .iso8601) 24 | locale = Locale(identifier: "en_US_POSIX") 25 | timeZone = OpenISO8601DateFormatter.utcTimeZone 26 | dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZZZZZ" 27 | } 28 | 29 | override init() { 30 | super.init() 31 | setup() 32 | } 33 | 34 | required init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | setup() 37 | } 38 | 39 | override {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func date(from string: String) -> Date? { 40 | if let result = super.date(from: string) { 41 | return result 42 | } 43 | return OpenISO8601DateFormatter.withoutSeconds.date(from: string) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/APIHelper.swift: -------------------------------------------------------------------------------- 1 | // APIHelper.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | 9 | public struct APIHelper { 10 | public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? { 11 | let destination = source.reduce(into: [String: Any]()) { result, item in 12 | if let value = item.value { 13 | result[item.key] = value 14 | } 15 | } 16 | 17 | if destination.isEmpty { 18 | return nil 19 | } 20 | return destination 21 | } 22 | 23 | public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { 24 | return source.reduce(into: [String: String]()) { result, item in 25 | if let collection = item.value as? [Any?] { 26 | result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",") 27 | } else if let value: Any = item.value { 28 | result[item.key] = "\(value)" 29 | } 30 | } 31 | } 32 | 33 | public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? { 34 | guard let source = source else { 35 | return nil 36 | } 37 | 38 | return source.reduce(into: [String: Any]()) { result, item in 39 | switch item.value { 40 | case let x as Bool: 41 | result[item.key] = x.description 42 | default: 43 | result[item.key] = item.value 44 | } 45 | } 46 | } 47 | 48 | public static func mapValueToPathItem(_ source: Any) -> Any { 49 | if let collection = source as? [Any?] { 50 | return collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",") 51 | } 52 | return source 53 | } 54 | 55 | public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? { 56 | let destination = source.filter { $0.value != nil }.reduce(into: [URLQueryItem]()) { result, item in 57 | if let collection = item.value as? [Any?] { 58 | collection.filter { $0 != nil }.map { "\($0!)" }.forEach { value in 59 | result.append(URLQueryItem(name: item.key, value: value)) 60 | } 61 | } else if let value = item.value { 62 | result.append(URLQueryItem(name: item.key, value: "\(value)")) 63 | } 64 | } 65 | 66 | if destination.isEmpty { 67 | return nil 68 | } 69 | return destination 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/CodableHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CodableHelper.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | open class CodableHelper { 11 | 12 | private static var customDateFormatter: DateFormatter? 13 | private static var defaultDateFormatter: DateFormatter = OpenISO8601DateFormatter() 14 | private static var customJSONDecoder: JSONDecoder? 15 | private static var defaultJSONDecoder: JSONDecoder = { 16 | let decoder = JSONDecoder() 17 | decoder.dateDecodingStrategy = .formatted(CodableHelper.dateFormatter) 18 | return decoder 19 | }() 20 | private static var customJSONEncoder: JSONEncoder? 21 | private static var defaultJSONEncoder: JSONEncoder = { 22 | let encoder = JSONEncoder() 23 | encoder.dateEncodingStrategy = .formatted(CodableHelper.dateFormatter) 24 | encoder.outputFormatting = .prettyPrinted 25 | return encoder 26 | }() 27 | 28 | public static var dateFormatter: DateFormatter { 29 | get { return self.customDateFormatter ?? self.defaultDateFormatter } 30 | set { self.customDateFormatter = newValue } 31 | } 32 | public static var jsonDecoder: JSONDecoder { 33 | get { return self.customJSONDecoder ?? self.defaultJSONDecoder } 34 | set { self.customJSONDecoder = newValue } 35 | } 36 | public static var jsonEncoder: JSONEncoder { 37 | get { return self.customJSONEncoder ?? self.defaultJSONEncoder } 38 | set { self.customJSONEncoder = newValue } 39 | } 40 | 41 | open class func decode(_ type: T.Type, from data: Data) -> Swift.Result where T: Decodable { 42 | return Swift.Result { try self.jsonDecoder.decode(type, from: data) } 43 | } 44 | 45 | open class func encode(_ value: T) -> Swift.Result where T: Encodable { 46 | return Swift.Result { try self.jsonEncoder.encode(value) } 47 | } 48 | 49 | open class func toErrorBody(_ data: Data?) -> [String: Any]? { 50 | 51 | if let data = data { 52 | let decodeResult = self.decode([String: String].self, from: data) 53 | 54 | switch decodeResult { 55 | case let .success(decodeResult): 56 | return decodeResult 57 | case .failure(_): 58 | return ["message": String(decoding: data, as: UTF8.self)] 59 | } 60 | } 61 | 62 | return nil 63 | } 64 | } -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/DeletePredicateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DeletePredicateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | /** The delete predicate request. */ 11 | public struct DeletePredicateRequest: Codable { 12 | 13 | /** RFC3339Nano */ 14 | public var start: Date 15 | /** RFC3339Nano */ 16 | public var stop: Date 17 | /** InfluxQL-like delete statement */ 18 | public var predicate: String? 19 | 20 | public init(start: Date, stop: Date, predicate: String? = nil) { 21 | self.start = start 22 | self.stop = stop 23 | self.predicate = predicate 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/Dialect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Dialect.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | /** Dialect are options to change the default CSV output format; https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions */ 11 | public struct Dialect: Codable { 12 | 13 | public enum Annotations: String, Codable, CaseIterable { 14 | case group = "group" 15 | case datatype = "datatype" 16 | case _default = "default" 17 | } 18 | public enum DateTimeFormat: String, Codable, CaseIterable { 19 | case rfc3339 = "RFC3339" 20 | case rfc3339nano = "RFC3339Nano" 21 | } 22 | /** If true, the results will contain a header row */ 23 | public var header: Bool? = true 24 | /** Separator between cells; the default is , */ 25 | public var delimiter: String? = "," 26 | /** https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns */ 27 | public var annotations: Array? 28 | /** Character prefixed to comment strings */ 29 | public var commentPrefix: String? = "#" 30 | /** Format of timestamps */ 31 | public var dateTimeFormat: DateTimeFormat? = .rfc3339 32 | 33 | public init(header: Bool? = true, delimiter: String? = ",", annotations: Array? = nil, commentPrefix: String? = "#", dateTimeFormat: DateTimeFormat? = .rfc3339) { 34 | self.header = header 35 | self.delimiter = delimiter 36 | self.annotations = annotations 37 | self.commentPrefix = commentPrefix 38 | self.dateTimeFormat = dateTimeFormat 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/Query.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Query.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | /** Query influx using the Flux language */ 11 | public struct Query: Codable { 12 | 13 | public enum ModelType: String, Codable, CaseIterable { 14 | case flux = "flux" 15 | } 16 | /** Query script to execute. */ 17 | public var query: String 18 | /** The type of query. Must be \"flux\". */ 19 | public var type: ModelType? 20 | /** Enumeration of key/value pairs that respresent parameters to be injected into query (can only specify either this field or extern and not both) */ 21 | public var params: [String: String]? 22 | public var dialect: Dialect? 23 | /** Specifies the time that should be reported as \"now\" in the query. Default is the server's now time. */ 24 | public var now: Date? 25 | 26 | public init(query: String, type: ModelType? = nil, params: [String: String]? = nil, dialect: Dialect? = nil, now: Date? = nil) { 27 | self.query = query 28 | self.type = type 29 | self.params = params 30 | self.dialect = dialect 31 | self.now = now 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/Script.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Script.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Script: Codable { 11 | 12 | public var id: String? 13 | public var name: String 14 | public var description: String? 15 | public var orgID: String 16 | /** script to be executed */ 17 | public var script: String 18 | public var language: ScriptLanguage? 19 | /** invocation endpoint address */ 20 | public var url: String? 21 | public var createdAt: Date? 22 | public var updatedAt: Date? 23 | 24 | public init(id: String? = nil, name: String, description: String? = nil, orgID: String, script: String, language: ScriptLanguage? = nil, url: String? = nil, createdAt: Date? = nil, updatedAt: Date? = nil) { 25 | self.id = id 26 | self.name = name 27 | self.description = description 28 | self.orgID = orgID 29 | self.script = script 30 | self.language = language 31 | self.url = url 32 | self.createdAt = createdAt 33 | self.updatedAt = updatedAt 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/ScriptCreateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScriptCreateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScriptCreateRequest: Codable { 11 | 12 | /** The name of the script. The name must be unique within the organization. */ 13 | public var name: String 14 | public var description: String 15 | /** The script to execute. */ 16 | public var script: String 17 | public var language: ScriptLanguage 18 | 19 | public init(name: String, description: String, script: String, language: ScriptLanguage) { 20 | self.name = name 21 | self.description = description 22 | self.script = script 23 | self.language = language 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/ScriptInvocationParams.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScriptInvocationParams.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScriptInvocationParams: Codable { 11 | 12 | public var params: [String: String]? 13 | 14 | public init(params: [String: String]? = nil) { 15 | self.params = params 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/ScriptLanguage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScriptLanguage.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public enum ScriptLanguage: String, Codable, CaseIterable { 11 | case flux = "flux" 12 | } 13 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/ScriptUpdateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScriptUpdateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScriptUpdateRequest: Codable { 11 | 12 | public var name: String? 13 | public var description: String? 14 | /** script is script to be executed */ 15 | public var script: String? 16 | 17 | public init(name: String? = nil, description: String? = nil, script: String? = nil) { 18 | self.name = name 19 | self.description = description 20 | self.script = script 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/Models/Scripts.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Scripts.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Scripts: Codable { 11 | 12 | public var scripts: [Script]? 13 | 14 | public init(scripts: [Script]? = nil) { 15 | self.scripts = scripts 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Generated/OpenISO8601DateFormatter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OpenISO8601DateFormatter.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | // https://stackoverflow.com/a/50281094/976628 11 | public class OpenISO8601DateFormatter: DateFormatter { 12 | static let utcTimeZone = TimeZone(abbreviation: "UTC")! 13 | static let withoutSeconds: DateFormatter = { 14 | let formatter = DateFormatter() 15 | formatter.calendar = Calendar(identifier: .iso8601) 16 | formatter.locale = Locale(identifier: "en_US_POSIX") 17 | formatter.timeZone = OpenISO8601DateFormatter.utcTimeZone 18 | formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" 19 | return formatter 20 | }() 21 | 22 | private func setup() { 23 | calendar = Calendar(identifier: .iso8601) 24 | locale = Locale(identifier: "en_US_POSIX") 25 | timeZone = OpenISO8601DateFormatter.utcTimeZone 26 | dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZZZZZ" 27 | } 28 | 29 | override init() { 30 | super.init() 31 | setup() 32 | } 33 | 34 | required init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | setup() 37 | } 38 | 39 | override public func date(from string: String) -> Date? { 40 | if let result = super.date(from: string) { 41 | return result 42 | } 43 | return OpenISO8601DateFormatter.withoutSeconds.date(from: string) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwift/Internal/LoggingHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 13.07.2022. 3 | // 4 | 5 | import Foundation 6 | #if canImport(FoundationNetworking) 7 | import FoundationNetworking 8 | #endif 9 | import Logging 10 | 11 | extension InfluxDBClient { 12 | /// The logger for logging HTTP request/response. 13 | public class HTTPLogger { 14 | fileprivate var logger: Logger { 15 | var logger = Logger(label: "http-logger") 16 | logger.logLevel = .debug 17 | return logger 18 | } 19 | /// Enable debugging for HTTP request/response. 20 | internal let debugging: Bool 21 | 22 | /// Create a new HTTPLogger. 23 | /// 24 | /// - Parameters: 25 | /// - debugging: optional Enable debugging for HTTP request/response. Default `false`. 26 | public init(debugging: Bool? = nil) { 27 | self.debugging = debugging ?? false 28 | } 29 | 30 | /// Log the HTTP request. 31 | /// 32 | /// - Parameter request: to log 33 | public func log(_ request: URLRequest?) { 34 | if debugging { 35 | logger.debug(">>> Request: '\(request?.httpMethod ?? "") \(request?.url?.absoluteString ?? "")'") 36 | log_headers(headers: request?.allHTTPHeaderFields, prefix: ">>>") 37 | log_body(body: request?.httpBody, prefix: ">>>") 38 | } 39 | } 40 | 41 | /// Log the HTTP response. 42 | /// 43 | /// - Parameters: 44 | /// - response: to log 45 | /// - data: response data 46 | public func log(_ response: URLResponse?, _ data: Data?) { 47 | if debugging { 48 | let httpResponse = response as? HTTPURLResponse 49 | logger.debug("<<< Response: \(httpResponse?.statusCode ?? 0)") 50 | log_headers(headers: httpResponse?.allHeaderFields, prefix: "<<<") 51 | log_body(body: data, prefix: "<<<") 52 | } 53 | } 54 | 55 | func log_body(body: Data?, prefix: String) { 56 | if let body = body { 57 | logger.debug("\(prefix) Body: \(String(decoding: body, as: UTF8.self))") 58 | } 59 | } 60 | 61 | func log_headers(headers: [AnyHashable: Any]?, prefix: String) { 62 | headers?.forEach { key, value in 63 | var sanitized = value 64 | if "authorization" == String(describing: key).lowercased() { 65 | sanitized = "***" 66 | } 67 | logger.debug("\(prefix) \(key): \(sanitized)") 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/APIs.swift: -------------------------------------------------------------------------------- 1 | // APIs.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | #if canImport(FoundationNetworking) 9 | import FoundationNetworking 10 | #endif 11 | import InfluxDBSwift 12 | 13 | internal class RequestBuilder { 14 | var credential: URLCredential? 15 | var headers: [String:String] 16 | public let parameters: [String:Any]? 17 | public let isBody: Bool 18 | public let method: String 19 | public let URLString: String 20 | internal let influxDB2API: InfluxDB2API 21 | 22 | /// Optional block to obtain a reference to the request's progress instance when available. 23 | /// With the URLSession http client the request's progress only works on iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0. 24 | /// If you need to get the request's progress in older OS versions, please use Alamofire http client. 25 | public var onProgressReady: ((Progress) -> ())? 26 | 27 | internal init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:], influxDB2API: InfluxDB2API) { 28 | self.method = method 29 | self.URLString = URLString 30 | self.parameters = parameters 31 | self.isBody = isBody 32 | self.headers = headers 33 | self.influxDB2API = influxDB2API 34 | } 35 | 36 | open func addHeaders(_ aHeaders:[String:String]) { 37 | for (header, value) in aHeaders { 38 | headers[header] = value 39 | } 40 | } 41 | 42 | internal func execute(_ apiResponseQueue: DispatchQueue, _ completion: @escaping (_ result: Swift.Result, InfluxDBClient.InfluxDBError>) -> Void) { } 43 | 44 | public func addHeader(name: String, value: String) -> Self { 45 | if !value.isEmpty { 46 | headers[name] = value 47 | } 48 | return self 49 | } 50 | 51 | internal func addCredential() -> Self { 52 | self 53 | } 54 | } 55 | 56 | internal protocol RequestBuilderFactory { 57 | func getRequestNonDecodableBuilder(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String], influxDB2API: InfluxDB2API) -> RequestBuilder 58 | func getRequestDecodableBuilder(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String], influxDB2API: InfluxDB2API) -> RequestBuilder 59 | } 60 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/JSONDataEncoding.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONDataEncoding.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | #if canImport(FoundationNetworking) 10 | import FoundationNetworking 11 | #endif 12 | 13 | public struct JSONDataEncoding { 14 | 15 | // MARK: Properties 16 | 17 | private static let jsonDataKey = "jsonData" 18 | 19 | // MARK: Encoding 20 | 21 | /// Creates a URL request by encoding parameters and applying them onto an existing request. 22 | /// 23 | /// - parameter urlRequest: The request to have parameters applied. 24 | /// - parameter parameters: The parameters to apply. This should have a single key/value 25 | /// pair with "jsonData" as the key and a Data object as the value. 26 | /// 27 | /// - throws: An `Error` if the encoding process encounters an error. 28 | /// 29 | /// - returns: The encoded request. 30 | public func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) -> URLRequest { 31 | var urlRequest = urlRequest 32 | 33 | guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else { 34 | return urlRequest 35 | } 36 | 37 | if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { 38 | urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") 39 | } 40 | 41 | urlRequest.httpBody = jsonData 42 | 43 | return urlRequest 44 | } 45 | 46 | public static func encodingParameters(jsonData: Data?) -> [String: Any]? { 47 | var returnedParams: [String: Any]? = nil 48 | if let jsonData = jsonData, !jsonData.isEmpty { 49 | var params: [String: Any] = [:] 50 | params[jsonDataKey] = jsonData 51 | returnedParams = params 52 | } 53 | return returnedParams 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/JSONEncodingHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONEncodingHelper.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | import InfluxDBSwift 10 | 11 | open class JSONEncodingHelper { 12 | 13 | open class func encodingParameters(forEncodableObject encodableObj: T?) -> [String: Any]? { 14 | var params: [String: Any]? = nil 15 | 16 | // Encode the Encodable object 17 | if let encodableObj = encodableObj { 18 | let encodeResult = CodableHelper.encode(encodableObj) 19 | do { 20 | let data = try encodeResult.get() 21 | params = JSONDataEncoding.encodingParameters(jsonData: data) 22 | } catch { 23 | print(error.localizedDescription) 24 | } 25 | } 26 | 27 | return params 28 | } 29 | 30 | open class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? { 31 | var params: [String: Any]? = nil 32 | 33 | if let encodableObj = encodableObj { 34 | do { 35 | let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted) 36 | params = JSONDataEncoding.encodingParameters(jsonData: data) 37 | } catch { 38 | print(error.localizedDescription) 39 | return nil 40 | } 41 | } 42 | 43 | return params 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models.swift: -------------------------------------------------------------------------------- 1 | // Models.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | #if canImport(FoundationNetworking) 9 | import FoundationNetworking 10 | #endif 11 | 12 | protocol JSONEncodable { 13 | func encodeToJSON() -> Any 14 | } 15 | 16 | public enum DownloadException : Error { 17 | case responseDataMissing 18 | case responseFailed 19 | case requestMissing 20 | case requestMissingPath 21 | case requestMissingURL 22 | } 23 | 24 | public enum DecodableRequestBuilderError: Error { 25 | case emptyDataResponse 26 | case nilHTTPResponse 27 | case unsuccessfulHTTPStatusCode 28 | case jsonDecoding(DecodingError) 29 | case generalError(Error) 30 | } 31 | 32 | 33 | open class Response { 34 | public let statusCode: Int 35 | public let header: [String: String] 36 | public let body: T? 37 | 38 | public init(statusCode: Int, header: [String: String], body: T?) { 39 | self.statusCode = statusCode 40 | self.header = header 41 | self.body = body 42 | } 43 | 44 | public convenience init(response: HTTPURLResponse, body: T?) { 45 | let rawHeader = response.allHeaderFields 46 | var header = [String:String]() 47 | for (key, value) in rawHeader { 48 | if let key = key.base as? String, let value = value as? String { 49 | header[key] = value 50 | } 51 | } 52 | self.init(statusCode: response.statusCode, header: header, body: body) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/AddResourceMemberRequestBody.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddResourceMemberRequestBody.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct AddResourceMemberRequestBody: Codable { 11 | 12 | public var id: String 13 | public var name: String? 14 | 15 | public init(id: String, name: String? = nil) { 16 | self.id = id 17 | self.name = name 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Authorization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Authorization.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Authorization: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | /** Status of the token. If `inactive`, requests using the token will be rejected. */ 17 | public var status: Status? = .active 18 | /** A description of the token. */ 19 | public var description: String? 20 | public var createdAt: Date? 21 | public var updatedAt: Date? 22 | /** ID of the organization that the authorization is scoped to. */ 23 | public var orgID: String 24 | /** List of permissions for an authorization. An authorization must have at least one permission. */ 25 | public var permissions: [Permission] 26 | public var id: String? 27 | /** Token used to authenticate API requests. */ 28 | public var token: String? 29 | /** ID of the user that created and owns the token. */ 30 | public var userID: String? 31 | /** Name of the user that created and owns the token. */ 32 | public var user: String? 33 | /** Name of the organization that the token is scoped to. */ 34 | public var org: String? 35 | public var links: AuthorizationAllOfLinks? 36 | 37 | public init(status: Status? = .active, description: String? = nil, createdAt: Date? = nil, updatedAt: Date? = nil, orgID: String, permissions: [Permission], id: String? = nil, token: String? = nil, userID: String? = nil, user: String? = nil, org: String? = nil, links: AuthorizationAllOfLinks? = nil) { 38 | self.status = status 39 | self.description = description 40 | self.createdAt = createdAt 41 | self.updatedAt = updatedAt 42 | self.orgID = orgID 43 | self.permissions = permissions 44 | self.id = id 45 | self.token = token 46 | self.userID = userID 47 | self.user = user 48 | self.org = org 49 | self.links = links 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/AuthorizationLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthorizationAllOfLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct AuthorizationAllOfLinks: Codable { 11 | 12 | /** URI of resource. */ 13 | public var _self: String? 14 | /** URI of resource. */ 15 | public var user: String? 16 | 17 | public init(_self: String? = nil, user: String? = nil) { 18 | self._self = _self 19 | self.user = user 20 | } 21 | 22 | public enum CodingKeys: String, CodingKey, CaseIterable { 23 | case _self = "self" 24 | case user 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/AuthorizationPostRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthorizationPostRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct AuthorizationPostRequest: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | /** Status of the token. If `inactive`, requests using the token will be rejected. */ 17 | public var status: Status? = .active 18 | /** A description of the token. */ 19 | public var description: String? 20 | /** ID of org that authorization is scoped to. */ 21 | public var orgID: String 22 | /** ID of user that authorization is scoped to. */ 23 | public var userID: String? 24 | /** List of permissions for an auth. An auth must have at least one Permission. */ 25 | public var permissions: [Permission] 26 | 27 | public init(status: Status? = .active, description: String? = nil, orgID: String, userID: String? = nil, permissions: [Permission]) { 28 | self.status = status 29 | self.description = description 30 | self.orgID = orgID 31 | self.userID = userID 32 | self.permissions = permissions 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/AuthorizationUpdateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthorizationUpdateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct AuthorizationUpdateRequest: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | /** Status of the token. If `inactive`, requests using the token will be rejected. */ 17 | public var status: Status? = .active 18 | /** A description of the token. */ 19 | public var description: String? 20 | 21 | public init(status: Status? = .active, description: String? = nil) { 22 | self.status = status 23 | self.description = description 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Authorizations.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Authorizations.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Authorizations: Codable { 11 | 12 | public var links: Links? 13 | public var authorizations: [Authorization]? 14 | 15 | public init(links: Links? = nil, authorizations: [Authorization]? = nil) { 16 | self.links = links 17 | self.authorizations = authorizations 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Bucket.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bucket.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Bucket: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case user = "user" 14 | case system = "system" 15 | } 16 | public var links: BucketLinks? 17 | public var id: String? 18 | public var type: ModelType? = .user 19 | public var name: String 20 | public var description: String? 21 | public var orgID: String? 22 | public var rp: String? 23 | public var schemaType: SchemaType? 24 | public var createdAt: Date? 25 | public var updatedAt: Date? 26 | /** Rules to expire or retain data. No rules means data never expires. */ 27 | public var retentionRules: [RetentionRule] 28 | public var labels: [Label]? 29 | 30 | public init(links: BucketLinks? = nil, id: String? = nil, type: ModelType? = .user, name: String, description: String? = nil, orgID: String? = nil, rp: String? = nil, schemaType: SchemaType? = nil, createdAt: Date? = nil, updatedAt: Date? = nil, retentionRules: [RetentionRule], labels: [Label]? = nil) { 31 | self.links = links 32 | self.id = id 33 | self.type = type 34 | self.name = name 35 | self.description = description 36 | self.orgID = orgID 37 | self.rp = rp 38 | self.schemaType = schemaType 39 | self.createdAt = createdAt 40 | self.updatedAt = updatedAt 41 | self.retentionRules = retentionRules 42 | self.labels = labels 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/BucketLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BucketLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct BucketLinks: Codable { 11 | 12 | /** URI of resource. */ 13 | public var labels: String? 14 | /** URI of resource. */ 15 | public var members: String? 16 | /** URI of resource. */ 17 | public var org: String? 18 | /** URI of resource. */ 19 | public var owners: String? 20 | /** URI of resource. */ 21 | public var _self: String? 22 | /** URI of resource. */ 23 | public var write: String? 24 | 25 | public init(labels: String? = nil, members: String? = nil, org: String? = nil, owners: String? = nil, _self: String? = nil, write: String? = nil) { 26 | self.labels = labels 27 | self.members = members 28 | self.org = org 29 | self.owners = owners 30 | self._self = _self 31 | self.write = write 32 | } 33 | 34 | public enum CodingKeys: String, CodingKey, CaseIterable { 35 | case labels 36 | case members 37 | case org 38 | case owners 39 | case _self = "self" 40 | case write 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Buckets.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Buckets.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Buckets: Codable { 11 | 12 | public var links: Links? 13 | public var buckets: [Bucket]? 14 | 15 | public init(links: Links? = nil, buckets: [Bucket]? = nil) { 16 | self.links = links 17 | self.buckets = buckets 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/DBRP.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DBRP.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DBRP: Codable { 11 | 12 | /** ID of the DBRP mapping. */ 13 | public var id: String 14 | /** ID of the organization that owns this mapping. */ 15 | public var orgID: String 16 | /** ID of the bucket used as the target for the translation. */ 17 | public var bucketID: String 18 | /** InfluxDB v1 database */ 19 | public var database: String 20 | /** InfluxDB v1 retention policy */ 21 | public var retentionPolicy: String 22 | /** Mapping represents the default retention policy for the database specified. */ 23 | public var _default: Bool 24 | public var links: Links? 25 | 26 | public init(id: String, orgID: String, bucketID: String, database: String, retentionPolicy: String, _default: Bool, links: Links? = nil) { 27 | self.id = id 28 | self.orgID = orgID 29 | self.bucketID = bucketID 30 | self.database = database 31 | self.retentionPolicy = retentionPolicy 32 | self._default = _default 33 | self.links = links 34 | } 35 | 36 | public enum CodingKeys: String, CodingKey, CaseIterable { 37 | case id 38 | case orgID 39 | case bucketID 40 | case database 41 | case retentionPolicy = "retention_policy" 42 | case _default = "default" 43 | case links 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/DBRPCreate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DBRPCreate.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DBRPCreate: Codable { 11 | 12 | /** ID of the organization that owns this mapping. */ 13 | public var orgID: String? 14 | /** Name of the organization that owns this mapping. */ 15 | public var org: String? 16 | /** ID of the bucket used as the target for the translation. */ 17 | public var bucketID: String 18 | /** InfluxDB v1 database */ 19 | public var database: String 20 | /** InfluxDB v1 retention policy */ 21 | public var retentionPolicy: String 22 | /** Mapping represents the default retention policy for the database specified. */ 23 | public var _default: Bool? 24 | 25 | public init(orgID: String? = nil, org: String? = nil, bucketID: String, database: String, retentionPolicy: String, _default: Bool? = nil) { 26 | self.orgID = orgID 27 | self.org = org 28 | self.bucketID = bucketID 29 | self.database = database 30 | self.retentionPolicy = retentionPolicy 31 | self._default = _default 32 | } 33 | 34 | public enum CodingKeys: String, CodingKey, CaseIterable { 35 | case orgID 36 | case org 37 | case bucketID 38 | case database 39 | case retentionPolicy = "retention_policy" 40 | case _default = "default" 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/DBRPGet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DBRPGet.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DBRPGet: Codable { 11 | 12 | public var content: DBRP? 13 | 14 | public init(content: DBRP? = nil) { 15 | self.content = content 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/DBRPUpdate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DBRPUpdate.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DBRPUpdate: Codable { 11 | 12 | /** InfluxDB v1 retention policy */ 13 | public var retentionPolicy: String? 14 | public var _default: Bool? 15 | 16 | public init(retentionPolicy: String? = nil, _default: Bool? = nil) { 17 | self.retentionPolicy = retentionPolicy 18 | self._default = _default 19 | } 20 | 21 | public enum CodingKeys: String, CodingKey, CaseIterable { 22 | case retentionPolicy = "retention_policy" 23 | case _default = "default" 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/DBRPs.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DBRPs.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DBRPs: Codable { 11 | 12 | public var content: [DBRP]? 13 | 14 | public init(content: [DBRP]? = nil) { 15 | self.content = content 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/HealthCheck.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HealthCheck.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct HealthCheck: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case pass = "pass" 14 | case fail = "fail" 15 | } 16 | public var name: String 17 | public var message: String? 18 | public var checks: [HealthCheck]? 19 | public var status: Status 20 | public var version: String? 21 | public var commit: String? 22 | 23 | public init(name: String, message: String? = nil, checks: [HealthCheck]? = nil, status: Status, version: String? = nil, commit: String? = nil) { 24 | self.name = name 25 | self.message = message 26 | self.checks = checks 27 | self.status = status 28 | self.version = version 29 | self.commit = commit 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/IsOnboarding.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IsOnboarding.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct IsOnboarding: Codable { 11 | 12 | /** True means that the influxdb instance has NOT had initial setup; false means that the database has been setup. */ 13 | public var allowed: Bool? 14 | 15 | public init(allowed: Bool? = nil) { 16 | self.allowed = allowed 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Label.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Label.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Label: Codable { 11 | 12 | public var id: String? 13 | public var orgID: String? 14 | public var name: String? 15 | /** Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. */ 16 | public var properties: [String: String]? 17 | 18 | public init(id: String? = nil, orgID: String? = nil, name: String? = nil, properties: [String: String]? = nil) { 19 | self.id = id 20 | self.orgID = orgID 21 | self.name = name 22 | self.properties = properties 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LabelCreateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabelCreateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LabelCreateRequest: Codable { 11 | 12 | public var orgID: String 13 | public var name: String 14 | /** Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. */ 15 | public var properties: [String: String]? 16 | 17 | public init(orgID: String, name: String, properties: [String: String]? = nil) { 18 | self.orgID = orgID 19 | self.name = name 20 | self.properties = properties 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LabelMapping.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabelMapping.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LabelMapping: Codable { 11 | 12 | public var labelID: String? 13 | 14 | public init(labelID: String? = nil) { 15 | self.labelID = labelID 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LabelResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabelResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LabelResponse: Codable { 11 | 12 | public var label: Label? 13 | public var links: Links? 14 | 15 | public init(label: Label? = nil, links: Links? = nil) { 16 | self.label = label 17 | self.links = links 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LabelUpdate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabelUpdate.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LabelUpdate: Codable { 11 | 12 | public var name: String? 13 | /** Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. */ 14 | public var properties: [String: String]? 15 | 16 | public init(name: String? = nil, properties: [String: String]? = nil) { 17 | self.name = name 18 | self.properties = properties 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LabelsResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabelsResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LabelsResponse: Codable { 11 | 12 | public var labels: [Label]? 13 | public var links: Links? 14 | 15 | public init(labels: [Label]? = nil, links: Links? = nil) { 16 | self.labels = labels 17 | self.links = links 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Links.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Links.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Links: Codable { 11 | 12 | /** URI of resource. */ 13 | public var next: String? 14 | /** URI of resource. */ 15 | public var _self: String 16 | /** URI of resource. */ 17 | public var prev: String? 18 | 19 | public init(next: String? = nil, _self: String, prev: String? = nil) { 20 | self.next = next 21 | self._self = _self 22 | self.prev = prev 23 | } 24 | 25 | public enum CodingKeys: String, CodingKey, CaseIterable { 26 | case next 27 | case _self = "self" 28 | case prev 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/LogEvent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LogEvent.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LogEvent: Codable { 11 | 12 | /** Time event occurred, RFC3339Nano. */ 13 | public var time: Date? 14 | /** A description of the event that occurred. */ 15 | public var message: String? 16 | /** the ID of the task that logged */ 17 | public var runID: String? 18 | 19 | public init(time: Date? = nil, message: String? = nil, runID: String? = nil) { 20 | self.time = time 21 | self.message = message 22 | self.runID = runID 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Logs.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logs.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Logs: Codable { 11 | 12 | public var events: [LogEvent]? 13 | 14 | public init(events: [LogEvent]? = nil) { 15 | self.events = events 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/OnboardingRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OnboardingRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct OnboardingRequest: Codable { 11 | 12 | public var username: String 13 | public var password: String? 14 | public var org: String 15 | public var bucket: String 16 | public var retentionPeriodSeconds: Int64? 17 | /** Retention period *in nanoseconds* for the new bucket. This key's name has been misleading since OSS 2.0 GA, please transition to use `retentionPeriodSeconds` */ 18 | @available(*, deprecated, message: "This property is deprecated.") 19 | public var retentionPeriodHrs: Int? 20 | /** Authentication token to set on the initial user. If not specified, the server will generate a token. */ 21 | public var token: String? 22 | 23 | public init(username: String, password: String? = nil, org: String, bucket: String, retentionPeriodSeconds: Int64? = nil, retentionPeriodHrs: Int? = nil, token: String? = nil) { 24 | self.username = username 25 | self.password = password 26 | self.org = org 27 | self.bucket = bucket 28 | self.retentionPeriodSeconds = retentionPeriodSeconds 29 | self.retentionPeriodHrs = retentionPeriodHrs 30 | self.token = token 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/OnboardingResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OnboardingResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct OnboardingResponse: Codable { 11 | 12 | public var user: UserResponse? 13 | public var org: Organization? 14 | public var bucket: Bucket? 15 | public var auth: Authorization? 16 | 17 | public init(user: UserResponse? = nil, org: Organization? = nil, bucket: Bucket? = nil, auth: Authorization? = nil) { 18 | self.user = user 19 | self.org = org 20 | self.bucket = bucket 21 | self.auth = auth 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Organization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Organization.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Organization: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | public var links: OrganizationLinks? 17 | public var id: String? 18 | public var name: String 19 | public var description: String? 20 | public var createdAt: Date? 21 | public var updatedAt: Date? 22 | /** If inactive the organization is inactive. */ 23 | public var status: Status? = .active 24 | 25 | public init(links: OrganizationLinks? = nil, id: String? = nil, name: String, description: String? = nil, createdAt: Date? = nil, updatedAt: Date? = nil, status: Status? = .active) { 26 | self.links = links 27 | self.id = id 28 | self.name = name 29 | self.description = description 30 | self.createdAt = createdAt 31 | self.updatedAt = updatedAt 32 | self.status = status 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/OrganizationLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OrganizationLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct OrganizationLinks: Codable { 11 | 12 | /** URI of resource. */ 13 | public var _self: String? 14 | /** URI of resource. */ 15 | public var members: String? 16 | /** URI of resource. */ 17 | public var owners: String? 18 | /** URI of resource. */ 19 | public var labels: String? 20 | /** URI of resource. */ 21 | public var secrets: String? 22 | /** URI of resource. */ 23 | public var buckets: String? 24 | /** URI of resource. */ 25 | public var tasks: String? 26 | /** URI of resource. */ 27 | public var dashboards: String? 28 | 29 | public init(_self: String? = nil, members: String? = nil, owners: String? = nil, labels: String? = nil, secrets: String? = nil, buckets: String? = nil, tasks: String? = nil, dashboards: String? = nil) { 30 | self._self = _self 31 | self.members = members 32 | self.owners = owners 33 | self.labels = labels 34 | self.secrets = secrets 35 | self.buckets = buckets 36 | self.tasks = tasks 37 | self.dashboards = dashboards 38 | } 39 | 40 | public enum CodingKeys: String, CodingKey, CaseIterable { 41 | case _self = "self" 42 | case members 43 | case owners 44 | case labels 45 | case secrets 46 | case buckets 47 | case tasks 48 | case dashboards 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Organizations.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Organizations.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Organizations: Codable { 11 | 12 | public var links: Links? 13 | public var orgs: [Organization]? 14 | 15 | public init(links: Links? = nil, orgs: [Organization]? = nil) { 16 | self.links = links 17 | self.orgs = orgs 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PasswordResetBody.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PasswordResetBody.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PasswordResetBody: Codable { 11 | 12 | public var password: String 13 | 14 | public init(password: String) { 15 | self.password = password 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PatchBucketRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PatchBucketRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | /** Updates to an existing bucket resource. */ 11 | public struct PatchBucketRequest: Codable { 12 | 13 | public var name: String? 14 | public var description: String? 15 | /** Updates to rules to expire or retain data. No rules means no updates. */ 16 | public var retentionRules: [PatchRetentionRule]? 17 | 18 | public init(name: String? = nil, description: String? = nil, retentionRules: [PatchRetentionRule]? = nil) { 19 | self.name = name 20 | self.description = description 21 | self.retentionRules = retentionRules 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PatchOrganizationRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PatchOrganizationRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PatchOrganizationRequest: Codable { 11 | 12 | /** New name to set on the organization */ 13 | public var name: String? 14 | /** New description to set on the organization */ 15 | public var description: String? 16 | 17 | public init(name: String? = nil, description: String? = nil) { 18 | self.name = name 19 | self.description = description 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PatchRetentionRule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PatchRetentionRule.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | /** Updates to a rule to expire or retain data. */ 11 | public struct PatchRetentionRule: Codable { 12 | 13 | public enum ModelType: String, Codable, CaseIterable { 14 | case expire = "expire" 15 | } 16 | public var type: ModelType = .expire 17 | /** Duration in seconds for how long data will be kept in the database. 0 means infinite. */ 18 | public var everySeconds: Int64? 19 | /** Shard duration measured in seconds. */ 20 | public var shardGroupDurationSeconds: Int64? 21 | 22 | public init(type: ModelType = .expire, everySeconds: Int64? = nil, shardGroupDurationSeconds: Int64? = nil) { 23 | self.type = type 24 | self.everySeconds = everySeconds 25 | self.shardGroupDurationSeconds = shardGroupDurationSeconds 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Permission.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Permission.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Permission: Codable { 11 | 12 | public enum Action: String, Codable, CaseIterable { 13 | case read = "read" 14 | case write = "write" 15 | } 16 | public var action: Action 17 | public var resource: Resource 18 | 19 | public init(action: Action, resource: Resource) { 20 | self.action = action 21 | self.resource = resource 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PostBucketRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PostBucketRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PostBucketRequest: Codable { 11 | 12 | public var orgID: String 13 | public var name: String 14 | public var description: String? 15 | public var rp: String? 16 | /** Rules to expire or retain data. No rules means data never expires. */ 17 | public var retentionRules: [RetentionRule] 18 | public var schemaType: SchemaType? 19 | 20 | public init(orgID: String, name: String, description: String? = nil, rp: String? = nil, retentionRules: [RetentionRule], schemaType: SchemaType? = nil) { 21 | self.orgID = orgID 22 | self.name = name 23 | self.description = description 24 | self.rp = rp 25 | self.retentionRules = retentionRules 26 | self.schemaType = schemaType 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/PostOrganizationRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PostOrganizationRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PostOrganizationRequest: Codable { 11 | 12 | public var name: String 13 | public var description: String? 14 | /** An optional list of email address's to be invited to the organization */ 15 | public var users: [String]? 16 | 17 | public init(name: String, description: String? = nil, users: [String]? = nil) { 18 | self.name = name 19 | self.description = description 20 | self.users = users 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Ready.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Ready.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Ready: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case ready = "ready" 14 | } 15 | public var status: Status? 16 | public var started: Date? 17 | public var up: String? 18 | 19 | public init(status: Status? = nil, started: Date? = nil, up: String? = nil) { 20 | self.status = status 21 | self.started = started 22 | self.up = up 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Resource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Resource.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Resource: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case authorizations = "authorizations" 14 | case buckets = "buckets" 15 | case dashboards = "dashboards" 16 | case orgs = "orgs" 17 | case sources = "sources" 18 | case tasks = "tasks" 19 | case telegrafs = "telegrafs" 20 | case users = "users" 21 | case variables = "variables" 22 | case scrapers = "scrapers" 23 | case secrets = "secrets" 24 | case labels = "labels" 25 | case views = "views" 26 | case documents = "documents" 27 | case notificationrules = "notificationRules" 28 | case notificationendpoints = "notificationEndpoints" 29 | case checks = "checks" 30 | case dbrp = "dbrp" 31 | case notebooks = "notebooks" 32 | case annotations = "annotations" 33 | case remotes = "remotes" 34 | case replications = "replications" 35 | case flows = "flows" 36 | case functions = "functions" 37 | } 38 | public var type: ModelType 39 | /** If ID is set that is a permission for a specific resource. if it is not set it is a permission for all resources of that resource type. */ 40 | public var id: String? 41 | /** Optional name of the resource if the resource has a name field. */ 42 | public var name: String? 43 | /** If orgID is set that is a permission for all resources owned my that org. if it is not set it is a permission for all resources of that resource type. */ 44 | public var orgID: String? 45 | /** Optional name of the organization of the organization with orgID. */ 46 | public var org: String? 47 | 48 | public init(type: ModelType, id: String? = nil, name: String? = nil, orgID: String? = nil, org: String? = nil) { 49 | self.type = type 50 | self.id = id 51 | self.name = name 52 | self.orgID = orgID 53 | self.org = org 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ResourceMember.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResourceMember.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResourceMember: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | public enum Role: String, Codable, CaseIterable { 17 | case member = "member" 18 | } 19 | public var id: String? 20 | public var oauthID: String? 21 | public var name: String 22 | /** If inactive the user is inactive. */ 23 | public var status: Status? = .active 24 | public var links: UserResponseLinks? 25 | public var role: Role? = .member 26 | 27 | public init(id: String? = nil, oauthID: String? = nil, name: String, status: Status? = .active, links: UserResponseLinks? = nil, role: Role? = .member) { 28 | self.id = id 29 | self.oauthID = oauthID 30 | self.name = name 31 | self.status = status 32 | self.links = links 33 | self.role = role 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ResourceMembers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResourceMembers.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResourceMembers: Codable { 11 | 12 | public var links: ResourceMembersLinks? 13 | public var users: [ResourceMember]? 14 | 15 | public init(links: ResourceMembersLinks? = nil, users: [ResourceMember]? = nil) { 16 | self.links = links 17 | self.users = users 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ResourceMembersLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResourceMembersLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResourceMembersLinks: Codable { 11 | 12 | public var _self: String? 13 | 14 | public init(_self: String? = nil) { 15 | self._self = _self 16 | } 17 | 18 | public enum CodingKeys: String, CodingKey, CaseIterable { 19 | case _self = "self" 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ResourceOwner.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResourceOwner.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResourceOwner: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | public enum Role: String, Codable, CaseIterable { 17 | case owner = "owner" 18 | } 19 | public var id: String? 20 | public var oauthID: String? 21 | public var name: String 22 | /** If inactive the user is inactive. */ 23 | public var status: Status? = .active 24 | public var links: UserResponseLinks? 25 | public var role: Role? = .owner 26 | 27 | public init(id: String? = nil, oauthID: String? = nil, name: String, status: Status? = .active, links: UserResponseLinks? = nil, role: Role? = .owner) { 28 | self.id = id 29 | self.oauthID = oauthID 30 | self.name = name 31 | self.status = status 32 | self.links = links 33 | self.role = role 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ResourceOwners.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResourceOwners.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResourceOwners: Codable { 11 | 12 | public var links: ResourceMembersLinks? 13 | public var users: [ResourceOwner]? 14 | 15 | public init(links: ResourceMembersLinks? = nil, users: [ResourceOwner]? = nil) { 16 | self.links = links 17 | self.users = users 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/RetentionRule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RetentionRule.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct RetentionRule: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case expire = "expire" 14 | } 15 | public var type: ModelType = .expire 16 | /** Duration in seconds for how long data will be kept in the database. 0 means infinite. */ 17 | public var everySeconds: Int64 18 | /** Shard duration measured in seconds. */ 19 | public var shardGroupDurationSeconds: Int64? 20 | 21 | public init(type: ModelType = .expire, everySeconds: Int64, shardGroupDurationSeconds: Int64? = nil) { 22 | self.type = type 23 | self.everySeconds = everySeconds 24 | self.shardGroupDurationSeconds = shardGroupDurationSeconds 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Run.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Run.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Run: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case scheduled = "scheduled" 14 | case started = "started" 15 | case failed = "failed" 16 | case success = "success" 17 | case canceled = "canceled" 18 | } 19 | public var id: String? 20 | public var taskID: String? 21 | public var status: Status? 22 | /** Time used for run's \"now\" option, RFC3339. */ 23 | public var scheduledFor: Date? 24 | /** An array of logs associated with the run. */ 25 | public var log: [LogEvent]? 26 | /** Time run started executing, RFC3339Nano. */ 27 | public var startedAt: Date? 28 | /** Time run finished executing, RFC3339Nano. */ 29 | public var finishedAt: Date? 30 | /** Time run was manually requested, RFC3339Nano. */ 31 | public var requestedAt: Date? 32 | public var links: RunLinks? 33 | 34 | public init(id: String? = nil, taskID: String? = nil, status: Status? = nil, scheduledFor: Date? = nil, log: [LogEvent]? = nil, startedAt: Date? = nil, finishedAt: Date? = nil, requestedAt: Date? = nil, links: RunLinks? = nil) { 35 | self.id = id 36 | self.taskID = taskID 37 | self.status = status 38 | self.scheduledFor = scheduledFor 39 | self.log = log 40 | self.startedAt = startedAt 41 | self.finishedAt = finishedAt 42 | self.requestedAt = requestedAt 43 | self.links = links 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/RunLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RunLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct RunLinks: Codable { 11 | 12 | public var _self: String? 13 | public var task: String? 14 | public var retry: String? 15 | 16 | public init(_self: String? = nil, task: String? = nil, retry: String? = nil) { 17 | self._self = _self 18 | self.task = task 19 | self.retry = retry 20 | } 21 | 22 | public enum CodingKeys: String, CodingKey, CaseIterable { 23 | case _self = "self" 24 | case task 25 | case retry 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/RunManually.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RunManually.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct RunManually: Codable { 11 | 12 | /** Time used for run's \"now\" option, RFC3339. Default is the server's now time. */ 13 | public var scheduledFor: Date? 14 | 15 | public init(scheduledFor: Date? = nil) { 16 | self.scheduledFor = scheduledFor 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Runs.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Runs.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Runs: Codable { 11 | 12 | public var links: Links? 13 | public var runs: [Run]? 14 | 15 | public init(links: Links? = nil, runs: [Run]? = nil) { 16 | self.links = links 17 | self.runs = runs 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/SchemaType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchemaType.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public enum SchemaType: String, Codable, CaseIterable { 11 | case implicit = "implicit" 12 | case explicit = "explicit" 13 | } 14 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ScraperTargetRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScraperTargetRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScraperTargetRequest: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case prometheus = "prometheus" 14 | } 15 | /** The name of the scraper target. */ 16 | public var name: String? 17 | /** The type of the metrics to be parsed. */ 18 | public var type: ModelType? 19 | /** The URL of the metrics endpoint. */ 20 | public var url: String? 21 | /** The organization ID. */ 22 | public var orgID: String? 23 | /** The ID of the bucket to write to. */ 24 | public var bucketID: String? 25 | /** Skip TLS verification on endpoint. */ 26 | public var allowInsecure: Bool? = false 27 | 28 | public init(name: String? = nil, type: ModelType? = nil, url: String? = nil, orgID: String? = nil, bucketID: String? = nil, allowInsecure: Bool? = false) { 29 | self.name = name 30 | self.type = type 31 | self.url = url 32 | self.orgID = orgID 33 | self.bucketID = bucketID 34 | self.allowInsecure = allowInsecure 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ScraperTargetResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScraperTargetResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScraperTargetResponse: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case prometheus = "prometheus" 14 | } 15 | /** The name of the scraper target. */ 16 | public var name: String? 17 | /** The type of the metrics to be parsed. */ 18 | public var type: ModelType? 19 | /** The URL of the metrics endpoint. */ 20 | public var url: String? 21 | /** The organization ID. */ 22 | public var orgID: String? 23 | /** The ID of the bucket to write to. */ 24 | public var bucketID: String? 25 | /** Skip TLS verification on endpoint. */ 26 | public var allowInsecure: Bool? = false 27 | public var id: String? 28 | /** The name of the organization. */ 29 | public var org: String? 30 | /** The bucket name. */ 31 | public var bucket: String? 32 | public var links: ScraperTargetResponseAllOfLinks? 33 | 34 | public init(name: String? = nil, type: ModelType? = nil, url: String? = nil, orgID: String? = nil, bucketID: String? = nil, allowInsecure: Bool? = false, id: String? = nil, org: String? = nil, bucket: String? = nil, links: ScraperTargetResponseAllOfLinks? = nil) { 35 | self.name = name 36 | self.type = type 37 | self.url = url 38 | self.orgID = orgID 39 | self.bucketID = bucketID 40 | self.allowInsecure = allowInsecure 41 | self.id = id 42 | self.org = org 43 | self.bucket = bucket 44 | self.links = links 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ScraperTargetResponseAllOfLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScraperTargetResponseAllOfLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScraperTargetResponseAllOfLinks: Codable { 11 | 12 | /** URI of resource. */ 13 | public var _self: String? 14 | /** URI of resource. */ 15 | public var members: String? 16 | /** URI of resource. */ 17 | public var owners: String? 18 | /** URI of resource. */ 19 | public var bucket: String? 20 | /** URI of resource. */ 21 | public var organization: String? 22 | 23 | public init(_self: String? = nil, members: String? = nil, owners: String? = nil, bucket: String? = nil, organization: String? = nil) { 24 | self._self = _self 25 | self.members = members 26 | self.owners = owners 27 | self.bucket = bucket 28 | self.organization = organization 29 | } 30 | 31 | public enum CodingKeys: String, CodingKey, CaseIterable { 32 | case _self = "self" 33 | case members 34 | case owners 35 | case bucket 36 | case organization 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/ScraperTargetResponses.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScraperTargetResponses.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ScraperTargetResponses: Codable { 11 | 12 | public var configurations: [ScraperTargetResponse]? 13 | 14 | public init(configurations: [ScraperTargetResponse]? = nil) { 15 | self.configurations = configurations 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/SecretKeys.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecretKeys.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct SecretKeys: Codable { 11 | 12 | public var secrets: [String]? 13 | 14 | public init(secrets: [String]? = nil) { 15 | self.secrets = secrets 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/SecretKeysResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecretKeysResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct SecretKeysResponse: Codable { 11 | 12 | public var secrets: [String]? 13 | public var links: SecretKeysResponseAllOfLinks? 14 | 15 | public init(secrets: [String]? = nil, links: SecretKeysResponseAllOfLinks? = nil) { 16 | self.secrets = secrets 17 | self.links = links 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/SecretKeysResponseAllOfLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecretKeysResponseAllOfLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct SecretKeysResponseAllOfLinks: Codable { 11 | 12 | public var _self: String? 13 | public var org: String? 14 | 15 | public init(_self: String? = nil, org: String? = nil) { 16 | self._self = _self 17 | self.org = org 18 | } 19 | 20 | public enum CodingKeys: String, CodingKey, CaseIterable { 21 | case _self = "self" 22 | case org 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Source.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Source.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Source: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case v1 = "v1" 14 | case v2 = "v2" 15 | case _self = "self" 16 | } 17 | public enum Languages: String, Codable, CaseIterable { 18 | case flux = "flux" 19 | case influxql = "influxql" 20 | } 21 | public var links: SourceLinks? 22 | public var id: String? 23 | public var orgID: String? 24 | public var _default: Bool? 25 | public var name: String? 26 | public var type: ModelType? 27 | public var url: String? 28 | public var insecureSkipVerify: Bool? 29 | public var telegraf: String? 30 | public var token: String? 31 | public var username: String? 32 | public var password: String? 33 | public var sharedSecret: String? 34 | public var metaUrl: String? 35 | public var defaultRP: String? 36 | public var languages: [Languages]? 37 | 38 | public init(links: SourceLinks? = nil, id: String? = nil, orgID: String? = nil, _default: Bool? = nil, name: String? = nil, type: ModelType? = nil, url: String? = nil, insecureSkipVerify: Bool? = nil, telegraf: String? = nil, token: String? = nil, username: String? = nil, password: String? = nil, sharedSecret: String? = nil, metaUrl: String? = nil, defaultRP: String? = nil, languages: [Languages]? = nil) { 39 | self.links = links 40 | self.id = id 41 | self.orgID = orgID 42 | self._default = _default 43 | self.name = name 44 | self.type = type 45 | self.url = url 46 | self.insecureSkipVerify = insecureSkipVerify 47 | self.telegraf = telegraf 48 | self.token = token 49 | self.username = username 50 | self.password = password 51 | self.sharedSecret = sharedSecret 52 | self.metaUrl = metaUrl 53 | self.defaultRP = defaultRP 54 | self.languages = languages 55 | } 56 | 57 | public enum CodingKeys: String, CodingKey, CaseIterable { 58 | case links 59 | case id 60 | case orgID 61 | case _default = "default" 62 | case name 63 | case type 64 | case url 65 | case insecureSkipVerify 66 | case telegraf 67 | case token 68 | case username 69 | case password 70 | case sharedSecret 71 | case metaUrl 72 | case defaultRP 73 | case languages 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/SourceLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SourceLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct SourceLinks: Codable { 11 | 12 | public var _self: String? 13 | public var query: String? 14 | public var health: String? 15 | public var buckets: String? 16 | 17 | public init(_self: String? = nil, query: String? = nil, health: String? = nil, buckets: String? = nil) { 18 | self._self = _self 19 | self.query = query 20 | self.health = health 21 | self.buckets = buckets 22 | } 23 | 24 | public enum CodingKeys: String, CodingKey, CaseIterable { 25 | case _self = "self" 26 | case query 27 | case health 28 | case buckets 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Sources.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sources.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Sources: Codable { 11 | 12 | public var links: ResourceMembersLinks? 13 | public var sources: [Source]? 14 | 15 | public init(links: ResourceMembersLinks? = nil, sources: [Source]? = nil) { 16 | self.links = links 17 | self.sources = sources 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/TaskCreateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TaskCreateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct TaskCreateRequest: Codable { 11 | 12 | /** The ID of the organization that owns this Task. */ 13 | public var orgID: String? 14 | /** The name of the organization that owns this Task. */ 15 | public var org: String? 16 | public var status: TaskStatusType? 17 | /** The Flux script to run for this task. */ 18 | public var flux: String 19 | /** An optional description of the task. */ 20 | public var description: String? 21 | 22 | public init(orgID: String? = nil, org: String? = nil, status: TaskStatusType? = nil, flux: String, description: String? = nil) { 23 | self.orgID = orgID 24 | self.org = org 25 | self.status = status 26 | self.flux = flux 27 | self.description = description 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/TaskLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TaskLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct TaskLinks: Codable { 11 | 12 | /** URI of resource. */ 13 | public var _self: String? 14 | /** URI of resource. */ 15 | public var owners: String? 16 | /** URI of resource. */ 17 | public var members: String? 18 | /** URI of resource. */ 19 | public var runs: String? 20 | /** URI of resource. */ 21 | public var logs: String? 22 | /** URI of resource. */ 23 | public var labels: String? 24 | 25 | public init(_self: String? = nil, owners: String? = nil, members: String? = nil, runs: String? = nil, logs: String? = nil, labels: String? = nil) { 26 | self._self = _self 27 | self.owners = owners 28 | self.members = members 29 | self.runs = runs 30 | self.logs = logs 31 | self.labels = labels 32 | } 33 | 34 | public enum CodingKeys: String, CodingKey, CaseIterable { 35 | case _self = "self" 36 | case owners 37 | case members 38 | case runs 39 | case logs 40 | case labels 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/TaskStatusType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TaskStatusType.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public enum TaskStatusType: String, Codable, CaseIterable { 11 | case active = "active" 12 | case inactive = "inactive" 13 | } 14 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/TaskUpdateRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TaskUpdateRequest.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct TaskUpdateRequest: Codable { 11 | 12 | public var status: TaskStatusType? 13 | /** The Flux script to run for this task. */ 14 | public var flux: String? 15 | /** Override the 'name' option in the flux script. */ 16 | public var name: String? 17 | /** Override the 'every' option in the flux script. */ 18 | public var every: String? 19 | /** Override the 'cron' option in the flux script. */ 20 | public var cron: String? 21 | /** Override the 'offset' option in the flux script. */ 22 | public var offset: String? 23 | /** An optional description of the task. */ 24 | public var description: String? 25 | 26 | public init(status: TaskStatusType? = nil, flux: String? = nil, name: String? = nil, every: String? = nil, cron: String? = nil, offset: String? = nil, description: String? = nil) { 27 | self.status = status 28 | self.flux = flux 29 | self.name = name 30 | self.every = every 31 | self.cron = cron 32 | self.offset = offset 33 | self.description = description 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Tasks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Tasks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Tasks: Codable { 11 | 12 | public var links: Links? 13 | public var tasks: [Task]? 14 | 15 | public init(links: Links? = nil, tasks: [Task]? = nil) { 16 | self.links = links 17 | self.tasks = tasks 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/User.swift: -------------------------------------------------------------------------------- 1 | // 2 | // User.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct User: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | public var id: String? 17 | public var oauthID: String? 18 | public var name: String 19 | /** If inactive the user is inactive. */ 20 | public var status: Status? = .active 21 | 22 | public init(id: String? = nil, oauthID: String? = nil, name: String, status: Status? = .active) { 23 | self.id = id 24 | self.oauthID = oauthID 25 | self.name = name 26 | self.status = status 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/UserResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserResponse.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct UserResponse: Codable { 11 | 12 | public enum Status: String, Codable, CaseIterable { 13 | case active = "active" 14 | case inactive = "inactive" 15 | } 16 | public var id: String? 17 | public var oauthID: String? 18 | public var name: String 19 | /** If inactive the user is inactive. */ 20 | public var status: Status? = .active 21 | public var links: UserResponseLinks? 22 | 23 | public init(id: String? = nil, oauthID: String? = nil, name: String, status: Status? = .active, links: UserResponseLinks? = nil) { 24 | self.id = id 25 | self.oauthID = oauthID 26 | self.name = name 27 | self.status = status 28 | self.links = links 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/UserResponseLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserResponseLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct UserResponseLinks: Codable { 11 | 12 | public var _self: String? 13 | 14 | public init(_self: String? = nil) { 15 | self._self = _self 16 | } 17 | 18 | public enum CodingKeys: String, CodingKey, CaseIterable { 19 | case _self = "self" 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Users.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Users.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Users: Codable { 11 | 12 | public var links: ResourceMembersLinks? 13 | public var users: [UserResponse]? 14 | 15 | public init(links: ResourceMembersLinks? = nil, users: [UserResponse]? = nil) { 16 | self.links = links 17 | self.users = users 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Variable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Variable.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Variable: Codable { 11 | 12 | public var links: VariableLinks? 13 | public var id: String? 14 | public var orgID: String 15 | public var name: String 16 | public var description: String? 17 | public var selected: [String]? 18 | public var labels: [Label]? 19 | public var arguments: VariableProperties 20 | public var createdAt: Date? 21 | public var updatedAt: Date? 22 | 23 | public init(links: VariableLinks? = nil, id: String? = nil, orgID: String, name: String, description: String? = nil, selected: [String]? = nil, labels: [Label]? = nil, arguments: VariableProperties, createdAt: Date? = nil, updatedAt: Date? = nil) { 24 | self.links = links 25 | self.id = id 26 | self.orgID = orgID 27 | self.name = name 28 | self.description = description 29 | self.selected = selected 30 | self.labels = labels 31 | self.arguments = arguments 32 | self.createdAt = createdAt 33 | self.updatedAt = updatedAt 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/VariableLinks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VariableLinks.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct VariableLinks: Codable { 11 | 12 | public var _self: String? 13 | public var org: String? 14 | public var labels: String? 15 | 16 | public init(_self: String? = nil, org: String? = nil, labels: String? = nil) { 17 | self._self = _self 18 | self.org = org 19 | self.labels = labels 20 | } 21 | 22 | public enum CodingKeys: String, CodingKey, CaseIterable { 23 | case _self = "self" 24 | case org 25 | case labels 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/VariableProperties.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VariableProperties.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct VariableProperties: Codable { 11 | 12 | public enum ModelType: String, Codable, CaseIterable { 13 | case map = "map" 14 | } 15 | public var type: ModelType? 16 | public var values: [String: String]? 17 | 18 | public init(type: ModelType? = nil, values: [String: String]? = nil) { 19 | self.type = type 20 | self.values = values 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/Models/Variables.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Variables.swift 3 | // 4 | // Generated by openapi-generator 5 | // https://openapi-generator.tech 6 | // 7 | 8 | import Foundation 9 | 10 | public struct Variables: Codable { 11 | 12 | public var variables: [Variable]? 13 | 14 | public init(variables: [Variable]? = nil) { 15 | self.variables = variables 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Sources/InfluxDBSwiftApis/Generated/SynchronizedDictionary.swift: -------------------------------------------------------------------------------- 1 | // SynchronizedDictionary.swift 2 | // 3 | // Generated by openapi-generator 4 | // https://openapi-generator.tech 5 | // 6 | 7 | import Foundation 8 | 9 | internal struct SynchronizedDictionary { 10 | 11 | private var dictionary = [K: V]() 12 | private let queue = DispatchQueue( 13 | label: "SynchronizedDictionary", 14 | qos: DispatchQoS.userInitiated, 15 | attributes: [DispatchQueue.Attributes.concurrent], 16 | autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, 17 | target: nil 18 | ) 19 | 20 | internal subscript(key: K) -> V? { 21 | get { 22 | var value: V? 23 | 24 | queue.sync { 25 | value = self.dictionary[key] 26 | } 27 | 28 | return value 29 | } 30 | set { 31 | queue.sync(flags: DispatchWorkItemFlags.barrier) { 32 | self.dictionary[key] = newValue 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Tests/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - explicit_acl 3 | - missing_docs 4 | - force_unwrapping 5 | - type_body_length 6 | - function_body_length 7 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/AuthorizationsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class AuthorizationsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.authorizationsAPI.getAuthorizations { authorizations, _ in 13 | authorizations? 14 | .authorizations? 15 | .filter { authorization in 16 | if let description = authorization.description { 17 | return description.hasSuffix("_TEST") 18 | } 19 | return false 20 | }.forEach { authorization in 21 | self.api.authorizationsAPI.deleteAuthorizationsID(authID: authorization.id!) { _, _ in 22 | } 23 | } 24 | } 25 | } 26 | 27 | func testCreateAuthorization() { 28 | let authorizationDesc = generateName("authorization") 29 | 30 | let request = AuthorizationPostRequest( 31 | description: authorizationDesc, 32 | orgID: Self.orgID, 33 | permissions: [ 34 | Permission( 35 | action: Permission.Action.read, 36 | resource: Resource( 37 | type: Resource.ModelType.users, 38 | orgID: Self.orgID 39 | ) 40 | ) 41 | ]) 42 | 43 | var checker: (Authorization) -> Void = { response in 44 | XCTAssertNotNil(response.id) 45 | XCTAssertEqual(authorizationDesc, response.description) 46 | XCTAssertEqual(Self.orgID, response.orgID) 47 | XCTAssertEqual(Permission.Action.read, response.permissions[0].action) 48 | XCTAssertEqual(Self.orgID, response.permissions[0].resource.orgID) 49 | XCTAssertEqual(Resource.ModelType.users, response.permissions[0].resource.type) 50 | XCTAssertNotNil(response.links) 51 | } 52 | 53 | checkPost(api.authorizationsAPI.postAuthorizations, request, &checker) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/BucketsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 02/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class BucketsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.bucketsAPI.getBuckets(limit: 100) { buckets, _ in 13 | buckets? 14 | .buckets? 15 | .filter { bucket in 16 | bucket.name.hasSuffix("_TEST") 17 | }.forEach { bucket in 18 | self.api.bucketsAPI.deleteBucketsID(bucketID: bucket.id!) { _, _ in 19 | } 20 | } 21 | } 22 | } 23 | 24 | func testCreateBucket() { 25 | let bucketName = generateName("bucket") 26 | let request = PostBucketRequest(orgID: Self.orgID, name: bucketName, retentionRules: []) 27 | 28 | var checker: (Bucket) -> Void = { response in 29 | XCTAssertNotNil(response.id) 30 | XCTAssertEqual(bucketName, response.name) 31 | XCTAssertEqual(Self.orgID, response.orgID) 32 | XCTAssertEqual(Bucket.ModelType.user, response.type) 33 | XCTAssertNotNil(response.links) 34 | } 35 | 36 | checkPost(api.bucketsAPI.postBuckets, request, &checker) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/DBRPsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class DBRPsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.dbrpsAPI.getDBRPs(orgID: Self.orgID) { dbrps, _ in 13 | dbrps? 14 | .content? 15 | .forEach { dbrp in 16 | self.api.dbrpsAPI.deleteDBRPID(dbrpID: dbrp.id, orgID: Self.orgID) { _, _ in 17 | } 18 | } 19 | } 20 | } 21 | 22 | func testCreateDBRPS() { 23 | let policyName = generateName("retention_policy") 24 | let request = DBRPCreate( 25 | org: "my-org", 26 | bucketID: Self.bucketID, 27 | database: "my-db", 28 | retentionPolicy: policyName) 29 | 30 | var checker: (DBRP) -> Void = { response in 31 | XCTAssertNotNil(response.id) 32 | XCTAssertEqual(Self.orgID, response.orgID) 33 | XCTAssertEqual(Self.bucketID, response.bucketID) 34 | XCTAssertEqual("my-db", response.database) 35 | XCTAssertEqual(policyName, response.retentionPolicy) 36 | } 37 | 38 | checkPost(api.dbrpsAPI.postDBRP, request, &checker) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/HealthAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 02/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | final class HealthAPITests: APIXCTestCase { 10 | func testHealth() { 11 | var checker: (HealthCheck) -> Void = { response in 12 | XCTAssertEqual(HealthCheck.Status.pass, response.status) 13 | XCTAssertEqual("influxdb", response.name) 14 | XCTAssertNotNil(response.message) 15 | XCTAssertNotNil(response.version) 16 | XCTAssertNotNil(response.commit) 17 | } 18 | 19 | checkGet(api.healthAPI.getHealth, &checker) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/LabelsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class LabelsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.labelsAPI.getLabels { labels, _ in 13 | labels? 14 | .labels? 15 | .filter {label in 16 | if let name = label.name { 17 | return name.hasSuffix("_TEST") 18 | } 19 | return false 20 | } 21 | .forEach { label in 22 | self.api.labelsAPI.deleteLabelsID(labelID: label.id!) { _, _ in 23 | } 24 | } 25 | } 26 | } 27 | 28 | func testCreateLabel() { 29 | let labelName = generateName("label") 30 | let request = LabelCreateRequest(orgID: Self.orgID, name: labelName) 31 | 32 | var checker: (LabelResponse) -> Void = { response in 33 | XCTAssertNotNil(response.label) 34 | XCTAssertNotNil(response.label?.id) 35 | XCTAssertEqual(Self.orgID, response.label?.orgID) 36 | XCTAssertEqual(labelName, response.label?.name) 37 | XCTAssertNotNil(response.links) 38 | } 39 | 40 | checkPost(api.labelsAPI.postLabels, request, &checker) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/OrganizationsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class OrganizationsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.organizationsAPI.getOrgs(limit: 100) { orgs, _ in 13 | orgs? 14 | .orgs? 15 | .filter { org in 16 | org.name.hasSuffix("_TEST") 17 | }.forEach { org in 18 | self.api.organizationsAPI.deleteOrgsID(orgID: org.id!) { _, _ in 19 | } 20 | } 21 | } 22 | } 23 | 24 | func testCreateOrg() { 25 | let orgName = generateName("org") 26 | let request = PostOrganizationRequest(name: orgName) 27 | 28 | var checker: (Organization) -> Void = { response in 29 | XCTAssertNotNil(response.id) 30 | XCTAssertEqual(orgName, response.name) 31 | XCTAssertNotNil(response.links) 32 | } 33 | 34 | checkPost(api.organizationsAPI.postOrgs, request, &checker) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/PingAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 13.10.2021. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | final class PingAPITests: APIXCTestCase { 10 | func testPing() { 11 | let expectation = XCTestExpectation(description: "Success response from API doesn't arrive") 12 | 13 | api.pingAPI.getPing { headers, error -> Void in 14 | if let error = error { 15 | XCTFail(error.description) 16 | } 17 | 18 | if let headers = headers { 19 | XCTAssertTrue(headers["X-Influxdb-Build"] != nil) 20 | XCTAssertTrue(headers["X-Influxdb-Version"] != nil) 21 | } 22 | 23 | expectation.fulfill() 24 | } 25 | 26 | wait(for: [expectation], timeout: 5) 27 | } 28 | 29 | #if swift(>=5.5) 30 | func testPingAsync() async throws { 31 | let headers = try await api.pingAPI.getPing()! 32 | XCTAssertTrue(headers["X-Influxdb-Build"] != nil) 33 | XCTAssertTrue(headers["X-Influxdb-Version"] != nil) 34 | } 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/ReadyAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 02/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | final class ReadyAPITests: APIXCTestCase { 10 | func testReady() { 11 | var checker: (Ready) -> Void = { response in 12 | XCTAssertEqual(Ready.Status.ready, response.status) 13 | XCTAssertNotNil(response.up) 14 | XCTAssertNotNil(response.started) 15 | } 16 | 17 | checkGet(api.readyAPI.getReady, &checker) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/ScraperTargetsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class ScraperTargetsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.scraperTargetsAPI.getScrapers { scrapers, _ in 13 | scrapers? 14 | .configurations? 15 | .filter { configuration in 16 | if let name = configuration.name { 17 | return name.hasSuffix("_TEST") 18 | } 19 | return false 20 | }.forEach { configuration in 21 | self.api.scraperTargetsAPI.deleteScrapersID(scraperTargetID: configuration.id!) { _, _ in 22 | } 23 | } 24 | } 25 | } 26 | 27 | func testCreateScraperTarget() { 28 | let scraperName = generateName("scraper") 29 | let request = ScraperTargetRequest( 30 | name: scraperName, 31 | type: ScraperTargetRequest.ModelType.prometheus, 32 | url: "http://localhost:8086", 33 | orgID: Self.orgID, 34 | bucketID: Self.bucketID) 35 | 36 | var checker: (ScraperTargetResponse) -> Void = { response in 37 | XCTAssertNotNil(response.id) 38 | XCTAssertEqual(scraperName, response.name) 39 | XCTAssertEqual(Self.orgID, response.orgID) 40 | XCTAssertEqual(Self.bucketID, response.bucketID) 41 | XCTAssertEqual(ScraperTargetResponse.ModelType.prometheus, response.type) 42 | XCTAssertNotNil(response.links) 43 | } 44 | 45 | checkPost(api.scraperTargetsAPI.postScrapers, request, &checker) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/SecretsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class SecretsAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.secretsAPI.getOrgsIDSecrets(orgID: Self.orgID) { response, _ in 13 | let secrets = response? 14 | .secrets? 15 | .filter { secret in 16 | secret.hasSuffix("_TEST") 17 | } 18 | 19 | self.api.secretsAPI 20 | .postOrgsIDSecrets(orgID: Self.orgID, secretKeys: SecretKeys(secrets: secrets)) { _, _ in 21 | } 22 | } 23 | } 24 | 25 | func testCreateSecret() { 26 | let request = [generateName("secret"): generateName("secret")] 27 | 28 | let expectation = XCTestExpectation(description: "Success response from API doesn't arrive") 29 | 30 | self.api.secretsAPI.patchOrgsIDSecrets(orgID: Self.orgID, requestBody: request) { _, error in 31 | if let error = error { 32 | XCTFail("Error occurs: \(error)") 33 | } 34 | 35 | expectation.fulfill() 36 | } 37 | 38 | wait(for: [expectation], timeout: 5) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/SetupAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class SetupAPITests: APIXCTestCase { 10 | func testGetSetup() { 11 | var checker: (IsOnboarding) -> Void = { response in 12 | XCTAssertEqual(false, response.allowed) 13 | } 14 | 15 | checkGet(api.setupAPI.getSetup, &checker) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/SourcesAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class SourcesAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.sourcesAPI.getSources { sources, _ in 13 | sources? 14 | .sources? 15 | .filter { source in 16 | if let name = source.name { 17 | return name.hasSuffix("_TEST") 18 | } 19 | return false 20 | }.forEach { source in 21 | self.api.sourcesAPI.deleteSourcesID(sourceID: source.id!) { _, _ in 22 | } 23 | } 24 | } 25 | } 26 | 27 | func testCreateSource() { 28 | let sourceName = generateName("source") 29 | let request = Source( 30 | orgID: Self.orgID, 31 | name: sourceName, 32 | type: Source.ModelType.v1, 33 | url: "http://localhost:8086") 34 | 35 | var checker: (Source) -> Void = { response in 36 | XCTAssertNotNil(response.id) 37 | XCTAssertEqual(sourceName, response.name) 38 | XCTAssertEqual(Self.orgID, response.orgID) 39 | XCTAssertEqual(Source.ModelType.v1, response.type) 40 | XCTAssertEqual("http://localhost:8086", response.url) 41 | XCTAssertNotNil(response.links) 42 | } 43 | 44 | checkPost(api.sourcesAPI.postSources, request, &checker) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/TasksAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class TasksAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.tasksAPI.getTasks(limit: 100) { tasks, _ in 13 | tasks? 14 | .tasks? 15 | .filter { task in 16 | task.name.hasSuffix("_TEST") 17 | }.forEach { task in 18 | self.api.tasksAPI.deleteTasksID(taskID: task.id) { _, _ in 19 | } 20 | } 21 | } 22 | } 23 | 24 | func testCreateTask() { 25 | let taskName = generateName("task") 26 | let flux = """ 27 | option task = { 28 | name: \"\(taskName)\", 29 | every: 1h 30 | } 31 | 32 | from(bucket:\"my-bucket\") |> range(start: -1m) |> last() 33 | """ 34 | let request = TaskCreateRequest(orgID: Self.orgID, flux: flux) 35 | 36 | var checker: (Task) -> Void = { response in 37 | XCTAssertNotNil(response.id) 38 | XCTAssertEqual(taskName, response.name) 39 | XCTAssertEqual(Self.orgID, response.orgID) 40 | XCTAssertEqual(flux, response.flux) 41 | XCTAssertEqual("1h", response.every) 42 | XCTAssertNotNil(response.links) 43 | } 44 | 45 | checkPost(api.tasksAPI.postTasks, request, &checker) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/UsersAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class UsersAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.usersAPI.getUsers { users, _ in 13 | users? 14 | .users? 15 | .filter { user in 16 | user.name.hasSuffix("_TEST") 17 | }.forEach { user in 18 | self.api.usersAPI.deleteUsersID(userID: user.id!) { _, _ in 19 | } 20 | } 21 | } 22 | } 23 | 24 | func testCreateUser() { 25 | let userName = generateName("user") 26 | let request = User(name: userName, status: User.Status.active) 27 | 28 | var checker: (UserResponse) -> Void = { response in 29 | XCTAssertNotNil(response.id) 30 | XCTAssertEqual(userName, response.name) 31 | XCTAssertEqual(UserResponse.Status.active, response.status) 32 | XCTAssertNotNil(response.links) 33 | } 34 | 35 | checkPost(api.usersAPI.postUsers, request, &checker) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftApisTests/VariablesAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 04/11/2020. 3 | // 4 | 5 | import InfluxDBSwift 6 | @testable import InfluxDBSwiftApis 7 | import XCTest 8 | 9 | class VariablesAPITests: APIXCTestCase { 10 | override func setUp() { 11 | super.setUp() 12 | api.variablesAPI.getVariables { variables, _ in 13 | variables? 14 | .variables? 15 | .filter { variable in 16 | variable.name.hasSuffix("_TEST") 17 | }.forEach { variable in 18 | self.api.variablesAPI.deleteVariablesID(variableID: variable.id!) { _, _ in 19 | } 20 | } 21 | } 22 | } 23 | 24 | func testCreateVariable() { 25 | let variableName = generateName("variable") 26 | let request = Variable( 27 | orgID: Self.orgID, 28 | name: variableName, 29 | arguments: VariableProperties( 30 | type: VariableProperties.ModelType.map, 31 | values: ["key1": "value1", "key2": "value2"])) 32 | 33 | var checker: (Variable) -> Void = { response in 34 | XCTAssertNotNil(response.id) 35 | XCTAssertEqual(Self.orgID, response.orgID) 36 | XCTAssertEqual(variableName, response.name) 37 | XCTAssertEqual(["key1": "value1", "key2": "value2"], response.arguments.values) 38 | XCTAssertNotNil(response.links) 39 | } 40 | 41 | checkPost(api.variablesAPI.postVariables, request, &checker) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftTests/AAJunitReportInitializerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 11/12/2020. 3 | // 4 | 5 | import Foundation 6 | 7 | @testable import InfluxDBSwift 8 | import SwiftTestReporter 9 | import XCTest 10 | 11 | class AAJunitReportInitializerTest: XCTestCase { 12 | override class func setUp() { 13 | _ = TestObserver() 14 | super.setUp() 15 | } 16 | 17 | // https://github.com/allegro/swift-junit/issues/12#issuecomment-725264315 18 | func testInit() {} 19 | } 20 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftTests/InvokableScriptsAPITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 01.04.2022. 3 | // 4 | 5 | import Foundation 6 | 7 | @testable import InfluxDBSwift 8 | import XCTest 9 | 10 | final class InvokableScriptsAPITests: XCTestCase { 11 | private var client: InfluxDBClient! 12 | 13 | override func setUp() { 14 | client = InfluxDBClient( 15 | url: Self.dbURL(), 16 | token: "my-token", 17 | options: InfluxDBClient.InfluxDBOptions(bucket: "my-bucket", org: "my-org"), 18 | protocolClasses: [MockURLProtocol.self]) 19 | } 20 | 21 | override func tearDown() { 22 | client.close() 23 | } 24 | 25 | func testGetInvokableScriptsApi() { 26 | XCTAssertNotNil(client.invokableScriptsApi) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftTests/MockHTTP.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | #if canImport(FoundationNetworking) 3 | import FoundationNetworking 4 | #endif 5 | import XCTest 6 | 7 | extension HTTPURLResponse { 8 | convenience init(statusCode: Int) { 9 | self.init(url: MockURLProtocol.url, statusCode: statusCode, httpVersion: "HTTP/1.1", headerFields: [:])! 10 | } 11 | 12 | convenience init(statusCode: Int, headers: [String: String]?) { 13 | self.init(url: MockURLProtocol.url, statusCode: statusCode, httpVersion: "HTTP/1.1", headerFields: headers)! 14 | } 15 | } 16 | 17 | class MockURLProtocol: URLProtocol { 18 | static let url = URL(string: InfluxDBClientTests.dbURL())! 19 | 20 | static var handler: ((URLRequest, Data?) throws -> (HTTPURLResponse, Data))? 21 | 22 | override class func canInit(with request: URLRequest) -> Bool { 23 | true 24 | } 25 | 26 | override class func canonicalRequest(for request: URLRequest) -> URLRequest { 27 | request 28 | } 29 | 30 | override func startLoading() { 31 | guard let handler = MockURLProtocol.handler else { 32 | XCTFail("Missing handler: 'MockURLProtocol.handler = { request in...'") 33 | return 34 | } 35 | 36 | do { 37 | let (response, data) = try handler(request, request.bodyValue) 38 | let locationHeader = response.allHeaderFields["Location"] 39 | if let location = locationHeader as? String, let url = URL(string: location), response.statusCode == 307 { 40 | client?.urlProtocol(self, wasRedirectedTo: URLRequest(url: url), redirectResponse: response) 41 | } else { 42 | client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed) 43 | client?.urlProtocol(self, didLoad: data) 44 | client?.urlProtocolDidFinishLoading(self) 45 | } 46 | } catch { 47 | client?.urlProtocol(self, didFailWithError: error) 48 | } 49 | } 50 | 51 | override func stopLoading() { 52 | } 53 | } 54 | 55 | private extension URLRequest { 56 | var bodyValue: Data? { 57 | guard let httpBody = httpBodyStreamData() else { 58 | return nil 59 | } 60 | return httpBody 61 | } 62 | 63 | private func httpBodyStreamData() -> Data? { 64 | guard let bodyStream = self.httpBodyStream else { 65 | if let httpBody = self.httpBody { 66 | return httpBody 67 | } 68 | return nil 69 | } 70 | 71 | return Data(reading: bodyStream) 72 | } 73 | } 74 | 75 | private extension Data { 76 | init(reading bodyStream: InputStream) { 77 | self.init() 78 | 79 | bodyStream.open() 80 | 81 | let buffer = UnsafeMutablePointer.allocate(capacity: 1024) 82 | defer { 83 | buffer.deallocate() 84 | } 85 | 86 | while bodyStream.hasBytesAvailable { 87 | self.append(buffer, count: bodyStream.read(buffer, maxLength: 1024)) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Tests/InfluxDBSwiftTests/PointSettingsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Jakub Bednář on 14/12/2020. 3 | // 4 | 5 | import Foundation 6 | 7 | @testable import InfluxDBSwift 8 | import XCTest 9 | 10 | final class PointSettingsTests: XCTestCase { 11 | func testCreate() { 12 | let defaultTags = InfluxDBClient.PointSettings() 13 | .addDefaultTag(key: "id", value: "132-987-655") 14 | .addDefaultTag(key: "customer", value: "California Miner") 15 | .addDefaultTag(key: "data_center", value: "${env.DATA_CENTER_LOCATION}") 16 | 17 | XCTAssertEqual(3, defaultTags.tags.count) 18 | } 19 | 20 | func testEvaluate() { 21 | setenv("DATA_CENTER_LOCATION", "west", 1) 22 | let defaultTags = InfluxDBClient.PointSettings() 23 | .addDefaultTag(key: "id", value: "132-987-655") 24 | .addDefaultTag(key: "customer", value: "California Miner") 25 | .addDefaultTag(key: "data_center", value: "${env.DATA_CENTER_LOCATION}") 26 | 27 | XCTAssertEqual([ 28 | "id": "132-987-655", 29 | "customer": "California Miner", 30 | "data_center": "west" 31 | ], defaultTags.evaluate()) 32 | 33 | unsetenv("DATA_CENTER_LOCATION") 34 | } 35 | 36 | func testNotExistEnv() { 37 | let defaultTags = InfluxDBClient.PointSettings() 38 | .addDefaultTag(key: "id", value: "132-987-655") 39 | .addDefaultTag(key: "not_exist", value: "${env.NOT_EXIST_KEY}") 40 | 41 | XCTAssertEqual([ 42 | "id": "132-987-655", 43 | "not_exist": nil 44 | ], defaultTags.evaluate()) 45 | } 46 | 47 | func testNilValue() { 48 | let defaultTags = InfluxDBClient.PointSettings() 49 | .addDefaultTag(key: "id", value: "132-987-655") 50 | .addDefaultTag(key: "nil", value: nil) 51 | 52 | XCTAssertEqual([ 53 | "id": "132-987-655", 54 | "nil": nil 55 | ], defaultTags.evaluate()) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | import InfluxDBSwiftApisTests 4 | import InfluxDBSwiftTests 5 | 6 | var tests = [XCTestCaseEntry]() 7 | tests += InfluxDBSwiftApisTests.__allTests() 8 | tests += InfluxDBSwiftTests.__allTests() 9 | 10 | XCTMain(tests) 11 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "Tests/*" 3 | - "Tests/**/*" 4 | - "Sources/InfluxDBSwift/Generated/*" 5 | - "Sources/InfluxDBSwiftApis/Generated/*" 6 | - "Sources/InfluxDBSwiftApis/Generated/**/*" --------------------------------------------------------------------------------