ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Introduce a Ballerina connector for AWS Marketplace Entitlement service #6864

Closed ayeshLK closed 2 months ago

ayeshLK commented 3 months ago

Description:

$subject

Following APIs should be supported:

Related to: #740

[1] - https://docs.aws.amazon.com/marketplaceentitlement/latest/APIReference/API_GetEntitlements.html

ayeshLK commented 3 months ago

Initial design for the AWS Marketplace Entitlement connector

1. Configurations

ConnectionConfig

public type ConnectionConfig record {|
    Region region;
    AuthConfig auth;
|};

Region

public enum Region {
    US_EAST_1 = "us-east-1"
    // other regions
}

AuthConfig

public type AuthConfig record {|
    string accessKeyId;
    string secretAccessKey;
    string sessionToken?;
|};

2. Client API

public type Client distinct client object {

    remote function getEntitlements(*EntitlementRequest request) returns EntitlementResponse|Error;
};

3. Request types

public type EntitlementsRequest record {|
    @constraint:String {
        minLength: 1,
        maxLength: 255
    }
    string productCode;
    EntitlementFilter filter?;
    int maxResults?;
    @constraint:String {
        pattern: re `\S+`
    }
    string nextToken?;
|};

public type EntitlementFilter record {|
    @constraint:Array {
        minLength: 1
    }
    string[] customerIdentifier?;
    @constraint:Array {
        minLength: 1
    }
    string[] dimension?;
|};

4. Response types

public type EntitlementsResponse record {|
    Entitlement[] entitlements;
    string nextToken?;
|};

public type Entitlement record {|
    string customerIdentifier?;
    string dimension?;
    time:Utc expirationDate?;
    string productCode?;
    boolean|decimal|int|string value?;
|};

5. Errors

public type Error distinct error;
ayeshLK commented 2 months ago

As the AWS SDK provides more information for the error, updated the error definition for the Ballerina AWS MPE connector.

public type Error error<ErrorDetails>;

public type ErrorDetails record {|
    int httpStatusCode?;
    string httpStatusText?;
    string errorCode?;
    string errorMessage?;
|};

Note: If the error is a connection error, the above ErrorDetails could not be extracted from the underlying exception, hence marked the fields in the ErrorDetails record as optional.