def delete_password(params): """Delete a password""" ident = params['name'] if ident not in load_passwords(): return problem( 404, f'Password "{ident}" is not known.', 'The password you asked for is not known. Please check for eventual misspellings.') remove_password(ident) return Response(status=204)
def show_password(params): """Show a password""" ident = params['name'] passwords = load_passwords() if ident not in passwords: return problem( 404, f'Password "{ident}" is not known.', 'The password you asked for is not known. Please check for eventual misspellings.') password_details = passwords[ident] return _serve_password(ident, password_details)
def delete_password(params): """Delete a password""" ident = params["name"] if ident not in load_passwords(): return problem( status=404, title='Password "{ident}" is not known.', detail="The password you asked for is not known. Please check for eventual misspellings.", ) remove_password(ident) return Response(status=204)
def show_password(params): """Show a password""" ident = params["name"] passwords = load_passwords() if ident not in passwords: return problem( status=404, title=f'Password "{ident}" is not known.', detail="The password you asked for is not known. Please check for eventual misspellings.", ) password_details = passwords[ident] return _serve_password(ident, password_details)
def list_passwords(params): """Show all passwords""" password_collection = { 'id': 'password', 'domainType': 'password', 'value': [ constructors.collection_item(domain_type='password', obj={ 'title': details['title'], 'id': password_id, }) for password_id, details in load_passwords().items() ], 'links': [constructors.link_rel('self', constructors.collection_href('password'))], } return constructors.serve_json(password_collection)
def list_passwords(params): """Show all passwords""" password_collection = { "id": "password", "domainType": "password", "value": [ constructors.collection_item( domain_type="password", title=details["title"], identifier=password_id, ) for password_id, details in load_passwords().items() ], "links": [constructors.link_rel("self", constructors.collection_href("password"))], } return constructors.serve_json(password_collection)