GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - palantir/conjure-python: Conjure generator for Python clients

BranchesTags
Open more actions menu

Latest commit

 

History

1,236 Commits
1,236 Commits

Folders and files

NameName
Last commit message
Last commit date
.baseline
.baseline
 
 
.circleci
.circleci
 
 
.github
.github
 
 
conjure-python-core
conjure-python-core
 
 
conjure-python-verifier
conjure-python-verifier
 
 
conjure-python
conjure-python
 
 
gradle
gradle
 
 
.bulldozer.yml
.bulldozer.yml
 
 
.changelog.yml
.changelog.yml
 
 
.excavator.yml
.excavator.yml
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 
versions.lock
versions.lock
 
 
versions.props
versions.props
 
 

Repository files navigation

Autorelease

Conjure-Python Bintray License

CLI to generate Python classes from Conjure API definitions.

Overview

The generated clients provide a simple interface for executing statically typed remote procedure calls from Python 2 or 3.

Usage

The recommended way to use conjure-python is via a build tool like gradle-conjure. However, if you don't want to use gradle-conjure, there is also an executable which conforms to RFC 002.

Usage: conjure-python generate <input> <output> [...options]

    --packageName         package name that will appear in setup.py
    --packageVersion      version number that will appear in setup.py
    --packageDescription  description that will appear in setup.py
    --packageUrl          url that will appear in setup.py
    --packageAuthor       author that will appear in setup.py
    --writeCondaRecipe    use this boolean option to generate a `conda_recipe/meta.yaml`

Example generated objects

  • Conjure object: ManyFieldExample

    example = ManyFieldExample('alias', 1.0, 1, [], {}, [])
  • Conjure union: UnionTypeExample

    stringVariant = UnionTypeExample(string_example="foo")
  • Conjure enum: EnumExample

    one = EnumExample.ONE;
    print(one); // prints: 'ONE'
  • Conjure alias: StringAliasExample

    Python uses structural (duck-typing) so aliases are currently transparent.

Example Client interfaces

Example service interface: TestService

class TestService(Service):
    """A Markdown description of the service. "Might end with quotes"
    """

    def get_file_systems(self, auth_header):
        # type: (str) -> Dict[str, BackingFileSystem]
        """Returns a mapping from file system id to backing file system configuration.
        """

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        } # type: Dict[str, Any]

        _params = {
        } # type: Dict[str, Any]

        _path_params = {
        } # type: Dict[str, Any]

        _json = None # type: Any

        _path = '/catalog/fileSystems'
        _path = _path.format(**_path_params)

        _response = self._request( # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), DictType(str, BackingFileSystem))

Constructing clients

Use conjure-python-client which leverages requests:

from conjure_python_client import RequestsClient, ServiceConfiguration

config = ServiceConfiguration()
config.uris = ["https://foo.com/api"]
service = RequestsClient.create(TestService,
    user_agent="something/1.2.3",
    service_config=config)

service.do_something(auth_header, param)

mypy typings

Generated code has mypy comments for optional static typing.

 class TestService(Service):
     '''A Markdown description of the service.'''

     def get_file_systems(self, authHeader):
+        # type: (str) -> Dict[str, BackingFileSystem]

Contributing

See the CONTRIBUTING.md document.

License

This project is made available under the Apache 2.0 License.

About

Conjure generator for Python clients

Topics

octo-correct-managed

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity
Custom properties

Stars

27 stars

Watchers

256 watching

Forks

20 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.