Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow api to publish config for maap-py #116

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions api/endpoints/environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from flask_restx import Resource
from flask import request
from api.restplus import api
from urllib.parse import urlsplit
from api import settings
Expand All @@ -11,6 +12,26 @@
ns = api.namespace('environment', description='Operations related to the MAAP environment')


@ns.route('/config')
class Config(Resource):
def get(self):
"""
Request environment metadata for a current ADE hostname
:return:
"""
try:
key = "CLIENT_SETTINGS"
config = getattr(settings, key)
maap_api_root = request.base_url.replace("/environment/config", '')
service = config.get("service")
service.update({"maap_api_root": maap_api_root})
return config
except ValueError as e:
logging.exception("No CLIENT_SETTINGS found in settings file")
return {}, 404



@ns.route('/config/<string:ade_host>')
class Config(Resource):
def get(self, ade_host):
Expand Down
69 changes: 69 additions & 0 deletions api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,72 @@ def str2bool(v):

# PORTAL PATHS
PORTAL_ADMIN_DASHBOARD_PATH = os.getenv('PORTAL_ADMIN_DASHBOARD_PATH', '')

CLIENT_SETTINGS = {
"maap_endpoint": {
"search_granule_url": "cmr/granules",
"search_collection_url": "cmr/collections",
"algorithm_register": "mas/algorithm",
"algorithm_build": "dps/algorithm/build",
"mas_algo": "mas/algorithm",
"dps_job": "dps/job",
"wmts": "wmts",
"member": "members/self",
"member_dps_token": "members/dps/userImpersonationToken",
"requester_pays": "members/self/awsAccess/requesterPaysBucket",
"edc_credentials": "members/self/awsAccess/edcCredentials/{endpoint_uri}",
"s3_signed_url": "members/self/presignedUrlS3/{bucket}/{key}",
"workspace_bucket_credentials": "members/self/awsAccess/workspaceBucket"
},
"service": {
"maap_token": "some-token",
"tiler_endpoint": "https://8e9mu91qr6.execute-api.us-east-1.amazonaws.com/production",
},
"search": {
"indexed_attributes" : [
"site_name,Site Name,string",
"data_format,Data Format,string",
"track_number,Track Number,float",
"polarization,Polarization,string",
"dataset_status,Dataset Status,string",
"geolocated,Geolocated,boolean",
"spat_res,Spatial Resolution,float",
"samp_freq,Sampling Frequency,float",
"acq_mode,Acquisition Mode,string",
"band_ctr_freq,Band Center Frequency,float",
"freq_band_name,Frequency Band Name,string",
"swath_width,Swath Width,float",
"field_view,Field of View,float",
"laser_foot_diam,Laser Footprint Diameter,float",
"pass_number,Pass Number,int",
"revisit_time,Revisit Time,float",
"flt_number,Flight Number,int",
"number_plots,Number of Plots,int",
"plot_area,Plot Area,float",
"subplot_size,Subplot Size,float",
"tree_ht_meas_status,Tree Height Measurement Status,boolean",
"br_ht_meas_status,Breast Height Measurement Status,boolean",
"br_ht,Breast Height,float",
"beam,Beam,int",
"intensity_status,intensity Status,boolean",
"ret_dens,Return Density,float",
"ret_per_pulse,Returns Per Pulse,string",
"min_diam_meas,Minimum Diameter Measured,float",
"allometric_model_appl,Allometric Model Applied,string",
"stem_mapped_status,Stem Mapped Status,boolean",
"br_ht_modeled_status,Breast Height Modeled Status,boolean",
"flt_alt,Flight Altitude,float",
"gnd_elev,Ground Elevation,float",
"hdg,Heading,float",
"swath_slant_rg_st_ang,Swath Slant Range Start Angle,float",
"azm_rg_px_spacing,Azimuth Range Pixel Spacing,float",
"slant_rg_px_spacing,Slant Range Pixel Spacing,float",
"acq_type,Acquisition Type,string",
"orbit_dir,Orbit Direction,string",
"modis_pft,MODIS PFT,string",
"wwf_ecorgn,WWF Ecoregion,string",
"band_ctr_wavelength,Band Center Wavelength,float",
"swath_slant_rg_end_ang,Swath Slant Range End Angle,float"
]
}
}