dpn-admin / dpn-server

Implementation of the DPN RESTful API.
Other
3 stars 6 forks source link

Added FixityAlg record but it doesn't appear in API response to /node/sdr #140

Closed dazza-codes closed 7 years ago

dazza-codes commented 7 years ago
[dpn@dpn-dev current]$ RAILS_ENV=production bundle exec rails c
Loading production environment (Rails 4.2.7.1)
2.3.0 :002 > FixityAlg.find_by_name('md5')
 => #<FixityAlg id: 4, name: "md5", created_at: "2016-11-09 18:49:10", updated_at: "2016-11-09 18:54:08"> 
[dpn@dpn-dev current]$ curl -H "Content-Type: application/json" \
>   -H "Authorization: Token token=${SDR_TOKEN}" \
>   -L https://dpn-dev.stanford.edu/api-v2/node/sdr
{"name":"Stanford Digital Repository",
 "namespace":"sdr",
 "api_root":"https://dpn-dev.stanford.edu/",
 "ssh_pubkey":"",
 "created_at":"2016-07-11T18:54:27Z",
 "updated_at":"2016-11-09T00:21:16Z",
 "replicate_from":["hathi","chron","tdr"],
 "replicate_to":["chron","tdr","hathi"],
 "restore_from":["chron","tdr","hathi"],
 "restore_to":["tdr","chron","hathi"],
 "protocols":["rsync"],
 "fixity_algorithms":["sha256"],
 "storage":{"region":"default","type":"default"}
}
dazza-codes commented 7 years ago

A change may need to be made to the SupportedFixityAlg, i.e.

sdr = Node.find_by_namespace('sdr')
# => #<Node id: 2, namespace: "sdr", ... >
md5 = FixityAlg.find_by_name("md5")
# => #<FixityAlg id: 4, name: "md5", ... >
alg = SupportedFixityAlg.new
# => #<SupportedFixityAlg id: nil, node_id: nil, fixity_alg_id: nil>
alg.node = sdr
alg.fixity_alg = md5
alg.save
# => true 
dazza-codes commented 7 years ago

That has fixed the API response, i.e.

# Stanford
{"name":"Stanford Digital Repository",
 "namespace":"sdr",
  ... snipped ...
 "fixity_algorithms":["md5","sha256"],
 "storage":{"region":"default","type":"default"}
}