Skip to content

Commit

Permalink
Release commit created with Cranko.
Browse files Browse the repository at this point in the history
+++ cranko-release-info-v1
[[projects]]
qnames = ["wwt_api_client", "pypa"]
version = "0.5.0"
age = 0

+++
  • Loading branch information
cranko committed Oct 24, 2023
2 parents 9157eca + a38371a commit 0e088d0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# wwt_api_client 0.5.0 (2023-10-24)

Start defaulting to the production Constellations API service (#28, @pkgw)!


# wwt_api_client 0.4.0 (2023-07-21)

This release adds many additional new APIs for Constellations.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[![PyPI version](https://badge.fury.io/py/wwt-api-client.svg)](https://badge.fury.io/py/wwt-api-client)
[![codecov](https://codecov.io/gh/WorldWideTelescope/wwt_api_client/branch/master/graph/badge.svg?token=R7hIYRRRCl)](https://codecov.io/gh/WorldWideTelescope/wwt_api_client)

# `wwt_api_client`: Accessing AAS WorldWide Telescope Web Service from Python
# `wwt_api_client`: Accessing WorldWide Telescope Web Services from Python

<!--pypi-begin-->
The [wwt_api_client] package provides a Python interface to the various web
services that power the [AAS](https://aas.org/) [WorldWide
Telescope](https://worldwidetelescope.org/) project.
services that power the [WorldWide Telescope](https://worldwidetelescope.org/)
project.

[wwt_api_client]: https://wwt-api-client.readthedocs.io/
<!--pypi-end-->
Expand Down Expand Up @@ -72,7 +72,7 @@ All participation in WWT communities is conditioned on your adherence to the

## Acknowledgments

The AAS WorldWide Telescope system is a [.NET Foundation] project. Work on WWT
The WorldWide Telescope system is a [.NET Foundation] project. Work on WWT
has been supported by the [American Astronomical Society] (AAS), the US
[National Science Foundation] (grants [1550701], [1642446], and [2004840]), the [Gordon
and Betty Moore Foundation], and [Microsoft].
Expand Down
2 changes: 2 additions & 0 deletions docs/api/wwt_api_client.constellations.ClientConfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ ClientConfig

~ClientConfig.new_default
~ClientConfig.new_dev
~ClientConfig.new_prod

.. rubric:: Methods Documentation

.. automethod:: new_default
.. automethod:: new_dev
.. automethod:: new_prod
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
author = "WorldWide Telescope project"
copyright = "2019-2023 " + author

release = "0.4.0" # cranko project-version
release = "0.5.0" # cranko project-version
version = ".".join(release.split(".")[:2])

extensions = [
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def get_long_desc():

setup_args = dict(
name="wwt_api_client", # cranko project-name
version="0.4.0", # cranko project-version
description="An API client for the AAS WorldWide Telescope web services",
version="0.5.0", # cranko project-version
description="An API client for WorldWide Telescope web services",
long_description=get_long_desc(),
long_description_content_type="text/markdown",
author="AAS WorldWide Telescope Team",
author_email="wwt@aas.org",
author="WorldWide Telescope Team",
author_email="hello@worldwidetelescope.org",
url="https://github.com/WorldWideTelescope/wwt_api_client",
packages=[
"wwt_api_client",
Expand Down
62 changes: 36 additions & 26 deletions wwt_api_client/constellations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
.. _OpenID Connect: https://openid.net/connect/
The client can connect to different instances of the backend API and
authentication service: the production environment (**which doesn't exist
yet**), the development environment, or a local testing instance. To make it so
that your code can choose which version to use on-the-fly, use the default
constructors and set the environment variable ``NUXT_PUBLIC_API_URL``. You'll
probably wish to use one of the following values:
- ``http://localhost:7000`` for a standard local testing environment, or
- ``https://api.wwtelescope.dev/`` for the development environment
authentication service. By default, it connects to the production environment.
To make it so that your code can choose which version to use on-the-fly, use the
default constructors and set the environment variable ``NUXT_PUBLIC_API_URL``.
You'll probably wish to use one of the following values:
- ``https://api.worldwidetelescope.org`` for the production API
- ``http://localhost:7000`` for a standard local testing environment
"""

from dataclasses import dataclass
Expand Down Expand Up @@ -56,28 +54,28 @@ def new_default(cls) -> "ClientConfig":
"""
Create a new client configuration with sensible default settings.
**Note!** Eventually this method will default to using the public,
production WWT Constellations service. But since that doesn't exist, you
currently must set *at least* the environment variable
``NUXT_PUBLIC_API_URL`` to indicate which service to use. The short
advice for now is that you should almost definitely set
``NUXT_PUBLIC_API_URL`` to either ``http://localhost:7000`` or to
``https://api.wwtelescope.dev/``.
This method defaults to using the public, production WWT Constellations
service. To override the backend, set ``NUXT_PUBLIC_API_URL`` to
something else, such as ``http://localhost:7000`` for the default local
testing configuration.
The long version is that the "sensible default" settings are determined
in the following way:
The "sensible default" settings are determined in the following way:
- If the environment variable ``NUXT_PUBLIC_API_URL`` is set, its value
used as the base URL for all API calls. (The name of this variable
aligns with the one used by the Constellations frontend server.)
- **Otherwise, an error is raised as mentioned above.**
- Otherwise, ``https://api.worldwidetelescope.org`` is used.
- If the environment variable ``NUXT_PUBLIC_KEYCLOAK_URL`` is set, its
value used as the base URL for the authentication service.
- Otherwise, if the environment variable ``KEYCLOAK_URL`` is set, its
value is used.
- Otherwise, if the base API URL contains the string ``localhost``, the
value ``http://localhost:8080`` is used. This is the default used by
the standard Keycloak Docker image.
- Otherwise, if the base API URL contains the string
``worldwidetelescope.org``, the value
``https://worldwidetelescope.org/auth/`` is used. This is the setting
for the WWT Constellations production environment.
- Otherwise, if the base API URL contains the string
``wwtelescope.dev``, the value ``https://wwtelescope.dev/auth/`` is
used. This is the setting for the WWT Constellations development
Expand All @@ -88,12 +86,12 @@ def new_default(cls) -> "ClientConfig":
the text ``realms/constellations`` is appended.
- Finally, if the environment variable ``WWT_API_CLIENT_ID`` is set, its
value is used to set the client ID.
- Otherwise it defaults to ``cli-tool``.
- Otherwise it defaults to ``automation``.
"""

api_url = os.environ.get("NUXT_PUBLIC_API_URL")
client_id = os.environ.get("WWT_API_CLIENT_ID", "cli-tool")
default_id_base = None
client_id = os.environ.get("WWT_API_CLIENT_ID", "automation")
default_id_base = "https://worldwidetelescope.org/auth/"

if api_url is not None:
if "localhost" in api_url:
Expand All @@ -103,10 +101,7 @@ def new_default(cls) -> "ClientConfig":
# dev mode?
default_id_base = "https://wwtelescope.dev/auth/"
else:
# TODO: default to using the production API, once it exists!
raise Exception(
"until WWT Constellations is released, you must set the environment variable NUXT_PUBLIC_API_URL"
)
api_url = "https://api.worldwidetelescope.org"

if api_url.endswith("/"):
api_url = api_url[:-1]
Expand All @@ -128,6 +123,21 @@ def new_default(cls) -> "ClientConfig":
api_url=api_url,
)

@classmethod
def new_prod(cls) -> "ClientConfig":
"""
Create a new client configuration explicitly set up for the WWT
Constellations production environment.
You should probably use :meth:`new_default` unless you explicitly want
your code to *always* refer to the production environment.
"""
return cls(
id_provider_url="https://worldwidetelescope.org/auth/realms/constellations",
client_id="automation",
api_url="https://api.worldwidetelescope.org",
)

@classmethod
def new_dev(cls) -> "ClientConfig":
"""
Expand All @@ -140,7 +150,7 @@ def new_dev(cls) -> "ClientConfig":
return cls(
id_provider_url="https://wwtelescope.dev/auth/realms/constellations",
client_id="cli-tool",
api_url="https://api.wwtelescope.dev/",
api_url="https://api.wwtelescope.dev",
)


Expand Down

0 comments on commit 0e088d0

Please sign in to comment.