Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from Open-MBEE/openapi
Browse files Browse the repository at this point in the history
openapi generated client
  • Loading branch information
ewbrower committed Mar 17, 2020
2 parents d24ebaa + 947b039 commit 7bbe0d8
Show file tree
Hide file tree
Showing 44 changed files with 2,351 additions and 441 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Created by https://www.gitignore.io/api/matlab

### Matlab ###
##---------------------------------------------------
## Remove autosaves generated by the Matlab editor
## We have git for backups!
##---------------------------------------------------

# Windows default autosave extension
*.asv

# OSX / *nix default autosave extension
*.m~

# Compiled MEX binaries (all platforms)
*.mex*

# Simulink Code Generation
slprj/

# Session info
octave-workspace

# Simulink autosave extension
*.autosave


# End of https://www.gitignore.io/api/matlab


# Created by https://www.gitignore.io/api/macos

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


# End of https://www.gitignore.io/api/macos
26 changes: 26 additions & 0 deletions Adapter/Login.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%-----------------------------------------------------------
%Download passcode.m from Supplementary Functions package
%-----------------------------------------------------------

function Login(username,basePath)

%-----------------------------------------------------------
%Description: Log into server
%
%input Args:
% basePath(str) = https://mms.org
% username(str) = JPL username
% passcode = JPL password (type in passcode text box)
%-----------------------------------------------------------

LoginRequest();
Matlab_MMS_client.setBasePath(basePath)
out.username = username;
out.password = passcode();
%Matlab_MMS_client.setBasicAuth(out.username, out.password);
tick = TicketApi.post_ticket(out);
Matlab_MMS_client.setTicketAuth(tick.data.ticket);

clear out

end
31 changes: 31 additions & 0 deletions Adapter/UpdateDocumentation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function UpdateDocumentation(username, basePath, project, ref, id1, id2, content1, content2, desiredFields)
%------------------------------------------------------
%Description: Update documentation of a presentation
% element.
%
%input Args
%username(str): JPL username
%password(str): JPL password (enter in text box)
%basePath(str): https://mms.org
%project(str): project ID
%ref(str): ref ID
%id(str): element ID
%content(str): documentation
%desiredFields(str array): fields to update ["id"
%"documentation"]
%------------------------------------------------------

Login(username, basePath);

json1 = ElementApi.get_element(project, ref, id1);
json2 = ElementApi.get_element(project, ref, id2);

out1 = removeFields(json1, desiredFields);
out2 = removeFields(json2, desiredFields);

out1 = setfield(out1,'documentation', content1);
out2 = setfield(out2,'documentation', content2);

posted = ElementApi.post_elements(project, ref, [out1,out2]);

end
29 changes: 29 additions & 0 deletions Adapter/UpdateName.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function UpdateName(username, basePath, project, ref, id1, id2, newName1, newName2, desiredFields)

%------------------------------------------------------
%Description: Update name of an element
%
%input Args
%username(str): JPL username
%password(str): JPL password (enter in text box)
%basePath(str): mms.org
%project(str): project ID
%ref(str): ref ID
%id(str): element ID
%content(str): documentation
%desiredFields(str array): fields to update["id"
%"name"]
%------------------------------------------------------
Login(username, basePath);

json1 = ElementApi.get_element(project, ref, id1);
json2 = ElementApi.get_element(project, ref, id2);

out1 = removeFields(json1, desiredFields);
out2 = removeFields(json2, desiredFields);

out1 = setfield(out1,'name', newName1);
out2 = setfield(out2,'name', newName2);

posted = ElementApi.post_elements(project, ref, [out1,out2])
end
12 changes: 12 additions & 0 deletions Adapter/postImagefromURL.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function postImagefromURL(username, basePath, project, ref, name1, name2, picUrl1,picUrl2,desiredFields)

Login(username, basePath);

pic1 = strcat('<img src="',picUrl1,'" />');
pic2 = strcat('<img src="',picUrl2,'" />');

s = struct('id','_hidden_MMS_1529082050667_32fffb1e-e0e4-40da-9e74-2f586f711818_pei','type','InstanceSpecification','name',name1,'documentation', pic1);
t = struct('id','_hidden_MMS_1529358324856_8442b90f-4e70-4359-be1e-ff6eef6e2259_pei','type','InstanceSpecification','name',name2,'documentation', pic2);

posted = ElementApi.post_elements(project,ref,[s,t]);
end
14 changes: 14 additions & 0 deletions Adapter/removeFields.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function out = removeFields(structure, desiredFields)

fields = fieldnames(structure.elements);
out = struct();

for i = 1:length(desiredFields)
for j = 1:length(fields)
if strcmp(desiredFields(i), string(fields(j)))
out = setfield(out,desiredFields(i), structure.elements.(desiredFields(i)));
end
end
end

end
78 changes: 0 additions & 78 deletions GetAuthentication.m

This file was deleted.

75 changes: 0 additions & 75 deletions MMSDocumentRead.m

This file was deleted.

Loading

0 comments on commit 7bbe0d8

Please sign in to comment.