Skip to content

Commit

Permalink
Add versions 1.45, 1.46
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jul 30, 2024
1 parent b076663 commit 00f0307
Show file tree
Hide file tree
Showing 78 changed files with 54,018 additions and 2 deletions.
20 changes: 19 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@
};
fixes = [fixHostConfigIsolation];
};
api_1_45 = mkApiYaml {
src = pkgs.fetchurl {
url = "https://docs.docker.com/reference/engine/v1.45.yaml";
hash = "sha256-PiGCCkbT/dHiSE4J+/rAX4MWfb1JR6FHkPui8DTFP7o=";
};
fixes = [fixHostConfigIsolation];
};
api_1_46 = mkApiYaml {
src = pkgs.fetchurl {
url = "https://docs.docker.com/reference/engine/v1.46.yaml";
hash = "sha256-bJr6mFqSvuFcN49NblO9pehFVCz7PSesBUweCicqRig=";
};
fixes = [fixHostConfigIsolation];
};

mkGenerateScript = apiYaml: dir: pkgs.writeShellScriptBin "generate.sh" ''
mkdir -p "${dir}"
Expand Down Expand Up @@ -172,7 +186,9 @@
api_1_41
api_1_42
api_1_43
api_1_44;
api_1_44
api_1_45
api_1_46;

generate1_36 = mkGenerateScript api_1_36 "v1.36";
generate1_37 = mkGenerateScript api_1_37 "v1.37";
Expand All @@ -183,6 +199,8 @@
generate1_42 = mkGenerateScript api_1_42 "v1.42";
generate1_43 = mkGenerateScript api_1_43 "v1.43";
generate1_44 = mkGenerateScript api_1_44 "v1.44";
generate1_45 = mkGenerateScript api_1_45 "v1.45";
generate1_46 = mkGenerateScript api_1_46 "v1.46";
};
}
);
Expand Down
2 changes: 2 additions & 0 deletions generate_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ nix run .#generate1_41
nix run .#generate1_42
nix run .#generate1_43
nix run .#generate1_44
nix run .#generate1_45
nix run .#generate1_46
6 changes: 6 additions & 0 deletions integration-tests/lib/TestLib/Docker/Networks.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ViewPatterns #-}

module TestLib.Docker.Networks where
Expand Down Expand Up @@ -41,8 +42,13 @@ createNetwork ds networkName labels = do
let networkConfig = (mkNetworkCreateRequest networkName) {
networkCreateRequestLabels = Just $ M.mapKeys T.unpack labels
}
#if MIN_VERSION_docker_engine(0,146,0)
NetworkCreateResponse {networkCreateResponseId=x} <- runDockerException ds (networkCreate networkConfig)
return (Id x)
#else
NetworkCreateResponse {networkCreateResponseId=(Just x)} <- runDockerException ds (networkCreate networkConfig)
return (Id x)
#endif

deleteNetwork :: (HasCallStack, MonadUnliftIO m, MonadLoggerIO m, MonadThrow m) => DockerState -> Id -> m ()
deleteNetwork ds networkId = do
Expand Down
4 changes: 3 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ packages:
# - ./v1.41
# - ./v1.42
# - ./v1.43
- ./v1.44
# - ./v1.44
# - ./v1.45
- ./v1.46

- ./integration-tests
8 changes: 8 additions & 0 deletions v1.45/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.stack-work
src/highlight.js
src/style.css
dist
dist-newstyle
cabal.project.local
.cabal-sandbox
cabal.sandbox.config
23 changes: 23 additions & 0 deletions v1.45/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
38 changes: 38 additions & 0 deletions v1.45/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.gitignore
.openapi-generator-ignore
.travis.yml
README.md
Setup.hs
docker-engine.cabal
git_push.sh
lib/DockerEngine.hs
lib/DockerEngine/API.hs
lib/DockerEngine/API/Config.hs
lib/DockerEngine/API/Container.hs
lib/DockerEngine/API/Distribution.hs
lib/DockerEngine/API/Exec.hs
lib/DockerEngine/API/Image.hs
lib/DockerEngine/API/Network.hs
lib/DockerEngine/API/Node.hs
lib/DockerEngine/API/Plugin.hs
lib/DockerEngine/API/Secret.hs
lib/DockerEngine/API/Service.hs
lib/DockerEngine/API/Session.hs
lib/DockerEngine/API/Swarm.hs
lib/DockerEngine/API/System.hs
lib/DockerEngine/API/Task.hs
lib/DockerEngine/API/Volume.hs
lib/DockerEngine/Client.hs
lib/DockerEngine/Core.hs
lib/DockerEngine/Logging.hs
lib/DockerEngine/LoggingKatip.hs
lib/DockerEngine/LoggingMonadLogger.hs
lib/DockerEngine/MimeTypes.hs
lib/DockerEngine/Model.hs
lib/DockerEngine/ModelLens.hs
openapi.yaml
stack.yaml
tests/ApproxEq.hs
tests/Instances.hs
tests/PropMime.hs
tests/Test.hs
1 change: 1 addition & 0 deletions v1.45/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.0
203 changes: 203 additions & 0 deletions v1.45/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
## OpenAPI Auto-Generated [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) Bindings to `Docker Engine API`

The library in `lib` provides auto-generated-from-OpenAPI [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the Docker Engine API API.

OpenApi Version: 3.0.1

## Installation

Installation follows the standard approach to installing Stack-based projects.

1. Install the [Haskell `stack` tool](http://docs.haskellstack.org/en/stable/README).
2. To build the package, and generate the documentation (recommended):
```
stack haddock
```
which will generate docs for this lib in the `docs` folder.

To generate the docs in the normal location (to enable hyperlinks to external libs), remove
```
build:
haddock-arguments:
haddock-args:
- "--odir=./docs"
```
from the stack.yaml file and run `stack haddock` again.

3. To run unit tests:
```
stack test
```

## OpenAPI-Generator

The code generator that produced this library, and which explains how
to obtain and use the openapi-generator cli tool lives at

https://openapi-generator.tech

The _generator-name_ argument (`--generator-name`) passed to the cli tool used should be

```
haskell-http-client
```

### Unsupported OpenAPI Features

* Model Inheritance

This is beta software; other cases may not be supported.

### Codegen "additional properties" parameters

These options allow some customization of the code generation process.

**haskell-http-client additional properties:**

| OPTION | DESCRIPTION | DEFAULT | ACTUAL |
|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------|----------|---------------------------------------|
| allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | true |
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | false |
| allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | false |
| baseModule | Set the base module namespace | | DockerEngine |
| cabalPackage | Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens | | docker-engine |
| cabalVersion | Set the cabal version number, consisting of a sequence of one or more integers separated by dots | 0.1.0.0 | 0.1.0.0 |
| customTestInstanceModule | test module used to provide typeclass instances for types not known by the generator | | |
| configType | Set the name of the type used for configuration | | DockerEngineConfig |
| dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d |
| dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | |
| dateTimeParseFormat | overrides the format string used to parse a datetime | | |
| generateEnums | Generate specific datatypes for OpenAPI enums | true | true |
| generateFormUrlEncodedInstances | Generate FromForm/ToForm instances for models used by x-www-form-urlencoded operations (model fields must be primitive types) | true | true |
| generateLenses | Generate Lens optics for Models | true | true |
| generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true |
| inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | true | true |
| modelDeriving | Additional classes to include in the deriving() clause of Models | | |
| requestType | Set the name of the type used to generate requests | | DockerEngineRequest |
| strictFields | Add strictness annotations to all model fields | true | true |
| useKatip | Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger | true | true |
| queryExtraUnreserved | Configures additional querystring characters which must not be URI encoded, e.g. '+' or ':' | | |

[1]: https://www.stackage.org/haddock/lts-9.0/iso8601-time-0.1.4/Data-Time-ISO8601.html#v:formatISO8601Millis

An example setting _dateTimeFormat_ and _strictFields_:

```
java -jar openapi-generator-cli.jar generate -i petstore.yaml -g haskell-http-client -o output/haskell-http-client --additional-properties=dateTimeFormat="%Y-%m-%dT%H:%M:%S%Q%z" --additional-properties=strictFields=false
```

View the full list of Codegen "config option" parameters with the command:

```
java -jar openapi-generator-cli.jar config-help -g haskell-http-client
```

## Usage Notes

### Example Petstore Haddock documentation

An example of the generated haddock documentation targeting the server http://petstore.swagger.io/ (Petstore) can be found [here][2]

[2]: https://hackage.haskell.org/package/swagger-petstore

### Example Petstore App

An example application using the auto-generated haskell-http-client bindings for the server http://petstore.swagger.io/ can be found [here][3]

[3]: https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/haskell-http-client/example-app

This library is intended to be imported qualified.

### Modules

| MODULE | NOTES |
| ------------------- | --------------------------------------------------- |
| DockerEngine.Client | use the "dispatch" functions to send requests |
| DockerEngine.Core | core functions, config and request types |
| DockerEngine.API | construct api requests |
| DockerEngine.Model | describes api models |
| DockerEngine.MimeTypes | encoding/decoding MIME types (content-types/accept) |
| DockerEngine.ModelLens | lenses for model fields |
| DockerEngine.Logging | logging functions and utils |


### MimeTypes

This library adds type safety around what OpenAPI specifies as
Produces and Consumes for each Operation (e.g. the list of MIME types an
Operation can Produce (using 'accept' headers) and Consume (using 'content-type' headers).

For example, if there is an Operation named _addFoo_, there will be a
data type generated named _AddFoo_ (note the capitalization), which
describes additional constraints and actions on the _addFoo_ operation
via its typeclass instances. These typeclass instances can be viewed
in GHCi or via the Haddocks.

* required parameters are included as function arguments to _addFoo_
* optional non-body parameters are included by using `applyOptionalParam`
* optional body parameters are set by using `setBodyParam`

Example code generated for pretend _addFoo_ operation:

```haskell
data AddFoo
instance Consumes AddFoo MimeJSON
instance Produces AddFoo MimeJSON
instance Produces AddFoo MimeXML
instance HasBodyParam AddFoo FooModel
instance HasOptionalParam AddFoo FooName
instance HasOptionalParam AddFoo FooId
```

this would indicate that:

* the _addFoo_ operation can consume JSON
* the _addFoo_ operation produces JSON or XML, depending on the argument passed to the dispatch function
* the _addFoo_ operation can set it's body param of _FooModel_ via `setBodyParam`
* the _addFoo_ operation can set 2 different optional parameters via `applyOptionalParam`

If the OpenAPI spec doesn't declare it can accept or produce a certain
MIME type for a given Operation, you should either add a Produces or
Consumes instance for the desired MIME types (assuming the server
supports it), use `dispatchLbsUnsafe` or modify the OpenAPI spec and
run the generator again.

New MIME type instances can be added via MimeType/MimeRender/MimeUnrender

Only JSON instances are generated by default, and in some case
x-www-form-urlencoded instances (FromFrom, ToForm) will also be
generated if the model fields are primitive types, and there are
Operations using x-www-form-urlencoded which use those models.

### Authentication

A haskell data type will be generated for each OpenAPI authentication type.

If for example the AuthMethod `AuthOAuthFoo` is generated for OAuth operations, then
`addAuthMethod` should be used to add the AuthMethod config.

When a request is dispatched, if a matching auth method is found in
the config, it will be applied to the request.

### Example

```haskell
mgr <- newManager defaultManagerSettings
config0 <- withStdoutLogging =<< newConfig
let config = config0
`addAuthMethod` AuthOAuthFoo "secret-key"

let addFooRequest =
addFoo
(ContentType MimeJSON)
(Accept MimeXML)
(ParamBar paramBar)
(ParamQux paramQux)
modelBaz
`applyOptionalParam` FooId 1
`applyOptionalParam` FooName "name"
`setHeader` [("qux_header","xxyy")]
addFooResult <- dispatchMime mgr config addFooRequest
```

See the example app and the haddocks for details.
2 changes: 2 additions & 0 deletions v1.45/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Loading

0 comments on commit 00f0307

Please sign in to comment.