Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where RequestToken = '54061545-e0a0-4ef0-b213-41fda81d8c24'
and region = 'ap-southeast-2';
```

(replace `region` and `data__RequestToken` accordingly)
(replace `region` and `RequestToken` accordingly)

### Resolving Identifiers

Expand Down
52 changes: 48 additions & 4 deletions bin/generate-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,45 @@ function generateResourceLinks(serviceName, resources) {
return resourceLinks.join('<br />\n');
}

function getReturningClause() {
const progressEventFields = [
'ErrorCode',
'EventTime',
'Identifier',
'Operation',
'OperationStatus',
'RequestToken',
'ResourceModel',
'RetryAfter',
'StatusMessage',
'TypeName',
];
return `RETURNING\n ${progressEventFields.join(",\n ")}\n`;
}

function createAdditionalParametersSection(serviceName, resourceData) {
if (nativeServices.includes(serviceName)) {
return '';
}
const hasInsert = !!resourceData.methods?.create_resource;
const hasUpdate = !!resourceData.methods?.update_resource;
const hasDelete = !!resourceData.methods?.delete_resource;
if (!hasInsert && !hasUpdate && !hasDelete) {
return '';
}
return `
## Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with \`INSERT\`, \`UPDATE\`, or \`DELETE\` operations. These include:

| Parameter | Description |
|-----------|-------------|
| <CopyableCode code="ClientToken" /> | <details><summary>A unique identifier to ensure the idempotency of the resource request.</summary>This allows the provider to accurately distinguish between retries and new requests.<br />A client token is valid for 36 hours once used.<br />After that, a resource request with the same client token is treated as a new request.<br />If you do not specify a client token, one is generated for inclusion in the request.</details> |
| <CopyableCode code="RoleArn" /> | <details><summary>The ARN of the IAM role used to perform this resource operation.</summary>The role specified must have the permissions required for this operation.<br />If you do not specify a role, a temporary session is created using your AWS user credentials.</details> |
| <CopyableCode code="TypeVersionId" /> | <details><summary>For private resource types, the type version to use in this resource operation.</summary>If you do not specify a resource version, the default version is used.</details> |
`;
}

function createDeleteExample(serviceName, resourceName, resourceData, thisSchema, allSchemas) {
const deleteOperation = resourceData.methods?.delete_resource;
if (!deleteOperation) {
Expand All @@ -218,7 +257,8 @@ ${sqlCodeBlockStart}
DELETE FROM ${providerName}.${serviceName}.${resourceName}
WHERE
Identifier = '${resourceData['x-identifiers'].map(id => `{{ ${toSnakeCase(fixCamelCaseIssues(id))} }}`).join('|')}' AND
region = '${getRegionExample(serviceName)}';
region = '${getRegionExample(serviceName)}'
${getReturningClause()};
${codeBlockEnd}
`;
}
Expand Down Expand Up @@ -254,7 +294,8 @@ ${patchFields}
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '${identifierValues}';
Identifier = '${identifierValues}'
${getReturningClause()};
${codeBlockEnd}
`;
}
Expand Down Expand Up @@ -417,7 +458,8 @@ INSERT INTO ${providerName}.${serviceName}.${resourceName} (
)
SELECT
'{{ ${requiredSnakeKeys.join(" }}',\n '{{ ")} }}',
'{{ region }}';
'{{ region }}'
${getReturningClause()};
${codeBlockEnd}
</TabItem>
<TabItem value="all">
Expand All @@ -430,7 +472,8 @@ INSERT INTO ${providerName}.${serviceName}.${resourceName} (
)
SELECT
'{{ ${allSnakeKeys.join(" }}',\n '{{ ")} }}',
'{{ region }}';
'{{ region }}'
${getReturningClause()};
${codeBlockEnd}
</TabItem>
<TabItem value="manifest">
Expand Down Expand Up @@ -966,6 +1009,7 @@ ${resourceType !== 'native' ? generateSelectExamples(resourceName, hasList, hasG
${resourceType !== 'native' ? createInsertExample(serviceName, resourceName, resourceData, schema, componentsSchemas): ''}
${resourceType !== 'native' ? createUpdateExample(serviceName, resourceName, resourceData, schema, componentsSchemas): ''}
${resourceType !== 'native' ? createDeleteExample(serviceName, resourceName, resourceData, schema, componentsSchemas): ''}
${resourceType !== 'native' ? createAdditionalParametersSection(serviceName, resourceData): ''}
${permissionsHeadingMarkdown}
${permissionsBylineMarkdown}
${permissionsMarkdown}`;
Expand Down
11 changes: 5 additions & 6 deletions bin/generate-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async function processService(servicePrefix, outputFilename) {
};

const files = findFiles(docsDir, servicePrefix);
let serviceTitle;
const serviceTitle = path.basename(outputFilename, '.yaml');
for (const file of files) {
const content = await fs.promises.readFile(file);
const jsonContent = JSON.parse(content);
Expand All @@ -208,16 +208,14 @@ async function processService(servicePrefix, outputFilename) {
}

const componentName = jsonContent.typeName.split("::").pop();
if (!serviceTitle) {
serviceTitle = jsonContent.typeName?.split("::")[1];
}
const openAPIComponent = convertToOpenAPI(
jsonContent,
componentName,
openAPI.components.schemas
);
Object.assign(openAPI.components.schemas, openAPIComponent);
}

openAPI.info = {title: serviceTitle, ...openAPI.info};

const stackqlViews = generateStackqlViews(openAPI);
Expand All @@ -239,7 +237,7 @@ async function processService(servicePrefix, outputFilename) {

const cleanedOpenAPI = cleanOpenAPISpec(openAPI);

if(serviceTitle == 'EC2'){
if(serviceTitle == 'ec2'){
// fix bug with self referencing object
delete cleanedOpenAPI.components.schemas.SseSpecification.$ref;
cleanedOpenAPI.components.schemas.SseSpecification['type'] = 'object';
Expand Down Expand Up @@ -408,7 +406,8 @@ async function main(){
};
console.log('Service processed', service);
} catch (error) {
console.log('Error processing file', service, error)
console.error(`Error processing file ${service}:`, error);
process.exit(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/addtl_routes/CloudWatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ components:
log_events:
name: log_events
x-cfn-schema-name: OutputLogEvent
x-example-where-clause: "WHERE region = 'us-east-1' AND data___logStreamName = '<logStreamName>'"
x-example-where-clause: "WHERE region = 'us-east-1' AND logStreamName = '<logStreamName>'"
x-type: native
id: aws.cloudwatch.log_events
methods:
Expand Down
Loading
Loading