Skip to content

Commit

Permalink
feat(client-b2bi): This release adds a GenerateMapping API to allow g…
Browse files Browse the repository at this point in the history
…eneration of JSONata or XSLT transformer code based on input and output samples.
  • Loading branch information
awstools committed Nov 13, 2024
1 parent b46415d commit 79297bb
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 2 deletions.
8 changes: 8 additions & 0 deletions clients/client-b2bi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ DeleteTransformer

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/b2bi/command/DeleteTransformerCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/DeleteTransformerCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/DeleteTransformerCommandOutput/)

</details>
<details>
<summary>
GenerateMapping
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/b2bi/command/GenerateMappingCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/GenerateMappingCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/GenerateMappingCommandOutput/)

</details>
<details>
<summary>
Expand Down
20 changes: 20 additions & 0 deletions clients/client-b2bi/src/B2bi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ import {
DeleteTransformerCommandInput,
DeleteTransformerCommandOutput,
} from "./commands/DeleteTransformerCommand";
import {
GenerateMappingCommand,
GenerateMappingCommandInput,
GenerateMappingCommandOutput,
} from "./commands/GenerateMappingCommand";
import {
GetCapabilityCommand,
GetCapabilityCommandInput,
Expand Down Expand Up @@ -143,6 +148,7 @@ const commands = {
DeletePartnershipCommand,
DeleteProfileCommand,
DeleteTransformerCommand,
GenerateMappingCommand,
GetCapabilityCommand,
GetPartnershipCommand,
GetProfileCommand,
Expand Down Expand Up @@ -307,6 +313,20 @@ export interface B2bi {
cb: (err: any, data?: DeleteTransformerCommandOutput) => void
): void;

/**
* @see {@link GenerateMappingCommand}
*/
generateMapping(
args: GenerateMappingCommandInput,
options?: __HttpHandlerOptions
): Promise<GenerateMappingCommandOutput>;
generateMapping(args: GenerateMappingCommandInput, cb: (err: any, data?: GenerateMappingCommandOutput) => void): void;
generateMapping(
args: GenerateMappingCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GenerateMappingCommandOutput) => void
): void;

/**
* @see {@link GetCapabilityCommand}
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-b2bi/src/B2biClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { DeleteCapabilityCommandInput, DeleteCapabilityCommandOutput } from "./c
import { DeletePartnershipCommandInput, DeletePartnershipCommandOutput } from "./commands/DeletePartnershipCommand";
import { DeleteProfileCommandInput, DeleteProfileCommandOutput } from "./commands/DeleteProfileCommand";
import { DeleteTransformerCommandInput, DeleteTransformerCommandOutput } from "./commands/DeleteTransformerCommand";
import { GenerateMappingCommandInput, GenerateMappingCommandOutput } from "./commands/GenerateMappingCommand";
import { GetCapabilityCommandInput, GetCapabilityCommandOutput } from "./commands/GetCapabilityCommand";
import { GetPartnershipCommandInput, GetPartnershipCommandOutput } from "./commands/GetPartnershipCommand";
import { GetProfileCommandInput, GetProfileCommandOutput } from "./commands/GetProfileCommand";
Expand Down Expand Up @@ -115,6 +116,7 @@ export type ServiceInputTypes =
| DeletePartnershipCommandInput
| DeleteProfileCommandInput
| DeleteTransformerCommandInput
| GenerateMappingCommandInput
| GetCapabilityCommandInput
| GetPartnershipCommandInput
| GetProfileCommandInput
Expand Down Expand Up @@ -149,6 +151,7 @@ export type ServiceOutputTypes =
| DeletePartnershipCommandOutput
| DeleteProfileCommandOutput
| DeleteTransformerCommandOutput
| GenerateMappingCommandOutput
| GetCapabilityCommandOutput
| GetPartnershipCommandOutput
| GetProfileCommandOutput
Expand Down
130 changes: 130 additions & 0 deletions clients/client-b2bi/src/commands/GenerateMappingCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { B2biClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../B2biClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { GenerateMappingRequest, GenerateMappingResponse } from "../models/models_0";
import { de_GenerateMappingCommand, se_GenerateMappingCommand } from "../protocols/Aws_json1_0";

/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link GenerateMappingCommand}.
*/
export interface GenerateMappingCommandInput extends GenerateMappingRequest {}
/**
* @public
*
* The output of {@link GenerateMappingCommand}.
*/
export interface GenerateMappingCommandOutput extends GenerateMappingResponse, __MetadataBearer {}

/**
* <p>Takes sample input and output documents and uses Amazon Bedrock to generate a mapping automatically. Depending on the accuracy and other factors, you can then edit the mapping for your needs.</p>
* <note>
* <p>Before you can use the AI-assisted feature for Amazon Web Services B2B Data Interchange you must enable models in Amazon Bedrock. For details, see <a href="https://docs.aws.amazon.com/b2bi/latest/userguide/ai-assisted-mapping.html#ai-assist-prereq">AI-assisted template mapping prerequisites</a> in
* the <i>Amazon Web Services B2B Data Interchange User guide</i>.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { B2biClient, GenerateMappingCommand } from "@aws-sdk/client-b2bi"; // ES Modules import
* // const { B2biClient, GenerateMappingCommand } = require("@aws-sdk/client-b2bi"); // CommonJS import
* const client = new B2biClient(config);
* const input = { // GenerateMappingRequest
* inputFileContent: "STRING_VALUE", // required
* outputFileContent: "STRING_VALUE", // required
* mappingType: "JSONATA" || "XSLT", // required
* };
* const command = new GenerateMappingCommand(input);
* const response = await client.send(command);
* // { // GenerateMappingResponse
* // mappingTemplate: "STRING_VALUE", // required
* // mappingAccuracy: Number("float"),
* // };
*
* ```
*
* @param GenerateMappingCommandInput - {@link GenerateMappingCommandInput}
* @returns {@link GenerateMappingCommandOutput}
* @see {@link GenerateMappingCommandInput} for command's `input` shape.
* @see {@link GenerateMappingCommandOutput} for command's `response` shape.
* @see {@link B2biClientResolvedConfig | config} for B2biClient's `config` shape.
*
* @throws {@link AccessDeniedException} (client fault)
* <p>You do not have sufficient access to perform this action.</p>
*
* @throws {@link InternalServerException} (server fault)
* <p>This exception is thrown when an error occurs in the Amazon Web Services B2B Data Interchange service.</p>
*
* @throws {@link ThrottlingException} (client fault)
* <p>The request was denied due to throttling: the data speed and rendering may be limited depending on various parameters and conditions.</p>
*
* @throws {@link ValidationException} (client fault)
* <p>Occurs when a B2BI object cannot be validated against a request from another object.</p>
*
* @throws {@link B2biServiceException}
* <p>Base exception class for all service exceptions from B2bi service.</p>
*
* @public
* @example Sample GenerateMapping call
* ```javascript
* //
* const input = {
* "inputFileContent": "Sample input file content",
* "mappingType": "JSONATA",
* "outputFileContent": "Sample output file content"
* };
* const command = new GenerateMappingCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "mappingAccuracy": 0.95,
* "mappingTemplate": "Sample mapping content"
* }
* *\/
* // example id: example-1
* ```
*
*/
export class GenerateMappingCommand extends $Command
.classBuilder<
GenerateMappingCommandInput,
GenerateMappingCommandOutput,
B2biClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: B2biClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("B2BI", "GenerateMapping", {})
.n("B2biClient", "GenerateMappingCommand")
.f(void 0, void 0)
.ser(se_GenerateMappingCommand)
.de(de_GenerateMappingCommand)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: GenerateMappingRequest;
output: GenerateMappingResponse;
};
sdk: {
input: GenerateMappingCommandInput;
output: GenerateMappingCommandOutput;
};
};
}
1 change: 1 addition & 0 deletions clients/client-b2bi/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from "./DeleteCapabilityCommand";
export * from "./DeletePartnershipCommand";
export * from "./DeleteProfileCommand";
export * from "./DeleteTransformerCommand";
export * from "./GenerateMappingCommand";
export * from "./GetCapabilityCommand";
export * from "./GetPartnershipCommand";
export * from "./GetProfileCommand";
Expand Down
43 changes: 42 additions & 1 deletion clients/client-b2bi/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,47 @@ export interface CreateStarterMappingTemplateResponse {
mappingTemplate: string | undefined;
}

/**
* @public
*/
export interface GenerateMappingRequest {
/**
* <p>Provide the contents of a sample X12 EDI file (for inbound EDI) or JSON/XML file (for outbound EDI) to use as a starting point for the mapping.</p>
* @public
*/
inputFileContent: string | undefined;

/**
* <p>Provide the contents of a sample X12 EDI file (for outbound EDI) or JSON/XML file (for inbound EDI) to use as a target for the mapping.</p>
* @public
*/
outputFileContent: string | undefined;

/**
* <p>Specify the mapping type: either <code>JSONATA</code> or <code>XSLT.</code>
* </p>
* @public
*/
mappingType: MappingType | undefined;
}

/**
* @public
*/
export interface GenerateMappingResponse {
/**
* <p>Returns a mapping template based on your inputs.</p>
* @public
*/
mappingTemplate: string | undefined;

/**
* <p>Returns a percentage that estimates the accuracy of the generated mapping.</p>
* @public
*/
mappingAccuracy?: number | undefined;
}

/**
* @public
*/
Expand Down Expand Up @@ -3006,7 +3047,7 @@ export interface UpdateTransformerRequest {
name?: string | undefined;

/**
* <p>Specifies the transformer's status. You can update the state of the transformer, from <code>active</code> to <code>inactive</code>, or <code>inactive</code> to <code>active</code>.</p>
* <p>Specifies the transformer's status. You can update the state of the transformer from <code>inactive</code> to <code>active</code>.</p>
* @public
*/
status?: TransformerStatus | undefined;
Expand Down
49 changes: 49 additions & 0 deletions clients/client-b2bi/src/protocols/Aws_json1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
decorateServiceException as __decorateServiceException,
expectNonNull as __expectNonNull,
expectString as __expectString,
limitedParseFloat32 as __limitedParseFloat32,
parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset,
take,
withBaseException,
Expand All @@ -36,6 +37,7 @@ import { DeleteCapabilityCommandInput, DeleteCapabilityCommandOutput } from "../
import { DeletePartnershipCommandInput, DeletePartnershipCommandOutput } from "../commands/DeletePartnershipCommand";
import { DeleteProfileCommandInput, DeleteProfileCommandOutput } from "../commands/DeleteProfileCommand";
import { DeleteTransformerCommandInput, DeleteTransformerCommandOutput } from "../commands/DeleteTransformerCommand";
import { GenerateMappingCommandInput, GenerateMappingCommandOutput } from "../commands/GenerateMappingCommand";
import { GetCapabilityCommandInput, GetCapabilityCommandOutput } from "../commands/GetCapabilityCommand";
import { GetPartnershipCommandInput, GetPartnershipCommandOutput } from "../commands/GetPartnershipCommand";
import { GetProfileCommandInput, GetProfileCommandOutput } from "../commands/GetProfileCommand";
Expand Down Expand Up @@ -88,6 +90,8 @@ import {
EdiConfiguration,
EdiType,
FormatOptions,
GenerateMappingRequest,
GenerateMappingResponse,
GetCapabilityRequest,
GetCapabilityResponse,
GetPartnershipRequest,
Expand Down Expand Up @@ -264,6 +268,19 @@ export const se_DeleteTransformerCommand = async (
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

/**
* serializeAws_json1_0GenerateMappingCommand
*/
export const se_GenerateMappingCommand = async (
input: GenerateMappingCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: __HeaderBag = sharedHeaders("GenerateMapping");
let body: any;
body = JSON.stringify(_json(input));
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

/**
* serializeAws_json1_0GetCapabilityCommand
*/
Expand Down Expand Up @@ -692,6 +709,26 @@ export const de_DeleteTransformerCommand = async (
return response;
};

/**
* deserializeAws_json1_0GenerateMappingCommand
*/
export const de_GenerateMappingCommand = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<GenerateMappingCommandOutput> => {
if (output.statusCode >= 300) {
return de_CommandError(output, context);
}
const data: any = await parseBody(output.body, context);
let contents: any = {};
contents = de_GenerateMappingResponse(data, context);
const response: GenerateMappingCommandOutput = {
$metadata: deserializeMetadata(output),
...contents,
};
return response;
};

/**
* deserializeAws_json1_0GetCapabilityCommand
*/
Expand Down Expand Up @@ -1320,6 +1357,8 @@ const se_CreateTransformerRequest = (input: CreateTransformerRequest, context: _

// se_FormatOptions omitted.

// se_GenerateMappingRequest omitted.

// se_GetCapabilityRequest omitted.

// se_GetPartnershipRequest omitted.
Expand Down Expand Up @@ -1526,6 +1565,16 @@ const de_CreateTransformerResponse = (output: any, context: __SerdeContext): Cre

// de_FormatOptions omitted.

/**
* deserializeAws_json1_0GenerateMappingResponse
*/
const de_GenerateMappingResponse = (output: any, context: __SerdeContext): GenerateMappingResponse => {
return take(output, {
mappingAccuracy: __limitedParseFloat32,
mappingTemplate: __expectString,
}) as any;
};

/**
* deserializeAws_json1_0GetCapabilityResponse
*/
Expand Down
Loading

0 comments on commit 79297bb

Please sign in to comment.