Open allentv opened 3 years ago
Hi @allentv, Thank you for the feature request! Adding Remote Config support to Admin Python SDK is something we plan to work on. Unfortunately, I cannot promise you a timeline as we have not started any work on this yet. This issue will track the progress once we start working on this feature.
Thanks again for contributing to the Admin Go SDK! As always, we greatly appreciate contributions to the codebase if you plan to work on adding Remote Config support to the Python SDK. Let me know if you are interested and we can start with putting together an API proposal first.
I am interested in working on the API proposal. What are the next steps?
Hi @allentv ! That is great! You can start by proposing an API similar to what we did in the Go repo. Please also refer to the released RC APIs in Admin Node.js and Java SDKs. Let me know if you have any questions or need help working on the API proposal. Once we agree on an API surface here I can start the internal review process for public APIs. Thank you!
I unfortunately don't have free time to work on this. Could you assign this to someone else who might be interested?
No problem! Thank you for you interest @allentv! We highly appreciate it!
Here's something I threw together in case anyone finds this and wants a free baseline
class RemoteConfigClient:
def __init__(self, app: App):
self.app = app
self.access_token = self._get_access_token()
self.project_id = self.app.project_id
self.base_url = f"https://firebaseremoteconfig.googleapis.com/v1/projects/{self.project_id}/remoteConfig"
@property
def config(self):
return self.fetch_and_activate()
def _get_access_token(self) -> str:
access_token = self.app.credential.get_access_token().access_token
return access_token
def fetch_and_activate(self):
response = requests.get(self.base_url, headers=self._get_headers())
response.raise_for_status()
return response.json()
def _get_headers(self) -> dict:
return {
"Authorization": f"Bearer {self.access_token}",
"Content-Type": "application/json; UTF-8"
}
def get_string(self, key: str, default='') -> str:
parameters = self.config.get('parameters', {})
return parameters.get(key, {}).get('defaultValue', {}).get('value', default)
def get_bool(self, key: str, default=False) -> bool:
parameters = self.config.get('parameters', {})
return parameters.get(key, {}).get('defaultValue', {}).get('value', default)
Example usage:
remote_config = RemoteConfigClient(get_app())
remote_config.get_bool('is_feature_enabled_example')
And if this is enough of an API proposal (for some features), then great.
Node and Java have full support for Remote Config. I had worked on a PR for the Remote Config spec for
Golang
few months ago and was wondering if there are plans for Python support?