From 68a300d05d1e1791a9206c48838a314f009339d1 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Thu, 17 Aug 2023 17:22:08 -0400 Subject: [PATCH 1/2] Update the "front door" email address to hello@worldwidetelescope.org --- README.md | 8 ++++---- setup.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8cb5741..6378e2c 100644 --- a/README.md +++ b/README.md @@ -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 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/ @@ -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]. diff --git a/setup.py b/setup.py index 8ea51d1..ef3ee3a 100644 --- a/setup.py +++ b/setup.py @@ -35,11 +35,11 @@ def get_long_desc(): setup_args = dict( name="wwt_api_client", # cranko project-name version="0.dev0", # cranko project-version - description="An API client for the AAS WorldWide Telescope web services", + 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", From f5f4f816e4e0981846b173281655995ef3708b9c Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sun, 22 Oct 2023 12:19:37 -0400 Subject: [PATCH 2/2] constellations: start defaulting to the production service! --- ...api_client.constellations.ClientConfig.rst | 2 + wwt_api_client/constellations/__init__.py | 62 +++++++++++-------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/docs/api/wwt_api_client.constellations.ClientConfig.rst b/docs/api/wwt_api_client.constellations.ClientConfig.rst index c56242d..3fdbfec 100644 --- a/docs/api/wwt_api_client.constellations.ClientConfig.rst +++ b/docs/api/wwt_api_client.constellations.ClientConfig.rst @@ -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 diff --git a/wwt_api_client/constellations/__init__.py b/wwt_api_client/constellations/__init__.py index 937c879..5cdcc2f 100644 --- a/wwt_api_client/constellations/__init__.py +++ b/wwt_api_client/constellations/__init__.py @@ -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 @@ -56,21 +54,17 @@ 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 @@ -78,6 +72,10 @@ def new_default(cls) -> "ClientConfig": - 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 @@ -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: @@ -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] @@ -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": """ @@ -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", )