204{
205 if (shape.type() == smithy::Shape::Type::Service) {
206 QVariantHash hash = shape.rawAst().toVariantHash();
207 hash.insert(QSL("shapeName"), shape.id().shapeName());
208 hash.insert(QSL("canonicalId"), canonicalServiceId(shape.traits()
209 .value(QSL("aws.api#service")).toObject().value(QSL("sdkId")).toString()));
210 hash.insert(QSL("sdkId"), shape.traits().value(QSL("aws.api#service")).toObject()
211 .value(QSL("sdkId")).toString());
213 shape.traits().value(QSL("smithy.api#documentation")).toString()));
214 QVariantMap operations;
215 const smithy::Shape::ShapeReferences operationRefs = shape.operations();
216 for (const smithy::Shape::ShapeReference &operationRef: operationRefs) {
217 operations.insert(operationRef.target.shapeName(),
218 toContext(model->shape(operationRef.target)));
219 }
220 Q_ASSERT(operationRefs.size() == operations.size());
221 const smithy::Shape::ShapeReferences resourceRefs = shape.resources();
222 for (const smithy::Shape::ShapeReference &resourceRef: resourceRefs) {
223 const QVariantHash resourceContext = toContext(model->shape(resourceRef.target));
224
225
226
227 const QVariantMap resourceOperations = resourceContext.value(QSL("operations")).toMap();
228 for (auto iter = resourceOperations.constBegin(); iter != resourceOperations.constEnd(); ++iter) {
229 operations.insert(iter.key(), iter.value());
230 }
231 }
232 hash.insert(QSL("operations"), operations);
233 return hash;
234 }
235
236 if (shape.type() == smithy::Shape::Type::Operation) {
237 QVariantHash hash = shape.rawAst().toVariantHash();
238 hash.insert(QSL("name"), shape.id().shapeName());
239 hash.insert(QSL("shapeId"), shape.id().toString());
241 shape.traits().value(QSL("smithy.api#documentation")).toString()));
242 return hash;
243 }
244
245 if (shape.type() == smithy::Shape::Type::Resource) {
246 QVariantHash hash = shape.rawAst().toVariantHash();
247 QVariantMap operations;
248 #define QTSMITHY_IF_VALID_INSERT(action) { \
249 const smithy::ShapeId action##TargetId = shape.action().target; \
250 if (action##TargetId.isValid()) { \
251 operations.insert(action##TargetId.shapeName(), \
252 toContext(model->shape(action##TargetId))); \
253 } \
254 }
255 QTSMITHY_IF_VALID_INSERT(create)
256 QTSMITHY_IF_VALID_INSERT(put)
257 QTSMITHY_IF_VALID_INSERT(read)
258 QTSMITHY_IF_VALID_INSERT(update)
259 QTSMITHY_IF_VALID_INSERT(Delete)
260 QTSMITHY_IF_VALID_INSERT(list)
261 #undef QTSMITHY_IF_VALID_INSERT
262
263 #define QTSMITHY_ADD_SHAPES(property) { \
264 const smithy::Shape::ShapeReferences refs = shape.property(); \
265 for (const smithy::Shape::ShapeReference &ref: refs) { \
266 operations.insert(ref.target.shapeName(), toContext(model->shape(ref.target))); \
267 } \
268 }
269 QTSMITHY_ADD_SHAPES(operations)
270 QTSMITHY_ADD_SHAPES(collectionOperations)
271 #undef QTSMITHY_ADD_SHAPES
272
273 const smithy::Shape::ShapeReferences resourceRefs = shape.resources();
274 for (const smithy::Shape::ShapeReference &resourceRef: resourceRefs) {
275 const QVariantHash resourceContext = toContext(model->shape(resourceRef.target));
276
277
278
279 const QVariantMap resourceOperations = resourceContext.value(QSL("operations")).toMap();
280 for (auto iter = resourceOperations.constBegin(); iter != resourceOperations.constEnd(); ++iter) {
281 operations.insert(iter.key(), iter.value());
282 }
283 }
284
285 hash.insert(QSL("operations"), operations);
286 return hash;
287 }
288
289 qCCritical(lc).noquote() << tr("Cannot generate context for shape type 0x%1")
290 .arg((int)shape.type(), 0, 16);
291 return QVariantHash{};
292}
static QStringList formatHtmlDocumentation(const QString &html)