Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a Ballerina connector for AWS Marketplace Metering service #6865

Closed
2 tasks done
ayeshLK opened this issue Aug 13, 2024 · 2 comments
Closed
2 tasks done

Introduce a Ballerina connector for AWS Marketplace Metering service #6865

ayeshLK opened this issue Aug 13, 2024 · 2 comments

Comments

@ayeshLK
Copy link
Member

ayeshLK commented Aug 13, 2024

Description:

$subject

Following APIs should be supported:

  • Resolve customer [1]
  • Batch meter usage [2]

Related to: #740

[1] - https://docs.aws.amazon.com/marketplacemetering/latest/APIReference/API_ResolveCustomer.html
[2] - https://docs.aws.amazon.com/marketplacemetering/latest/APIReference/API_BatchMeterUsage.html

@ayeshLK
Copy link
Member Author

ayeshLK commented Aug 14, 2024

Initial design for the AWS Marketplace Metering 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 resolveCustomer(string registrationToken) returns ResolveCustomerResponse|Error;

    remote function batchMeterUsage(*BatchMeterUsageRequest request) returns BatchMeterUsageResponse|Error;
};

3. Types related resolve-customer API

public type ResolveCustomerResponse record {|
    string customerAWSAccountId;
    string customerIdentifier;
    string productCode;
|};

4. Types related to batch-meter-usage API

public type BatchMeterUsageRequest record {|
    @constraint:String {
        pattern: re `^[-a-zA-Z0-9/=:_.@]{1,255}$`
    }
    string productCode;
    @constraint:Array {
        maxLength: 25
    }
    UsageRecord[] usageRecords = [];
|};

public type UsageRecord record {|
    @constraint:String {
        pattern: re `[\s\S]{1,255}$`
    }
    string customerIdentifier;
    @constraint:String {
        pattern: re `[\s\S]{1,255}$`
    }
    string dimension;
    time:Utc timestamp;
    @constraint:Int {
        minValue: 0,
        maxValue: 2147483647
    }
    int quantity?;
    @constraint:Array {
        minLength: 1,
        maxLength: 2500
    }
    UsageAllocation[] usageAllocations?;
|};

public type UsageAllocation record {|
    @constraint:Int {
        minValue: 0,
        maxValue: 2147483647
    }
    int allocatedUsageQuantity;
    @constraint:Array {
        minLength: 1,
        maxLength: 5
    }
    Tag[] tags;
|};

public type Tag record {|
    string 'key;
    string value;
|};

public type BatchMeterUsageResponse record {|
    UsageRecordResult[] results;
    UsageRecord[] unprocessedRecords;
|};

public type UsageRecordResult record {|
    string meteringRecordId?;
    UsageRecordStatus status?;
    UsageRecord usageRecord?;
|};

public enum UsageRecordStatus {
    SUCCESS = "Success",
    CUSTOMER_NOT_SUBSCRIBED = "CustomerNotSubscribed",
    DUPLICATE_RECORD = "DuplicateRecord"
}

5. Errors

public type Error distinct error;

@ayeshLK
Copy link
Member Author

ayeshLK commented Aug 21, 2024

@ayeshLK ayeshLK closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant