diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 51b4c9e..be4ccec 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,10 +9,10 @@ ] }, "fsharp-analyzers": { - "version": "0.22.0", + "version": "0.23.0", "commands": [ "fsharp-analyzers" ] } } -} +} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 72c2bfe..2e62656 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,7 @@ updates: interval: "weekly" - package-ecosystem: "nuget" - directory: "/ApiSurface" + directory: "/" schedule: interval: "weekly" ignore: diff --git a/.github/workflows/dotnet.yaml b/.github/workflows/dotnet.yaml index 0d7ab05..2543e6a 100644 --- a/.github/workflows/dotnet.yaml +++ b/.github/workflows/dotnet.yaml @@ -28,7 +28,7 @@ jobs: with: fetch-depth: 0 # so that NerdBank.GitVersioning has access to history - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -49,7 +49,7 @@ jobs: with: fetch-depth: 0 # so that NerdBank.GitVersioning has access to history - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -66,7 +66,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -79,7 +79,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -92,7 +92,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -105,7 +105,7 @@ jobs: steps: - uses: actions/checkout@master - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -118,7 +118,7 @@ jobs: steps: - uses: actions/checkout@master - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -132,7 +132,7 @@ jobs: with: fetch-depth: 0 # so that NerdBank.GitVersioning has access to history - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} @@ -174,7 +174,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v25 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} diff --git a/ConsumePlugin/AssemblyInfo.fs b/ConsumePlugin/AssemblyInfo.fs new file mode 100644 index 0000000..af862b4 --- /dev/null +++ b/ConsumePlugin/AssemblyInfo.fs @@ -0,0 +1,5 @@ +namespace ConsumePlugin.AssemblyInfo + +[] + +do () diff --git a/ConsumePlugin/ConsumePlugin.fsproj b/ConsumePlugin/ConsumePlugin.fsproj index 808c436..7278c06 100644 --- a/ConsumePlugin/ConsumePlugin.fsproj +++ b/ConsumePlugin/ConsumePlugin.fsproj @@ -10,25 +10,31 @@ + - - RecordFile.fs + + RecordFile.fs - - JsonRecord.fs + + JsonRecord.fs - PureGymDto.fs + PureGymDto.fs - RestApiExample.fs + RestApiExample.fs + + + + MockExample.fs + + + + Vault.fs - - runmyriad.sh - diff --git a/ConsumePlugin/GeneratedJson.fs b/ConsumePlugin/GeneratedJson.fs index c51e2f5..ca0132d 100644 --- a/ConsumePlugin/GeneratedJson.fs +++ b/ConsumePlugin/GeneratedJson.fs @@ -3,6 +3,7 @@ // Changes to this file will be lost when the code is regenerated. //------------------------------------------------------------------------------ + namespace ConsumePlugin /// Module containing JSON parsing methods for the InnerType type @@ -60,7 +61,17 @@ module JsonRecordType = |> Seq.map (fun elt -> elt.AsValue().GetValue ()) |> Array.ofSeq - let D = InnerType.jsonParse node.["d"] + let D = + InnerType.jsonParse ( + match node.["d"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("d") + ) + ) + | v -> v + ) let C = (match node.["hi"] with @@ -107,3 +118,68 @@ module JsonRecordType = E = E F = F } +namespace ConsumePlugin + +/// Module containing JSON parsing extension members for the ToGetExtensionMethod type +[] +module ToGetExtensionMethodJsonParseExtension = + ///Extension methods for JSON parsing + type ToGetExtensionMethod with + + /// Parse from a JSON node. + static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : ToGetExtensionMethod = + let Sailor = + (match node.["sailor"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("sailor") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Soldier = + (match node.["soldier"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("soldier") + ) + ) + | v -> v) + .AsValue() + .GetValue () + |> System.Uri + + let Tailor = + (match node.["tailor"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("tailor") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Tinker = + (match node.["tinker"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("tinker") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + { + Tinker = Tinker + Tailor = Tailor + Soldier = Soldier + Sailor = Sailor + } diff --git a/ConsumePlugin/GeneratedMock.fs b/ConsumePlugin/GeneratedMock.fs new file mode 100644 index 0000000..41292af --- /dev/null +++ b/ConsumePlugin/GeneratedMock.fs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// This code was generated by myriad. +// Changes to this file will be lost when the code is regenerated. +//------------------------------------------------------------------------------ + +namespace SomeNamespace + +/// Mock record type for an interface +type internal PublicTypeMock = + { + Mem1 : string * int -> string list + Mem2 : string -> int + Mem3 : int * option -> string + } + + static member Empty : PublicTypeMock = + { + Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem2 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem3 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + } + + interface IPublicType with + member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) + member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) + member this.Mem3 (arg_0_0, arg_0_1) = this.Mem3 (arg_0_0, arg_0_1) +namespace SomeNamespace + +/// Mock record type for an interface +type internal InternalTypeMock = + { + Mem1 : string * int -> unit + Mem2 : string -> int + } + + static member Empty : InternalTypeMock = + { + Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem2 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + } + + interface InternalType with + member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) + member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) +namespace SomeNamespace + +/// Mock record type for an interface +type private PrivateTypeMock = + { + Mem1 : string * int -> unit + Mem2 : string -> int + } + + static member Empty : PrivateTypeMock = + { + Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem2 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + } + + interface PrivateType with + member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) + member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) +namespace SomeNamespace + +/// Mock record type for an interface +type internal VeryPublicTypeMock<'a, 'b> = + { + Mem1 : 'a -> 'b + } + + static member Empty () : VeryPublicTypeMock<'a, 'b> = + { + Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + } + + interface VeryPublicType<'a, 'b> with + member this.Mem1 (arg_0_0) = this.Mem1 (arg_0_0) +namespace SomeNamespace + +/// Mock record type for an interface +type internal CurriedMock<'a> = + { + Mem1 : int -> 'a -> string + Mem2 : int * string -> 'a -> string + Mem3 : (int * string) -> 'a -> string + Mem4 : (int * string) -> ('a * int) -> string + Mem5 : int * string -> ('a * int) -> string + Mem6 : int * string -> 'a * int -> string + } + + static member Empty () : CurriedMock<'a> = + { + Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem2 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem3 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem4 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem5 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + Mem6 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) + } + + interface Curried<'a> with + member this.Mem1 (arg_0_0) (arg_1_0) = this.Mem1 (arg_0_0) (arg_1_0) + member this.Mem2 (arg_0_0, arg_0_1) (arg_1_0) = this.Mem2 (arg_0_0, arg_0_1) (arg_1_0) + member this.Mem3 ((arg_0_0, arg_0_1)) (arg_1_0) = this.Mem3 (arg_0_0, arg_0_1) (arg_1_0) + + member this.Mem4 ((arg_0_0, arg_0_1)) ((arg_1_0, arg_1_1)) = + this.Mem4 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) + + member this.Mem5 (arg_0_0, arg_0_1) ((arg_1_0, arg_1_1)) = + this.Mem5 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) + + member this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) = + this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) diff --git a/ConsumePlugin/GeneratedPureGymDto.fs b/ConsumePlugin/GeneratedPureGymDto.fs index d97aa14..8436efe 100644 --- a/ConsumePlugin/GeneratedPureGymDto.fs +++ b/ConsumePlugin/GeneratedPureGymDto.fs @@ -3,6 +3,7 @@ // Changes to this file will be lost when the code is regenerated. //------------------------------------------------------------------------------ + namespace PureGym /// Module containing JSON parsing methods for the GymOpeningHours type @@ -253,9 +254,41 @@ module Gym = .AsValue() .GetValue () - let Location = GymLocation.jsonParse node.["location"] - let AccessOptions = GymAccessOptions.jsonParse node.["accessOptions"] - let GymOpeningHours = GymOpeningHours.jsonParse node.["gymOpeningHours"] + let Location = + GymLocation.jsonParse ( + match node.["location"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("location") + ) + ) + | v -> v + ) + + let AccessOptions = + GymAccessOptions.jsonParse ( + match node.["accessOptions"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("accessOptions") + ) + ) + | v -> v + ) + + let GymOpeningHours = + GymOpeningHours.jsonParse ( + match node.["gymOpeningHours"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("gymOpeningHours") + ) + ) + | v -> v + ) let EmailAddress = (match node.["emailAddress"] with @@ -281,7 +314,17 @@ module Gym = .AsValue() .GetValue () - let Address = GymAddress.jsonParse node.["address"] + let Address = + GymAddress.jsonParse ( + match node.["address"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("address") + ) + ) + | v -> v + ) let Status = (match node.["status"] with @@ -856,7 +899,17 @@ namespace PureGym module Visit = /// Parse from a JSON node. let jsonParse (node : System.Text.Json.Nodes.JsonNode) : Visit = - let Gym = VisitGym.jsonParse node.["Gym"] + let Gym = + VisitGym.jsonParse ( + match node.["Gym"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("Gym") + ) + ) + | v -> v + ) let Duration = (match node.["Duration"] with @@ -909,8 +962,29 @@ namespace PureGym module SessionsSummary = /// Parse from a JSON node. let jsonParse (node : System.Text.Json.Nodes.JsonNode) : SessionsSummary = - let ThisWeek = SessionsAggregate.jsonParse node.["ThisWeek"] - let Total = SessionsAggregate.jsonParse node.["Total"] + let ThisWeek = + SessionsAggregate.jsonParse ( + match node.["ThisWeek"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("ThisWeek") + ) + ) + | v -> v + ) + + let Total = + SessionsAggregate.jsonParse ( + match node.["Total"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("Total") + ) + ) + | v -> v + ) { Total = Total @@ -937,9 +1011,43 @@ module Sessions = |> Seq.map (fun elt -> Visit.jsonParse elt) |> List.ofSeq - let Summary = SessionsSummary.jsonParse node.["Summary"] + let Summary = + SessionsSummary.jsonParse ( + match node.["Summary"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("Summary") + ) + ) + | v -> v + ) { Summary = Summary Visits = Visits } +namespace PureGym + +/// Module containing JSON parsing methods for the UriThing type +[] +[] +module UriThing = + /// Parse from a JSON node. + let jsonParse (node : System.Text.Json.Nodes.JsonNode) : UriThing = + let SomeUri = + (match node.["someUri"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("someUri") + ) + ) + | v -> v) + .AsValue() + .GetValue () + |> System.Uri + + { + SomeUri = SomeUri + } diff --git a/ConsumePlugin/GeneratedRestClient.fs b/ConsumePlugin/GeneratedRestClient.fs index 341824b..39efb85 100644 --- a/ConsumePlugin/GeneratedRestClient.fs +++ b/ConsumePlugin/GeneratedRestClient.fs @@ -4,6 +4,7 @@ //------------------------------------------------------------------------------ + namespace PureGym open System @@ -26,7 +27,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("v1/gyms/", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("v1/gyms/", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -52,7 +58,9 @@ module PureGymApi = let uri = System.Uri ( - client.BaseAddress, + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), System.Uri ( "v1/gyms/{gym_id}/attendance" .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), @@ -83,7 +91,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("v1/member", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("v1/member", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -109,7 +122,9 @@ module PureGymApi = let uri = System.Uri ( - client.BaseAddress, + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), System.Uri ( "v1/gyms/{gym_id}" .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), @@ -140,7 +155,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("v1/member/activity", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("v1/member/activity", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -160,13 +180,45 @@ module PureGymApi = } |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + member _.GetUrl (ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("some/url", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! stream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + + let! node = + System.Text.Json.Nodes.JsonNode.ParseAsync (stream, cancellationToken = ct) + |> Async.AwaitTask + + return UriThing.jsonParse node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + member _.GetSessions (fromDate : DateOnly, toDate : DateOnly, ct : CancellationToken option) = async { let! ct = Async.CancellationToken let uri = System.Uri ( - client.BaseAddress, + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), System.Uri ( ("/v2/gymSessions/member" + "?fromDate=" @@ -195,13 +247,176 @@ module PureGymApi = } |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + member _.CreateUserString (user : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + let queryParams = new System.Net.Http.StringContent (user) + do httpMessage.Content <- queryParams + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.CreateUserStream (user : System.IO.Stream, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + let queryParams = new System.Net.Http.StreamContent (user) + do httpMessage.Content <- queryParams + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.CreateUserByteArr (user : byte[], ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + let queryParams = new System.Net.Http.ByteArrayContent (user) + do httpMessage.Content <- queryParams + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.CreateUserByteArr' (user : array, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + let queryParams = new System.Net.Http.ByteArrayContent (user) + do httpMessage.Content <- queryParams + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.CreateUserByteArr'' (user : byte array, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + let queryParams = new System.Net.Http.ByteArrayContent (user) + do httpMessage.Content <- queryParams + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.CreateUserHttpContent (user : System.Net.Http.HttpContent, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("users/new", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Post, + RequestUri = uri + ) + + do httpMessage.Content <- user + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + member _.GetPathParam (parameter : string, ct : CancellationToken option) = async { let! ct = Async.CancellationToken let uri = System.Uri ( - client.BaseAddress, + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), System.Uri ( "endpoint/{param}" .Replace ("{param}", parameter.ToString () |> System.Web.HttpUtility.UrlEncode), @@ -227,7 +442,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -247,7 +467,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -267,7 +492,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -287,7 +517,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -307,7 +542,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -327,7 +567,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -347,7 +592,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -367,7 +617,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -386,7 +641,12 @@ module PureGymApi = let! ct = Async.CancellationToken let uri = - System.Uri (client.BaseAddress, System.Uri ("endpoint", System.UriKind.Relative)) + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ("endpoint", System.UriKind.Relative) + ) let httpMessage = new System.Net.Http.HttpRequestMessage ( @@ -401,3 +661,153 @@ module PureGymApi = } |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) } +namespace PureGym + +open System +open System.Threading +open System.Threading.Tasks +open System.IO +open System.Net +open System.Net.Http +open RestEase + +/// Module for constructing a REST client. +[] +[] +module internal ApiWithoutBaseAddress = + /// Create a REST client. + let make (client : System.Net.Http.HttpClient) : IApiWithoutBaseAddress = + { new IApiWithoutBaseAddress with + member _.GetPathParam (parameter : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> + raise ( + System.ArgumentNullException ( + nameof (client.BaseAddress), + "No base address was supplied on the type, and no BaseAddress was on the HttpClient." + ) + ) + | v -> v), + System.Uri ( + "endpoint/{param}" + .Replace ("{param}", parameter.ToString () |> System.Web.HttpUtility.UrlEncode), + System.UriKind.Relative + ) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + } +namespace PureGym + +open System +open System.Threading +open System.Threading.Tasks +open System.IO +open System.Net +open System.Net.Http +open RestEase + +/// Module for constructing a REST client. +[] +[] +module ApiWithBasePath = + /// Create a REST client. + let make (client : System.Net.Http.HttpClient) : IApiWithBasePath = + { new IApiWithBasePath with + member _.GetPathParam (parameter : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> + raise ( + System.ArgumentNullException ( + nameof (client.BaseAddress), + "No base address was supplied on the type, and no BaseAddress was on the HttpClient." + ) + ) + | v -> v), + System.Uri ( + "endpoint/{param}" + .Replace ("{param}", parameter.ToString () |> System.Web.HttpUtility.UrlEncode), + System.UriKind.Relative + ) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + } +namespace PureGym + +open System +open System.Threading +open System.Threading.Tasks +open System.IO +open System.Net +open System.Net.Http +open RestEase + +/// Module for constructing a REST client. +[] +[] +module ApiWithBasePathAndAddress = + /// Create a REST client. + let make (client : System.Net.Http.HttpClient) : IApiWithBasePathAndAddress = + { new IApiWithBasePathAndAddress with + member _.GetPathParam (parameter : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> System.Uri "https://whatnot.com" + | v -> v), + System.Uri ( + "endpoint/{param}" + .Replace ("{param}", parameter.ToString () |> System.Web.HttpUtility.UrlEncode), + System.UriKind.Relative + ) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + } diff --git a/ConsumePlugin/GeneratedVault.fs b/ConsumePlugin/GeneratedVault.fs new file mode 100644 index 0000000..cace90a --- /dev/null +++ b/ConsumePlugin/GeneratedVault.fs @@ -0,0 +1,549 @@ +//------------------------------------------------------------------------------ +// This code was generated by myriad. +// Changes to this file will be lost when the code is regenerated. +//------------------------------------------------------------------------------ + + +namespace ConsumePlugin + +/// Module containing JSON parsing methods for the JwtVaultAuthResponse type +[] +[] +module JwtVaultAuthResponse = + /// Parse from a JSON node. + let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultAuthResponse = + let NumUses = + (match node.["num_uses"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("num_uses") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Orphan = + (match node.["orphan"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("orphan") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let EntityId = + (match node.["entity_id"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("entity_id") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let TokenType = + (match node.["token_type"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("token_type") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Renewable = + (match node.["renewable"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("renewable") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let LeaseDuration = + (match node.["lease_duration"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("lease_duration") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let IdentityPolicies = + (match node.["identity_policies"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("identity_policies") + ) + ) + | v -> v) + .AsArray () + |> Seq.map (fun elt -> elt.AsValue().GetValue ()) + |> List.ofSeq + + let TokenPolicies = + (match node.["token_policies"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("token_policies") + ) + ) + | v -> v) + .AsArray () + |> Seq.map (fun elt -> elt.AsValue().GetValue ()) + |> List.ofSeq + + let Policies = + (match node.["policies"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("policies") + ) + ) + | v -> v) + .AsArray () + |> Seq.map (fun elt -> elt.AsValue().GetValue ()) + |> List.ofSeq + + let Accessor = + (match node.["accessor"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("accessor") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let ClientToken = + (match node.["client_token"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("client_token") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + { + ClientToken = ClientToken + Accessor = Accessor + Policies = Policies + TokenPolicies = TokenPolicies + IdentityPolicies = IdentityPolicies + LeaseDuration = LeaseDuration + Renewable = Renewable + TokenType = TokenType + EntityId = EntityId + Orphan = Orphan + NumUses = NumUses + } +namespace ConsumePlugin + +/// Module containing JSON parsing methods for the JwtVaultResponse type +[] +[] +module JwtVaultResponse = + /// Parse from a JSON node. + let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultResponse = + let Auth = + JwtVaultAuthResponse.jsonParse ( + match node.["auth"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("auth") + ) + ) + | v -> v + ) + + let LeaseDuration = + (match node.["lease_duration"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("lease_duration") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Renewable = + (match node.["renewable"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("renewable") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let LeaseId = + (match node.["lease_id"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("lease_id") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let RequestId = + (match node.["request_id"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("request_id") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + { + RequestId = RequestId + LeaseId = LeaseId + Renewable = Renewable + LeaseDuration = LeaseDuration + Auth = Auth + } +namespace ConsumePlugin + +/// Module containing JSON parsing methods for the JwtSecretResponse type +[] +[] +module JwtSecretResponse = + /// Parse from a JSON node. + let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtSecretResponse = + let Data8 = + (match node.["data8"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data8") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () |> System.Uri + key, value + ) + |> Seq.map System.Collections.Generic.KeyValuePair + |> System.Collections.Generic.Dictionary + + let Data7 = + (match node.["data7"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data7") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> Map.ofSeq + + let Data6 = + (match node.["data6"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data6") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) |> System.Uri + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> dict + + let Data5 = + (match node.["data5"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data5") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) |> System.Uri + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> readOnlyDict + + let Data4 = + (match node.["data4"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data4") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> Map.ofSeq + + let Data3 = + (match node.["data3"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data3") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> Seq.map System.Collections.Generic.KeyValuePair + |> System.Collections.Generic.Dictionary + + let Data2 = + (match node.["data2"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data2") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> dict + + let Data = + (match node.["data"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("data") + ) + ) + | v -> v) + .AsObject () + |> Seq.map (fun kvp -> + let key = (kvp.Key) + let value = (kvp.Value).AsValue().GetValue () + key, value + ) + |> readOnlyDict + + let LeaseDuration = + (match node.["lease_duration"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("lease_duration") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let Renewable = + (match node.["renewable"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("renewable") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let LeaseId = + (match node.["lease_id"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("lease_id") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + let RequestId = + (match node.["request_id"] with + | null -> + raise ( + System.Collections.Generic.KeyNotFoundException ( + sprintf "Required key '%s' not found on JSON object" ("request_id") + ) + ) + | v -> v) + .AsValue() + .GetValue () + + { + RequestId = RequestId + LeaseId = LeaseId + Renewable = Renewable + LeaseDuration = LeaseDuration + Data = Data + Data2 = Data2 + Data3 = Data3 + Data4 = Data4 + Data5 = Data5 + Data6 = Data6 + Data7 = Data7 + Data8 = Data8 + } + +namespace ConsumePlugin + +open System +open System.Collections.Generic +open System.Text.Json.Serialization +open System.Threading +open System.Threading.Tasks +open RestEase + +/// Module for constructing a REST client. +[] +[] +module VaultClient = + /// Create a REST client. + let make (client : System.Net.Http.HttpClient) : IVaultClient = + { new IVaultClient with + member _.GetSecret + ( + jwt : JwtVaultResponse, + path : string, + mountPoint : string, + ct : CancellationToken option + ) + = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> + raise ( + System.ArgumentNullException ( + nameof (client.BaseAddress), + "No base address was supplied on the type, and no BaseAddress was on the HttpClient." + ) + ) + | v -> v), + System.Uri ( + "v1/{mountPoint}/{path}" + .Replace("{path}", path.ToString () |> System.Web.HttpUtility.UrlEncode) + .Replace ( + "{mountPoint}", + mountPoint.ToString () |> System.Web.HttpUtility.UrlEncode + ), + System.UriKind.Relative + ) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! stream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + + let! node = + System.Text.Json.Nodes.JsonNode.ParseAsync (stream, cancellationToken = ct) + |> Async.AwaitTask + + return JwtSecretResponse.jsonParse node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.GetJwt (role : string, jwt : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + (match client.BaseAddress with + | null -> + raise ( + System.ArgumentNullException ( + nameof (client.BaseAddress), + "No base address was supplied on the type, and no BaseAddress was on the HttpClient." + ) + ) + | v -> v), + System.Uri ("v1/auth/jwt/login", System.UriKind.Relative) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! stream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask + + let! node = + System.Text.Json.Nodes.JsonNode.ParseAsync (stream, cancellationToken = ct) + |> Async.AwaitTask + + return JwtVaultResponse.jsonParse node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + } diff --git a/ConsumePlugin/JsonRecord.fs b/ConsumePlugin/JsonRecord.fs index 371e2df..b78502c 100644 --- a/ConsumePlugin/JsonRecord.fs +++ b/ConsumePlugin/JsonRecord.fs @@ -28,3 +28,16 @@ type JsonRecordType = E : string array F : int[] } + +[] +type ToGetExtensionMethod = + { + Tinker : string + Tailor : int + Soldier : System.Uri + Sailor : float + } + +[] +module ToGetExtensionMethod = + let thisModuleWouldClash = 3 diff --git a/ConsumePlugin/MockExample.fs b/ConsumePlugin/MockExample.fs new file mode 100644 index 0000000..35930c5 --- /dev/null +++ b/ConsumePlugin/MockExample.fs @@ -0,0 +1,32 @@ +namespace SomeNamespace + +open WoofWare.Myriad.Plugins + +[] +type IPublicType = + abstract Mem1 : string * int -> string list + abstract Mem2 : string -> int + abstract Mem3 : x : int * ?ct : System.Threading.CancellationToken -> string + +[] +type internal InternalType = + abstract Mem1 : string * int -> unit + abstract Mem2 : string -> int + +[] +type private PrivateType = + abstract Mem1 : string * int -> unit + abstract Mem2 : string -> int + +[] +type VeryPublicType<'a, 'b> = + abstract Mem1 : 'a -> 'b + +[] +type Curried<'a> = + abstract Mem1 : int -> 'a -> string + abstract Mem2 : int * string -> 'a -> string + abstract Mem3 : (int * string) -> 'a -> string + abstract Mem4 : (int * string) -> ('a * int) -> string + abstract Mem5 : x : int * string -> ('a * int) -> string + abstract Mem6 : int * string -> y : 'a * int -> string diff --git a/ConsumePlugin/PureGymDto.fs b/ConsumePlugin/PureGymDto.fs index 455ed88..1010dd8 100644 --- a/ConsumePlugin/PureGymDto.fs +++ b/ConsumePlugin/PureGymDto.fs @@ -177,3 +177,9 @@ type Sessions = [] Visits : Visit list } + +[] +type UriThing = + { + SomeUri : Uri + } diff --git a/ConsumePlugin/RestApiExample.fs b/ConsumePlugin/RestApiExample.fs index 7e4344d..38453e0 100644 --- a/ConsumePlugin/RestApiExample.fs +++ b/ConsumePlugin/RestApiExample.fs @@ -9,6 +9,7 @@ open System.Net.Http open RestEase [] +[] type IPureGymApi = [] abstract GetGyms : ?ct : CancellationToken -> Task @@ -25,11 +26,34 @@ type IPureGymApi = [] abstract GetMemberActivity : ?ct : CancellationToken -> Task + [] + abstract GetUrl : ?ct : CancellationToken -> Task + // We'll use this one to check handling of absolute URIs too [] abstract GetSessions : [] fromDate : DateOnly * [] toDate : DateOnly * ?ct : CancellationToken -> Task + // An example from RestEase's own docs + [] + abstract CreateUserString : [] user : string * ?ct : CancellationToken -> Task + + [] + abstract CreateUserStream : [] user : System.IO.Stream * ?ct : CancellationToken -> Task + + [] + abstract CreateUserByteArr : [] user : byte[] * ?ct : CancellationToken -> Task + + [] + abstract CreateUserByteArr' : [] user : array * ?ct : CancellationToken -> Task + + [] + abstract CreateUserByteArr'' : [] user : byte array * ?ct : CancellationToken -> Task + + [] + abstract CreateUserHttpContent : + [] user : System.Net.Http.HttpContent * ?ct : CancellationToken -> Task + [] abstract GetPathParam : [] parameter : string * ?ct : CancellationToken -> Task @@ -72,3 +96,23 @@ type IPureGymApi = [] abstract GetWithoutAnyReturnCode : ?ct : CancellationToken -> Task + +[] +type internal IApiWithoutBaseAddress = + [] + abstract GetPathParam : [] parameter : string * ?ct : CancellationToken -> Task + +// TODO: implement BasePath support + +[] +[] +type IApiWithBasePath = + [] + abstract GetPathParam : [] parameter : string * ?ct : CancellationToken -> Task + +[] +[] +[] +type IApiWithBasePathAndAddress = + [] + abstract GetPathParam : [] parameter : string * ?ct : CancellationToken -> Task diff --git a/ConsumePlugin/Vault.fs b/ConsumePlugin/Vault.fs new file mode 100644 index 0000000..73dcaf9 --- /dev/null +++ b/ConsumePlugin/Vault.fs @@ -0,0 +1,78 @@ +namespace ConsumePlugin + +open System +open System.Collections.Generic +open System.Text.Json.Serialization +open System.Threading +open System.Threading.Tasks +open RestEase + +[] +type JwtVaultAuthResponse = + { + [] + ClientToken : string + Accessor : string + Policies : string list + [] + TokenPolicies : string list + [] + IdentityPolicies : string list + [] + LeaseDuration : int + Renewable : bool + [] + TokenType : string + [] + EntityId : string + Orphan : bool + [] + NumUses : int + } + +[] +type JwtVaultResponse = + { + [] + RequestId : string + [] + LeaseId : string + Renewable : bool + [] + LeaseDuration : int + Auth : JwtVaultAuthResponse + } + +[] +type JwtSecretResponse = + { + [] + RequestId : string + [] + LeaseId : string + Renewable : bool + [] + LeaseDuration : int + Data : IReadOnlyDictionary + // These ones aren't actually part of the Vault response, but are here for tests + Data2 : IDictionary + Data3 : Dictionary + Data4 : Map + Data5 : IReadOnlyDictionary + Data6 : IDictionary + Data7 : Map + Data8 : Dictionary + } + +[] +type IVaultClient = + [] + abstract GetSecret : + jwt : JwtVaultResponse * + [] path : string * + [] mountPoint : string * + ?ct : CancellationToken -> + Task + + [] + abstract GetJwt : role : string * jwt : string * ?ct : CancellationToken -> Task diff --git a/Directory.Build.props b/Directory.Build.props index 8a619c2..2bc68d8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,12 +6,12 @@ true true true - FS3559 embedded + FS3388,FS3559 - - + +