Skip to content

Commit

Permalink
Merge pull request #126 from SNIA/fix-editorial
Browse files Browse the repository at this point in the history
Editorial fixes; roll back changes removed by autogen PR
  • Loading branch information
rahlvers authored Apr 5, 2024
2 parents 35d2778 + ac7381b commit 421f11e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
24 changes: 14 additions & 10 deletions api_emulator/redfish/MessageRegistryFile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,23 @@
# Program name - MessageRegistryFile_api.py

import g
import json, os
import json
import os
import traceback
import logging, random, requests, string, jwt
import logging

from flask import Flask, request, session
from flask import Flask, request
from flask_restful import Resource
from .constants import *
from api_emulator.utils import check_authentication, create_path, get_json_data, create_and_patch_object, delete_object, patch_object, put_object, delete_collection, create_collection
from api_emulator.utils import check_authentication, update_collections_json, create_path, get_json_data, create_and_patch_object, delete_object, patch_object, put_object, delete_collection, create_collection

config = {}

members = []
member_ids = []
INTERNAL_ERROR = 500

# MessageRegistryFile Collection API


class MessageRegistryFileCollectionAPI(Resource):
def __init__(self, **kwargs):
logging.info('MessageRegistryFile Collection init called')
Expand Down Expand Up @@ -98,8 +99,13 @@ def get(self, MessageRegistryFileId):
msg, code = check_authentication(self.auth)

if code == 200:
path = create_path(self.root, 'Registries/{0}', 'index.json').format(MessageRegistryFileId)
return get_json_data (path)
if '.json' not in MessageRegistryFileId:
path = create_path(
self.root, 'Registries/{0}', 'index.json').format(MessageRegistryFileId)
else:
path = create_path(
self.root, 'Registries/{0}').format(MessageRegistryFileId)
return get_json_data(path)
else:
return msg, code

Expand All @@ -122,5 +128,3 @@ def patch(self, MessageRegistryFileId):
def delete(self, MessageRegistryFileId):
logging.info('MessageRegistryFile delete called')
return 'DELETE is not a supported command for MessageRegistryFileAPI', 405


5 changes: 3 additions & 2 deletions api_emulator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ def remove_json_object (config, property_id):
# Iterate through the objects in the JSON and pop (remove)
# the obj once we find it.

if property_id in config:
config.pop (property_id, None)
if isinstance(config, dict):
if property_id in config:
config.pop(property_id, None)
return config

def check_session_authentication():
Expand Down
6 changes: 5 additions & 1 deletion emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def output_json(data, code, headers=None):
global location

if 'UserName' not in data or 'Password' not in data:
resp = make_response(json.dumps(data, indent=4), code)
if code == 405:
# No data should be returned in the body - only return the code.
resp = make_response('', code)
if code != 405:
resp = make_response(json.dumps(data, indent=4), code)
resp.headers.extend(headers or {})

#if session timed out then delete the cookie as well
Expand Down

0 comments on commit 421f11e

Please sign in to comment.