def _update_all_developer_attributes( username, password, mfa_secret, token, zonename, org, profile, name, body, **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, name) .update_all_developer_attributes(body) .text )
def _delete_developer( username, password, mfa_secret, token, zonename, org, profile, name, **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, name) .delete_developer() .text )
def _set_developer_status( username, password, mfa_secret, token, zonename, org, profile, name, action, **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, name) .set_developer_status(action) .text )
def _get_developer_by_app( username, password, mfa_secret, token, zonename, org, profile, app_name, **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, None) .get_developer_by_app(app_name) .text )
def download_developers_snapshot(self): self.snapshot_data.developers = Developers(self.auth, self.org_name, None).list_developers( prefix=self.prefix, format='dict' ) write_file( self.snapshot_data.developers, self._gen_download_path(is_snapshot=True, subpaths=['developers', 'developers.json']), fs_write=self.fs_write, indent=2, ) return self.snapshot_data.developers
def download_developers(self): for developer in self.snapshot_data.developers: try: write_file( Developers(self.auth, self.org_name, developer).get_developer().text, Backups.generate_download_path( self.org_path, subpaths=['developers', f'{developer}.json'] ), fs_write=self.fs_write, ) except HTTPError as e: Backups.log_error(e, append_msg=' for Developer ({developer})') self._Backups__progress_callback(desc='Developers')
def download_developers(self): for developer in self.snapshot_data.developers: try: write_file( Developers(self.auth, self.org_name, developer).get_developer().text, self._gen_download_path(subpaths=['developers', f'{developer}.json']), fs_write=self.fs_write, ) except HTTPError as e: console.echo( f'Ignoring {type(e).__name__} {e.response.status_code} error for Developer ({developer})' ) self._progress_callback(desc='Developers') return self.snapshot_data.developers
def download_developers_snapshot(self): self.snapshot_data.developers = Developers(self.auth, self.org_name, None).list_developers( prefix=self.prefix, format='dict' ) data = { 'snapshot': self.snapshot_data.developers, 'target_path': self._gen_snapshot_path(subpaths=['developers', 'developers.json']), 'fs_write': self.fs_write, 'indent': 2, } write_file( data['snapshot'], data['target_path'], fs_write=data['fs_write'], indent=data['indent'] ) return self.snapshot_data.developers
def auth_with_prefix( auth_obj, org, name, attribute_name=APIGEE_CLI_AUTHORIZATION_DEVELOPER_ATTRIBUTE ): team = ( Developers(auth_obj, org, auth_obj.username) .get_developer_attribute(attribute_name) .json()['value'] ) allowed = team.split(',') for prefix in allowed: if name.startswith(prefix): return name raise Exception( f'401 Client Error: Unauthorized for team: {str(allowed)}\nAttempted to access resource: {name}' )
def download_apps_snapshot(self, expand=False, count=1000, startkey=""): self.snapshot_data.apps = Apps(self.auth, self.org_name, None).list_apps_for_all_developers( Developers(self.auth, self.org_name, None).list_developers( prefix=None, expand=expand, count=count, startkey=startkey, format='dict' ), prefix=self.prefix, format='dict', ) self.snapshot_data.apps = {k: v for k, v in self.snapshot_data.apps.items() if v} for app, details in self.snapshot_data.apps.items(): write_file( details, self._gen_download_path(is_snapshot=True, subpaths=['apps', f'{app}.json']), fs_write=self.fs_write, indent=2, ) return self.snapshot_data.apps
def _list_developers( username, password, mfa_secret, token, zonename, org, profile, prefix=None, expand=False, count=1000, startkey="", **kwargs ): return Developers( gen_auth(username, password, mfa_secret, token, zonename), org, None ).list_developers(prefix=prefix, expand=expand, count=count, startkey=startkey)
def _update_a_developer_attribute( username, password, mfa_secret, token, zonename, org, profile, name, attribute_name, updated_value, **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, name) .update_a_developer_attribute(attribute_name, updated_value) .text )
def _create_developer( username, password, mfa_secret, token, zonename, org, profile, name, first_name, last_name, user_name, attributes='{"attributes" : [ ]}', **kwargs ): return ( Developers(gen_auth(username, password, mfa_secret, token, zonename), org, name) .create_developer(first_name, last_name, user_name, attributes=attributes) .text )
def download_apps_snapshot(self, expand=False, count=1000, startkey=""): self.snapshot_data.apps = Apps(self.auth, self.org_name, None).list_apps_for_all_developers( Developers(self.auth, self.org_name, None).list_developers( prefix=None, expand=expand, count=count, startkey=startkey, format='dict' ), prefix=self.prefix, format='dict', ) self.snapshot_data.apps = {k: v for k, v in self.snapshot_data.apps.items() if v} for app, details in self.snapshot_data.apps.items(): data = { 'snapshot': details, 'target_path': self._gen_snapshot_path(subpaths=['apps', f'{app}.json']), 'fs_write': self.fs_write, 'indent': 2, } write_file( data['snapshot'], data['target_path'], fs_write=data['fs_write'], indent=data['indent'], ) return self.snapshot_data.apps