From 65280abb44a1e3ab78c53e6d27c42d5c645861dd Mon Sep 17 00:00:00 2001 From: AWS SDK for Go v2 automation user Date: Fri, 12 Jan 2024 19:38:40 +0000 Subject: [PATCH] Regenerated Clients --- .../07b21d5afb4f4cda9b54f304aa3a0251.json | 8 + .../37ffa09d752e4667b0486bd208f104ef.json | 8 + .../41575353444b40ffbf474f4155544f00.json | 8 + .../5b5d8731d99d4f87b0312373025215a2.json | 8 + .../7526854dc85d45c98aadb5406afb6bbe.json | 8 + .../9383c100dbf34ce8931168d1c5e7e27c.json | 8 + .../b6029001ef98481e8a089c8f7593a1fa.json | 8 + .../c464520d3bc34515b45aea9a22f196ec.json | 8 + .../connect/api_op_GetCurrentMetricData.go | 12 +- service/connect/api_op_GetMetricData.go | 8 +- service/connect/api_op_GetMetricDataV2.go | 78 +- service/connect/api_op_MonitorContact.go | 1 + service/connect/types/enums.go | 12 +- service/connect/types/types.go | 6 +- service/connectparticipant/deserializers.go | 3 + service/connectparticipant/endpoints.go | 4 +- service/connectparticipant/types/enums.go | 12 +- .../internal/endpoints/endpoints.go | 21 + service/location/api_op_GetMapGlyphs.go | 3 +- service/location/api_op_GetPlace.go | 24 +- service/location/types/types.go | 90 +- service/mwaa/api_op_CreateWebLoginToken.go | 8 + service/mwaa/deserializers.go | 18 + service/s3control/endpoints.go | 288 +++++- service/s3control/endpoints_test.go | 496 ++++++--- service/supplychain/LICENSE.txt | 202 ++++ service/supplychain/api_client.go | 491 +++++++++ service/supplychain/api_client_test.go | 127 +++ .../api_op_CreateBillOfMaterialsImportJob.go | 189 ++++ .../api_op_GetBillOfMaterialsImportJob.go | 146 +++ service/supplychain/auth.go | 284 ++++++ service/supplychain/deserializers.go | 961 ++++++++++++++++++ service/supplychain/doc.go | 15 + service/supplychain/endpoints.go | 509 ++++++++++ service/supplychain/endpoints_config_test.go | 139 +++ service/supplychain/endpoints_test.go | 856 ++++++++++++++++ service/supplychain/generated.json | 34 + service/supplychain/go.mod | 17 + service/supplychain/go.sum | 4 + service/supplychain/go_module_metadata.go | 6 + .../internal/endpoints/endpoints.go | 296 ++++++ .../internal/endpoints/endpoints_test.go | 11 + service/supplychain/options.go | 221 ++++ service/supplychain/protocol_test.go | 3 + service/supplychain/serializers.go | 181 ++++ service/supplychain/types/enums.go | 27 + service/supplychain/types/errors.go | 190 ++++ service/supplychain/types/types.go | 39 + service/supplychain/validators.go | 94 ++ service/transfer/deserializers.go | 46 + service/transfer/types/types.go | 14 +- 51 files changed, 6023 insertions(+), 227 deletions(-) create mode 100644 .changelog/07b21d5afb4f4cda9b54f304aa3a0251.json create mode 100644 .changelog/37ffa09d752e4667b0486bd208f104ef.json create mode 100644 .changelog/41575353444b40ffbf474f4155544f00.json create mode 100644 .changelog/5b5d8731d99d4f87b0312373025215a2.json create mode 100644 .changelog/7526854dc85d45c98aadb5406afb6bbe.json create mode 100644 .changelog/9383c100dbf34ce8931168d1c5e7e27c.json create mode 100644 .changelog/b6029001ef98481e8a089c8f7593a1fa.json create mode 100644 .changelog/c464520d3bc34515b45aea9a22f196ec.json create mode 100644 service/supplychain/LICENSE.txt create mode 100644 service/supplychain/api_client.go create mode 100644 service/supplychain/api_client_test.go create mode 100644 service/supplychain/api_op_CreateBillOfMaterialsImportJob.go create mode 100644 service/supplychain/api_op_GetBillOfMaterialsImportJob.go create mode 100644 service/supplychain/auth.go create mode 100644 service/supplychain/deserializers.go create mode 100644 service/supplychain/doc.go create mode 100644 service/supplychain/endpoints.go create mode 100644 service/supplychain/endpoints_config_test.go create mode 100644 service/supplychain/endpoints_test.go create mode 100644 service/supplychain/generated.json create mode 100644 service/supplychain/go.mod create mode 100644 service/supplychain/go.sum create mode 100644 service/supplychain/go_module_metadata.go create mode 100644 service/supplychain/internal/endpoints/endpoints.go create mode 100644 service/supplychain/internal/endpoints/endpoints_test.go create mode 100644 service/supplychain/options.go create mode 100644 service/supplychain/protocol_test.go create mode 100644 service/supplychain/serializers.go create mode 100644 service/supplychain/types/enums.go create mode 100644 service/supplychain/types/errors.go create mode 100644 service/supplychain/types/types.go create mode 100644 service/supplychain/validators.go diff --git a/.changelog/07b21d5afb4f4cda9b54f304aa3a0251.json b/.changelog/07b21d5afb4f4cda9b54f304aa3a0251.json new file mode 100644 index 00000000000..aa1ca457ff8 --- /dev/null +++ b/.changelog/07b21d5afb4f4cda9b54f304aa3a0251.json @@ -0,0 +1,8 @@ +{ + "id": "07b21d5a-fb4f-4cda-9b54-f304aa3a0251", + "type": "feature", + "description": "AWS Transfer Family now supports static IP addresses for SFTP \u0026 AS2 connectors and for async MDNs on AS2 servers.", + "modules": [ + "service/transfer" + ] +} \ No newline at end of file diff --git a/.changelog/37ffa09d752e4667b0486bd208f104ef.json b/.changelog/37ffa09d752e4667b0486bd208f104ef.json new file mode 100644 index 00000000000..5508e3ed237 --- /dev/null +++ b/.changelog/37ffa09d752e4667b0486bd208f104ef.json @@ -0,0 +1,8 @@ +{ + "id": "37ffa09d-752e-4667-b048-6bd208f104ef", + "type": "feature", + "description": "Supervisor Barge for Chat is now supported through the MonitorContact API.", + "modules": [ + "service/connect" + ] +} \ No newline at end of file diff --git a/.changelog/41575353444b40ffbf474f4155544f00.json b/.changelog/41575353444b40ffbf474f4155544f00.json new file mode 100644 index 00000000000..289431df4b4 --- /dev/null +++ b/.changelog/41575353444b40ffbf474f4155544f00.json @@ -0,0 +1,8 @@ +{ + "id": "41575353-444b-40ff-bf47-4f4155544f00", + "type": "release", + "description": "New AWS service client module", + "modules": [ + "service/supplychain" + ] +} \ No newline at end of file diff --git a/.changelog/5b5d8731d99d4f87b0312373025215a2.json b/.changelog/5b5d8731d99d4f87b0312373025215a2.json new file mode 100644 index 00000000000..76c16bbbd01 --- /dev/null +++ b/.changelog/5b5d8731d99d4f87b0312373025215a2.json @@ -0,0 +1,8 @@ +{ + "id": "5b5d8731-d99d-4f87-b031-2373025215a2", + "type": "feature", + "description": "Introduce new Supervisor participant role", + "modules": [ + "service/connectparticipant" + ] +} \ No newline at end of file diff --git a/.changelog/7526854dc85d45c98aadb5406afb6bbe.json b/.changelog/7526854dc85d45c98aadb5406afb6bbe.json new file mode 100644 index 00000000000..696d16ac43d --- /dev/null +++ b/.changelog/7526854dc85d45c98aadb5406afb6bbe.json @@ -0,0 +1,8 @@ +{ + "id": "7526854d-c85d-45c9-8aad-b5406afb6bbe", + "type": "documentation", + "description": "Location SDK documentation update. Added missing fonts to the MapConfiguration data type. Updated note for the SubMunicipality property in the place data type.", + "modules": [ + "service/location" + ] +} \ No newline at end of file diff --git a/.changelog/9383c100dbf34ce8931168d1c5e7e27c.json b/.changelog/9383c100dbf34ce8931168d1c5e7e27c.json new file mode 100644 index 00000000000..1658e49167b --- /dev/null +++ b/.changelog/9383c100dbf34ce8931168d1c5e7e27c.json @@ -0,0 +1,8 @@ +{ + "id": "9383c100-dbf3-4ce8-9311-68d1c5e7e27c", + "type": "feature", + "description": "This Amazon MWAA feature release includes new fields in CreateWebLoginToken response model. The new fields IamIdentity and AirflowIdentity will let you match identifications, as the Airflow identity length is currently hashed to 64 characters.", + "modules": [ + "service/mwaa" + ] +} \ No newline at end of file diff --git a/.changelog/b6029001ef98481e8a089c8f7593a1fa.json b/.changelog/b6029001ef98481e8a089c8f7593a1fa.json new file mode 100644 index 00000000000..62157aa7c60 --- /dev/null +++ b/.changelog/b6029001ef98481e8a089c8f7593a1fa.json @@ -0,0 +1,8 @@ +{ + "id": "b6029001-ef98-481e-8a08-9c8f7593a1fa", + "type": "feature", + "description": "S3 On Outposts team adds dualstack endpoints support for S3Control and S3Outposts API calls.", + "modules": [ + "service/s3control" + ] +} \ No newline at end of file diff --git a/.changelog/c464520d3bc34515b45aea9a22f196ec.json b/.changelog/c464520d3bc34515b45aea9a22f196ec.json new file mode 100644 index 00000000000..27bae3a5976 --- /dev/null +++ b/.changelog/c464520d3bc34515b45aea9a22f196ec.json @@ -0,0 +1,8 @@ +{ + "id": "c464520d-3bc3-4515-b45a-ea9a22f196ec", + "type": "feature", + "description": "This release includes APIs CreateBillOfMaterialsImportJob and GetBillOfMaterialsImportJob.", + "modules": [ + "service/supplychain" + ] +} \ No newline at end of file diff --git a/service/connect/api_op_GetCurrentMetricData.go b/service/connect/api_op_GetCurrentMetricData.go index 21f258bc0e2..8a423a06d47 100644 --- a/service/connect/api_op_GetCurrentMetricData.go +++ b/service/connect/api_op_GetCurrentMetricData.go @@ -53,7 +53,11 @@ type GetCurrentMetricDataInput struct { // SECONDS but the Value is returned in MILLISECONDS. For example, if you get a // response like this: { "Metric": { "Name": "OLDEST_CONTACT_AGE", "Unit": // "SECONDS" }, "Value": 24113.0 } The actual OLDEST_CONTACT_AGE is 24 seconds. - // Name in real-time metrics report: Oldest (https://docs.aws.amazon.com/connect/latest/adminguide/real-time-metrics-definitions.html#oldest-real-time) + // When the filter RoutingStepExpression is used, this metric is still calculated + // from enqueue time. For example, if a contact that has been queued under for 10 + // seconds has expired and becomes active, then OLDEST_CONTACT_AGE for this queue + // will be counted starting from 10, not 0. Name in real-time metrics report: + // Oldest (https://docs.aws.amazon.com/connect/latest/adminguide/real-time-metrics-definitions.html#oldest-real-time) // SLOTS_ACTIVE Unit: COUNT Name in real-time metrics report: Active (https://docs.aws.amazon.com/connect/latest/adminguide/real-time-metrics-definitions.html#active-real-time) // SLOTS_AVAILABLE Unit: COUNT Name in real-time metrics report: Availability (https://docs.aws.amazon.com/connect/latest/adminguide/real-time-metrics-definitions.html#availability-real-time) // @@ -65,10 +69,12 @@ type GetCurrentMetricDataInput struct { // - Queues: 100 // - Routing profiles: 100 // - Channels: 3 (VOICE, CHAT, and TASK channels are supported.) + // - RoutingStepExpressions: 50 // Metric data is retrieved only for the resources associated with the queues or // routing profiles, and by any channels included in the filter. (You cannot filter // by both queue AND routing profile.) You can include both resource IDs and - // resource ARNs in the same request. Currently tagging is only supported on the + // resource ARNs in the same request. When using RoutingStepExpression , you need + // to pass exactly one QueueId . Currently tagging is only supported on the // resources that are passed in the filter. // // This member is required. @@ -89,6 +95,8 @@ type GetCurrentMetricDataInput struct { // profile filter. In addition, a routing profile filter is required for metrics // CONTACTS_SCHEDULED , CONTACTS_IN_QUEUE , and OLDEST_CONTACT_AGE . // - If no Grouping is included in the request, a summary of metrics is returned. + // - When using the RoutingStepExpression filter, group by + // ROUTING_STEP_EXPRESSION is required. Groupings []types.Grouping // The maximum number of results to return per page. diff --git a/service/connect/api_op_GetMetricData.go b/service/connect/api_op_GetMetricData.go index 5fb4603d325..e2bb7a54b5e 100644 --- a/service/connect/api_op_GetMetricData.go +++ b/service/connect/api_op_GetMetricData.go @@ -52,8 +52,10 @@ type GetMetricDataInput struct { // The queues, up to 100, or channels, to use to filter the metrics returned. // Metric data is retrieved only for the resources associated with the queues or // channels included in the filter. You can include both queue IDs and queue ARNs - // in the same request. VOICE, CHAT, and TASK channels are supported. To filter by - // Queues , enter the queue ID/ARN, not the name of the queue. + // in the same request. VOICE, CHAT, and TASK channels are supported. + // RoutingStepExpression is not a valid filter for GetMetricData and we recommend + // switching to GetMetricDataV2 for more up-to-date features. To filter by Queues , + // enter the queue ID/ARN, not the name of the queue. // // This member is required. Filters *types.Filters @@ -106,6 +108,8 @@ type GetMetricDataInput struct { // grouped by queue, the metrics returned are grouped by queue. The values returned // apply to the metrics for each queue rather than aggregated for all queues. If no // grouping is specified, a summary of metrics for all queues is returned. + // RoutingStepExpression is not a valid filter for GetMetricData and we recommend + // switching to GetMetricDataV2 for more up-to-date features. Groupings []types.Grouping // The maximum number of results to return per page. diff --git a/service/connect/api_op_GetMetricDataV2.go b/service/connect/api_op_GetMetricDataV2.go index 3d235026aa4..0e17490ce73 100644 --- a/service/connect/api_op_GetMetricDataV2.go +++ b/service/connect/api_op_GetMetricDataV2.go @@ -54,6 +54,7 @@ type GetMetricDataV2Input struct { // - Channels // - User hierarchy groups // - Feature + // - Routing step expression // At least one filter must be passed from queues, routing profiles, agents, or // user hierarchy groups. To filter by phone number, see Create a historical // metrics report (https://docs.aws.amazon.com/connect/latest/adminguide/create-historical-metrics-report.html) @@ -63,7 +64,7 @@ type GetMetricDataV2Input struct { // AGENT_HIERARCHY_LEVEL_ONE | AGENT_HIERARCHY_LEVEL_TWO | // AGENT_HIERARCHY_LEVEL_THREE | AGENT_HIERARCHY_LEVEL_FOUR | // AGENT_HIERARCHY_LEVEL_FIVE | FEATURE | - // contact/segmentAttributes/connect:Subtype + // contact/segmentAttributes/connect:Subtype | ROUTING_STEP_EXPRESSION // - Filter values: A maximum of 100 filter values are supported in a single // request. VOICE, CHAT, and TASK are valid filterValue for the CHANNEL filter // key. They do not count towards limitation of 100 filter values. For example, a @@ -73,7 +74,8 @@ type GetMetricDataV2Input struct { // filter key. It is available only to contacts analyzed by Contact Lens // conversational analytics. connect:Chat , connect:SMS , connect:Telephony , and // connect:WebRTC are valid filterValue examples (not exhaustive) for the - // contact/segmentAttributes/connect:Subtype filter key. + // contact/segmentAttributes/connect:Subtype filter key. ROUTING_STEP_EXPRESSION + // is a valid filter key with a filter value up to 3000 length. // // This member is required. Filters []types.FilterV2 @@ -127,12 +129,12 @@ type GetMetricDataV2Input struct { // filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, // contact/segmentAttributes/connect:Subtype AVG_HANDLE_TIME Unit: Seconds Valid // groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, - // Feature, contact/segmentAttributes/connect:Subtype Feature is a valid filter but - // not a valid grouping. AVG_HOLD_TIME Unit: Seconds Valid groupings and filters: - // Queue, Channel, Routing Profile, Agent, Agent Hierarchy, Feature, - // contact/segmentAttributes/connect:Subtype Feature is a valid filter but not a - // valid grouping. AVG_HOLD_TIME_ALL_CONTACTS Unit: Seconds Valid groupings and - // filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, + // Feature, contact/segmentAttributes/connect:Subtype, RoutingStepExpression + // Feature is a valid filter but not a valid grouping. AVG_HOLD_TIME Unit: Seconds + // Valid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent + // Hierarchy, Feature, contact/segmentAttributes/connect:Subtype Feature is a valid + // filter but not a valid grouping. AVG_HOLD_TIME_ALL_CONTACTS Unit: Seconds Valid + // groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, // contact/segmentAttributes/connect:Subtype AVG_HOLDS Unit: Count Valid groupings // and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, Feature, // contact/segmentAttributes/connect:Subtype Feature is a valid filter but not a @@ -169,15 +171,16 @@ type GetMetricDataV2Input struct { // Agent, Agent Hierarchy, contact/segmentAttributes/connect:Subtype // CONTACTS_ABANDONED Unit: Count Valid groupings and filters: Queue, Channel, // Routing Profile, Agent, Agent Hierarchy, - // contact/segmentAttributes/connect:Subtype CONTACTS_CREATED Unit: Count Valid - // metric filter key: INITIATION_METHOD Valid groupings and filters: Queue, - // Channel, Routing Profile, Feature, contact/segmentAttributes/connect:Subtype - // Feature is a valid filter but not a valid grouping. CONTACTS_HANDLED Unit: Count - // Valid metric filter key: INITIATION_METHOD , DISCONNECT_REASON Valid groupings - // and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, Feature, + // contact/segmentAttributes/connect:Subtype, RoutingStepExpression + // CONTACTS_CREATED Unit: Count Valid metric filter key: INITIATION_METHOD Valid + // groupings and filters: Queue, Channel, Routing Profile, Feature, // contact/segmentAttributes/connect:Subtype Feature is a valid filter but not a - // valid grouping. CONTACTS_HOLD_ABANDONS Unit: Count Valid groupings and filters: - // Queue, Channel, Routing Profile, Agent, Agent Hierarchy, + // valid grouping. CONTACTS_HANDLED Unit: Count Valid metric filter key: + // INITIATION_METHOD , DISCONNECT_REASON Valid groupings and filters: Queue, + // Channel, Routing Profile, Agent, Agent Hierarchy, Feature, + // contact/segmentAttributes/connect:Subtype, RoutingStepExpression Feature is a + // valid filter but not a valid grouping. CONTACTS_HOLD_ABANDONS Unit: Count Valid + // groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, // contact/segmentAttributes/connect:Subtype CONTACTS_ON_HOLD_AGENT_DISCONNECT // Unit: Count Valid groupings and filters: Queue, Channel, Routing Profile, Agent, // Agent Hierarchy CONTACTS_ON_HOLD_CUSTOMER_DISCONNECT Unit: Count Valid groupings @@ -202,25 +205,29 @@ type GetMetricDataV2Input struct { // Queue, Channel, Routing Profile, Agent, Agent Hierarchy, // contact/segmentAttributes/connect:Subtype MAX_QUEUED_TIME Unit: Seconds Valid // groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, - // contact/segmentAttributes/connect:Subtype PERCENT_NON_TALK_TIME This metric is - // available only for contacts analyzed by Contact Lens conversational analytics. - // Unit: Percentage Valid groupings and filters: Queue, Channel, Routing Profile, - // Agent, Agent Hierarchy, contact/segmentAttributes/connect:Subtype - // PERCENT_TALK_TIME This metric is available only for contacts analyzed by Contact - // Lens conversational analytics. Unit: Percentage Valid groupings and filters: - // Queue, Channel, Routing Profile, Agent, Agent Hierarchy, - // contact/segmentAttributes/connect:Subtype PERCENT_TALK_TIME_AGENT This metric is - // available only for contacts analyzed by Contact Lens conversational analytics. - // Unit: Percentage Valid groupings and filters: Queue, Channel, Routing Profile, - // Agent, Agent Hierarchy, contact/segmentAttributes/connect:Subtype - // PERCENT_TALK_TIME_CUSTOMER This metric is available only for contacts analyzed - // by Contact Lens conversational analytics. Unit: Percentage Valid groupings and + // contact/segmentAttributes/connect:Subtype PERCENT_CONTACTS_STEP_EXPIRED Unit: + // Percent Valid groupings and filters: Queue, RoutingStepExpression + // PERCENT_CONTACTS_STEP_JOINED Unit: Percent Valid groupings and filters: Queue, + // RoutingStepExpression PERCENT_NON_TALK_TIME This metric is available only for + // contacts analyzed by Contact Lens conversational analytics. Unit: Percentage + // Valid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent + // Hierarchy, contact/segmentAttributes/connect:Subtype PERCENT_TALK_TIME This + // metric is available only for contacts analyzed by Contact Lens conversational + // analytics. Unit: Percentage Valid groupings and filters: Queue, Channel, Routing + // Profile, Agent, Agent Hierarchy, contact/segmentAttributes/connect:Subtype + // PERCENT_TALK_TIME_AGENT This metric is available only for contacts analyzed by + // Contact Lens conversational analytics. Unit: Percentage Valid groupings and // filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy, - // contact/segmentAttributes/connect:Subtype SERVICE_LEVEL You can include up to 20 - // SERVICE_LEVEL metrics in a request. Unit: Percent Valid groupings and filters: - // Queue, Channel, Routing Profile Threshold: For ThresholdValue , enter any whole - // number from 1 to 604800 (inclusive), in seconds. For Comparison , you must enter - // LT (for "Less than"). SUM_AFTER_CONTACT_WORK_TIME Unit: Seconds Valid groupings + // contact/segmentAttributes/connect:Subtype PERCENT_TALK_TIME_CUSTOMER This metric + // is available only for contacts analyzed by Contact Lens conversational + // analytics. Unit: Percentage Valid groupings and filters: Queue, Channel, Routing + // Profile, Agent, Agent Hierarchy, contact/segmentAttributes/connect:Subtype + // SERVICE_LEVEL You can include up to 20 SERVICE_LEVEL metrics in a request. Unit: + // Percent Valid groupings and filters: Queue, Channel, Routing Profile Threshold: + // For ThresholdValue , enter any whole number from 1 to 604800 (inclusive), in + // seconds. For Comparison , you must enter LT (for "Less than"). + // STEP_CONTACTS_QUEUED Unit: Count Valid groupings and filters: Queue, + // RoutingStepExpression SUM_AFTER_CONTACT_WORK_TIME Unit: Seconds Valid groupings // and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy // SUM_CONNECTING_TIME_AGENT Unit: Seconds Valid metric filter key: // INITIATION_METHOD . This metric only supports the following filter keys as @@ -281,7 +288,8 @@ type GetMetricDataV2Input struct { // is returned. Valid grouping keys: QUEUE | ROUTING_PROFILE | AGENT | CHANNEL | // AGENT_HIERARCHY_LEVEL_ONE | AGENT_HIERARCHY_LEVEL_TWO | // AGENT_HIERARCHY_LEVEL_THREE | AGENT_HIERARCHY_LEVEL_FOUR | - // AGENT_HIERARCHY_LEVEL_FIVE , contact/segmentAttributes/connect:Subtype + // AGENT_HIERARCHY_LEVEL_FIVE , contact/segmentAttributes/connect:Subtype | + // ROUTING_STEP_EXPRESSION Groupings []string // The interval period and timezone to apply to returned metrics. diff --git a/service/connect/api_op_MonitorContact.go b/service/connect/api_op_MonitorContact.go index fcb85779198..2eae53f760e 100644 --- a/service/connect/api_op_MonitorContact.go +++ b/service/connect/api_op_MonitorContact.go @@ -50,6 +50,7 @@ type MonitorContactInput struct { // Specify which monitoring actions the user is allowed to take. For example, // whether the user is allowed to escalate from silent monitoring to barge. + // AllowedMonitorCapabilities is required if barge is enabled. AllowedMonitorCapabilities []types.MonitorCapability // A unique, case-sensitive identifier that you provide to ensure the idempotency diff --git a/service/connect/types/enums.go b/service/connect/types/enums.go index 4c80d1025d7..5ef32d15b61 100644 --- a/service/connect/types/enums.go +++ b/service/connect/types/enums.go @@ -769,6 +769,7 @@ const ( InstanceAttributeTypeMultiPartyConference InstanceAttributeType = "MULTI_PARTY_CONFERENCE" InstanceAttributeTypeHighVolumeOutbound InstanceAttributeType = "HIGH_VOLUME_OUTBOUND" InstanceAttributeTypeEnhancedContactMonitoring InstanceAttributeType = "ENHANCED_CONTACT_MONITORING" + InstanceAttributeTypeEnhancedChatMonitoring InstanceAttributeType = "ENHANCED_CHAT_MONITORING" ) // Values returns all known values for InstanceAttributeType. Note that this can @@ -786,6 +787,7 @@ func (InstanceAttributeType) Values() []InstanceAttributeType { "MULTI_PARTY_CONFERENCE", "HIGH_VOLUME_OUTBOUND", "ENHANCED_CONTACT_MONITORING", + "ENHANCED_CHAT_MONITORING", } } @@ -1039,10 +1041,11 @@ type ParticipantRole string // Enum values for ParticipantRole const ( - ParticipantRoleAgent ParticipantRole = "AGENT" - ParticipantRoleCustomer ParticipantRole = "CUSTOMER" - ParticipantRoleSystem ParticipantRole = "SYSTEM" - ParticipantRoleCustomBot ParticipantRole = "CUSTOM_BOT" + ParticipantRoleAgent ParticipantRole = "AGENT" + ParticipantRoleCustomer ParticipantRole = "CUSTOMER" + ParticipantRoleSystem ParticipantRole = "SYSTEM" + ParticipantRoleCustomBot ParticipantRole = "CUSTOM_BOT" + ParticipantRoleSupervisor ParticipantRole = "SUPERVISOR" ) // Values returns all known values for ParticipantRole. Note that this can be @@ -1054,6 +1057,7 @@ func (ParticipantRole) Values() []ParticipantRole { "CUSTOMER", "SYSTEM", "CUSTOM_BOT", + "SUPERVISOR", } } diff --git a/service/connect/types/types.go b/service/connect/types/types.go index fb9c54aab10..6e887dfa1d8 100644 --- a/service/connect/types/types.go +++ b/service/connect/types/types.go @@ -1700,7 +1700,11 @@ type EvaluationMetadata struct { // Information about notes for a contact evaluation. type EvaluationNote struct { - // The note for an item (section or question) in a contact evaluation. + // The note for an item (section or question) in a contact evaluation. Even though + // a note in an evaluation can have up to 3072 chars, there is also a limit on the + // total number of chars for all the notes in the evaluation combined. Assuming + // there are N questions in the evaluation being submitted, then the max char limit + // for all notes combined is N x 1024. Value *string noSmithyDocumentSerde diff --git a/service/connectparticipant/deserializers.go b/service/connectparticipant/deserializers.go index 26d06af2186..1ee214c4193 100644 --- a/service/connectparticipant/deserializers.go +++ b/service/connectparticipant/deserializers.go @@ -972,6 +972,9 @@ func awsRestjson1_deserializeOpErrorSendEvent(response *smithyhttp.Response, met case strings.EqualFold("AccessDeniedException", errorCode): return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + case strings.EqualFold("ConflictException", errorCode): + return awsRestjson1_deserializeErrorConflictException(response, errorBody) + case strings.EqualFold("InternalServerException", errorCode): return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) diff --git a/service/connectparticipant/endpoints.go b/service/connectparticipant/endpoints.go index 02b270d86e0..e4c4874a2fd 100644 --- a/service/connectparticipant/endpoints.go +++ b/service/connectparticipant/endpoints.go @@ -366,8 +366,8 @@ func (r *resolver) ResolveEndpoint( } } if _UseFIPS == true { - if true == _PartitionResult.SupportsFIPS { - if "aws-us-gov" == _PartitionResult.Name { + if _PartitionResult.SupportsFIPS == true { + if _PartitionResult.Name == "aws-us-gov" { uriString := func() string { var out strings.Builder out.WriteString("https://participant.connect.") diff --git a/service/connectparticipant/types/enums.go b/service/connectparticipant/types/enums.go index 18ff5103be3..0dfe33575f1 100644 --- a/service/connectparticipant/types/enums.go +++ b/service/connectparticipant/types/enums.go @@ -82,10 +82,11 @@ type ParticipantRole string // Enum values for ParticipantRole const ( - ParticipantRoleAgent ParticipantRole = "AGENT" - ParticipantRoleCustomer ParticipantRole = "CUSTOMER" - ParticipantRoleSystem ParticipantRole = "SYSTEM" - ParticipantRoleCustomBot ParticipantRole = "CUSTOM_BOT" + ParticipantRoleAgent ParticipantRole = "AGENT" + ParticipantRoleCustomer ParticipantRole = "CUSTOMER" + ParticipantRoleSystem ParticipantRole = "SYSTEM" + ParticipantRoleCustomBot ParticipantRole = "CUSTOM_BOT" + ParticipantRoleSupervisor ParticipantRole = "SUPERVISOR" ) // Values returns all known values for ParticipantRole. Note that this can be @@ -97,6 +98,7 @@ func (ParticipantRole) Values() []ParticipantRole { "CUSTOMER", "SYSTEM", "CUSTOM_BOT", + "SUPERVISOR", } } @@ -111,6 +113,7 @@ const ( ResourceTypeHierarchyLevel ResourceType = "HIERARCHY_LEVEL" ResourceTypeHierarchyGroup ResourceType = "HIERARCHY_GROUP" ResourceTypeUser ResourceType = "USER" + ResourceTypePhoneNumber ResourceType = "PHONE_NUMBER" ) // Values returns all known values for ResourceType. Note that this can be @@ -125,6 +128,7 @@ func (ResourceType) Values() []ResourceType { "HIERARCHY_LEVEL", "HIERARCHY_GROUP", "USER", + "PHONE_NUMBER", } } diff --git a/service/iottwinmaker/internal/endpoints/endpoints.go b/service/iottwinmaker/internal/endpoints/endpoints.go index c2d15ae2022..aed4ffd8967 100644 --- a/service/iottwinmaker/internal/endpoints/endpoints.go +++ b/service/iottwinmaker/internal/endpoints/endpoints.go @@ -408,6 +408,27 @@ var defaultPartitions = endpoints.Partitions{ }, RegionRegex: partitionRegexp.AwsCn, IsRegionalized: true, + Endpoints: endpoints.Endpoints{ + endpoints.EndpointKey{ + Region: "api-cn-north-1", + }: endpoints.Endpoint{ + Hostname: "api.iottwinmaker.cn-north-1.amazonaws.com.cn", + CredentialScope: endpoints.CredentialScope{ + Region: "cn-north-1", + }, + }, + endpoints.EndpointKey{ + Region: "cn-north-1", + }: endpoints.Endpoint{}, + endpoints.EndpointKey{ + Region: "data-cn-north-1", + }: endpoints.Endpoint{ + Hostname: "data.iottwinmaker.cn-north-1.amazonaws.com.cn", + CredentialScope: endpoints.CredentialScope{ + Region: "cn-north-1", + }, + }, + }, }, { ID: "aws-iso", diff --git a/service/location/api_op_GetMapGlyphs.go b/service/location/api_op_GetMapGlyphs.go index b08ed78e529..d64ade374c4 100644 --- a/service/location/api_op_GetMapGlyphs.go +++ b/service/location/api_op_GetMapGlyphs.go @@ -39,7 +39,8 @@ type GetMapGlyphsInput struct { // - VectorEsriTopographic – Noto Sans Italic | Noto Sans Regular | Noto Sans // Bold | Noto Serif Regular | Roboto Condensed Light Italic // - VectorEsriStreets – Arial Regular | Arial Italic | Arial Bold - // - VectorEsriNavigation – Arial Regular | Arial Italic | Arial Bold + // - VectorEsriNavigation – Arial Regular | Arial Italic | Arial Bold | Arial + // Unicode MS Bold | Arial Unicode MS Regular // Valid font stacks for HERE Technologies (https://docs.aws.amazon.com/location/latest/developerguide/HERE.html) // styles: // - VectorHereContrast – Fira GO Regular | Fira GO Bold diff --git a/service/location/api_op_GetPlace.go b/service/location/api_op_GetPlace.go index 7c761d973ce..f1c52f400b4 100644 --- a/service/location/api_op_GetPlace.go +++ b/service/location/api_op_GetPlace.go @@ -40,7 +40,29 @@ type GetPlaceInput struct { // This member is required. IndexName *string - // The identifier of the place to find. + // The identifier of the place to find. While you can use PlaceID in subsequent + // requests, PlaceID is not intended to be a permanent identifier and the ID can + // change between consecutive API calls. Please see the following PlaceID behaviour + // for each data provider: + // - Esri: Place IDs will change every quarter at a minimum. The typical time + // period for these changes would be March, June, September, and December. Place + // IDs might also change between the typical quarterly change but that will be much + // less frequent. + // - HERE: We recommend that you cache data for no longer than a week to keep + // your data data fresh. You can assume that less than 1% ID shifts will release + // over release which is approximately 1 - 2 times per week. + // - Grab: Place IDs can expire or become invalid in the following situations. + // - Data operations: The POI may be removed from Grab POI database by Grab Map + // Ops based on the ground-truth, such as being closed in the real world, being + // detected as a duplicate POI, or having incorrect information. Grab will + // synchronize data to the Waypoint environment on weekly basis. + // - Interpolated POI: Interpolated POI is a temporary POI generated in real + // time when serving a request, and it will be marked as derived in the + // place.result_type field in the response. The information of interpolated POIs + // will be retained for at least 30 days, which means that within 30 days, you are + // able to obtain POI details by Place ID from Place Details API. After 30 days, + // the interpolated POIs(both Place ID and details) may expire and inaccessible + // from the Places Details API. // // This member is required. PlaceId *string diff --git a/service/location/types/types.go b/service/location/types/types.go index 8514a2fd6c0..02b7bab8f77 100644 --- a/service/location/types/types.go +++ b/service/location/types/types.go @@ -905,9 +905,12 @@ type MapConfiguration struct { // Specifies the map style selected from an available data provider. Valid Esri // map styles (https://docs.aws.amazon.com/location/latest/developerguide/esri.html) // : - // - VectorEsriDarkGrayCanvas – The Esri Dark Gray Canvas map style. A vector - // basemap with a dark gray, neutral background with minimal colors, labels, and - // features that's designed to draw attention to your thematic content. + // - VectorEsriNavigation – The Esri Navigation map style, which provides a + // detailed basemap for the world symbolized with a custom navigation map style + // that's designed for use during the day in mobile devices. It also includes a + // richer set of places, such as shops, services, restaurants, attractions, and + // other points of interest. Enable the POI layer by setting it in CustomLayers + // to leverage the additional places data. // - RasterEsriImagery – The Esri Imagery map style. A raster basemap that // provides one meter or better satellite and aerial imagery in many parts of the // world and lower resolution satellite imagery worldwide. @@ -921,23 +924,14 @@ type MapConfiguration struct { // vector basemap for the world symbolized with a classic Esri street map style. // The vector tile layer is similar in content and style to the World Street Map // raster map. - // - VectorEsriNavigation – The Esri Navigation map style, which provides a - // detailed basemap for the world symbolized with a custom navigation map style - // that's designed for use during the day in mobile devices. + // - VectorEsriDarkGrayCanvas – The Esri Dark Gray Canvas map style. A vector + // basemap with a dark gray, neutral background with minimal colors, labels, and + // features that's designed to draw attention to your thematic content. // Valid HERE Technologies map styles (https://docs.aws.amazon.com/location/latest/developerguide/HERE.html) // : - // - VectorHereContrast – The HERE Contrast (Berlin) map style is a high contrast - // detailed base map of the world that blends 3D and 2D rendering. The - // VectorHereContrast style has been renamed from VectorHereBerlin . - // VectorHereBerlin has been deprecated, but will continue to work in - // applications that use it. // - VectorHereExplore – A default HERE map style containing a neutral, global // map and its features including roads, buildings, landmarks, and water features. // It also now includes a fully designed map of Japan. - // - VectorHereExploreTruck – A global map containing truck restrictions and - // attributes (e.g. width / height / HAZMAT) symbolized with highlighted segments - // and icons on top of HERE Explore to support use cases within transport and - // logistics. // - RasterHereExploreSatellite – A global map containing high resolution // satellite imagery. // - HybridHereExploreSatellite – A global map displaying the road network, @@ -947,6 +941,15 @@ type MapConfiguration struct { // when rendering the map that you see. This means that more tiles are retrieved // than when using either vector or raster tiles alone. Your charges will include // all tiles retrieved. + // - VectorHereContrast – The HERE Contrast (Berlin) map style is a high contrast + // detailed base map of the world that blends 3D and 2D rendering. The + // VectorHereContrast style has been renamed from VectorHereBerlin . + // VectorHereBerlin has been deprecated, but will continue to work in + // applications that use it. + // - VectorHereExploreTruck – A global map containing truck restrictions and + // attributes (e.g. width / height / HAZMAT) symbolized with highlighted segments + // and icons on top of HERE Explore to support use cases within transport and + // logistics. // Valid GrabMaps map styles (https://docs.aws.amazon.com/location/latest/developerguide/grab.html) // : // - VectorGrabStandardLight – The Grab Standard Light map style provides a @@ -981,9 +984,10 @@ type MapConfiguration struct { // Specifies the custom layers for the style. Leave unset to not enable any custom // layer, or, for styles that support custom layers, you can enable layer(s), such - // as POI layer for the VectorEsriNavigation style. Default is unset . Not all map - // resources or styles support custom layers. See Custom Layers for more - // information. + // as POI layer for the VectorEsriNavigation style. Default is unset . Currenlty + // only VectorEsriNavigation supports CustomLayers. For more information, see + // Custom Layers (https://docs.aws.amazon.com/location/latest/developerguide/map-concepts.html#map-custom-layers) + // . CustomLayers []string // Specifies the political view for the style. Leave unset to not use a political @@ -1001,9 +1005,10 @@ type MapConfigurationUpdate struct { // Specifies the custom layers for the style. Leave unset to not enable any custom // layer, or, for styles that support custom layers, you can enable layer(s), such - // as POI layer for the VectorEsriNavigation style. Default is unset . Not all map - // resources or styles support custom layers. See Custom Layers for more - // information. + // as POI layer for the VectorEsriNavigation style. Default is unset . Currenlty + // only VectorEsriNavigation supports CustomLayers. For more information, see + // Custom Layers (https://docs.aws.amazon.com/location/latest/developerguide/map-concepts.html#map-custom-layers) + // . CustomLayers []string // Specifies the political view for the style. Set to an empty string to not use a @@ -1069,10 +1074,12 @@ type Place struct { // . Street *string - // An area that's part of a larger municipality. For example, Blissville is a - // submunicipality in the Queen County in New York. This property supported by Esri - // and OpenData. The Esri property is district , and the OpenData property is - // borough . + // An area that's part of a larger municipality. For example, Blissville is a + // submunicipality in the Queen County in New York. This property is only returned + // for a place index that uses Esri as a data provider. The property is represented + // as a district . For more information about data providers, see Amazon Location + // Service data providers (https://docs.aws.amazon.com/location/latest/developerguide/what-is-data-provider.html) + // . SubMunicipality *string // A county, or an area that's part of a larger region. For example, Metro @@ -1088,13 +1095,14 @@ type Place struct { TimeZone *TimeZone // For addresses with multiple units, the unit identifier. Can include numbers and - // letters, for example 3B or Unit 123 . Returned only for a place index that uses - // Esri or Grab as a data provider. Is not returned for SearchPlaceIndexForPosition - // . + // letters, for example 3B or Unit 123 . This property is returned only for a place + // index that uses Esri or Grab as a data provider. It is not returned for + // SearchPlaceIndexForPosition . UnitNumber *string // For addresses with a UnitNumber , the type of unit. For example, Apartment . - // Returned only for a place index that uses Esri as a data provider. + // This property is returned only for a place index that uses Esri as a data + // provider. UnitType *string noSmithyDocumentSerde @@ -1219,7 +1227,29 @@ type SearchForSuggestionsResult struct { // Place. The GetPlace request must use the same PlaceIndex resource as the // SearchPlaceIndexForSuggestions that generated the Place ID. For // SearchPlaceIndexForSuggestions operations, the PlaceId is returned by place - // indexes that use Esri, Grab, or HERE as data providers. + // indexes that use Esri, Grab, or HERE as data providers. While you can use + // PlaceID in subsequent requests, PlaceID is not intended to be a permanent + // identifier and the ID can change between consecutive API calls. Please see the + // following PlaceID behaviour for each data provider: + // - Esri: Place IDs will change every quarter at a minimum. The typical time + // period for these changes would be March, June, September, and December. Place + // IDs might also change between the typical quarterly change but that will be much + // less frequent. + // - HERE: We recommend that you cache data for no longer than a week to keep + // your data data fresh. You can assume that less than 1% ID shifts will release + // over release which is approximately 1 - 2 times per week. + // - Grab: Place IDs can expire or become invalid in the following situations. + // - Data operations: The POI may be removed from Grab POI database by Grab Map + // Ops based on the ground-truth, such as being closed in the real world, being + // detected as a duplicate POI, or having incorrect information. Grab will + // synchronize data to the Waypoint environment on weekly basis. + // - Interpolated POI: Interpolated POI is a temporary POI generated in real + // time when serving a request, and it will be marked as derived in the + // place.result_type field in the response. The information of interpolated POIs + // will be retained for at least 30 days, which means that within 30 days, you are + // able to obtain POI details by Place ID from Place Details API. After 30 days, + // the interpolated POIs(both Place ID and details) may expire and inaccessible + // from the Places Details API. PlaceId *string // Categories from the data provider that describe the Place that are not mapped diff --git a/service/mwaa/api_op_CreateWebLoginToken.go b/service/mwaa/api_op_CreateWebLoginToken.go index 79884c911ca..5bfa547c606 100644 --- a/service/mwaa/api_op_CreateWebLoginToken.go +++ b/service/mwaa/api_op_CreateWebLoginToken.go @@ -41,6 +41,14 @@ type CreateWebLoginTokenInput struct { type CreateWebLoginTokenOutput struct { + // The user name of the Apache Airflow identity creating the web login token. + AirflowIdentity *string + + // The name of the IAM identity creating the web login token. This might be an IAM + // user, or an assumed or federated identity. For example, + // assumed-role/Admin/your-name . + IamIdentity *string + // The Airflow web server hostname for the environment. WebServerHostname *string diff --git a/service/mwaa/deserializers.go b/service/mwaa/deserializers.go index 09592006c89..5a9fd5f9fe0 100644 --- a/service/mwaa/deserializers.go +++ b/service/mwaa/deserializers.go @@ -475,6 +475,24 @@ func awsRestjson1_deserializeOpDocumentCreateWebLoginTokenOutput(v **CreateWebLo for key, value := range shape { switch key { + case "AirflowIdentity": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected AirflowIdentity to be of type string, got %T instead", value) + } + sv.AirflowIdentity = ptr.String(jtv) + } + + case "IamIdentity": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected IamIdentity to be of type string, got %T instead", value) + } + sv.IamIdentity = ptr.String(jtv) + } + case "WebServerHostname": if value != nil { jtv, ok := value.(string) diff --git a/service/s3control/endpoints.go b/service/s3control/endpoints.go index 0afd9ee4828..973121712f7 100644 --- a/service/s3control/endpoints.go +++ b/service/s3control/endpoints.go @@ -452,10 +452,14 @@ func (r *resolver) ResolveEndpoint( if !(rulesfn.IsValidHostLabel(_OutpostId, false)) { return endpoint, fmt.Errorf("endpoint rule error, %s", "OutpostId must only contain a-z, A-Z, 0-9 and `-`.") } - if rulesfn.IsValidHostLabel(_Region, true) { + if exprVal := params.Endpoint; exprVal != nil { + _Endpoint := *exprVal + _ = _Endpoint if _UseDualStack == true { - return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid configuration: Outposts do not support dual-stack") + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: DualStack and custom endpoint are not supported") } + } + if rulesfn.IsValidHostLabel(_Region, true) { if exprVal := params.Endpoint; exprVal != nil { _Endpoint := *exprVal _ = _Endpoint @@ -501,6 +505,47 @@ func (r *resolver) ResolveEndpoint( }, nil } } + if _UseFIPS == true { + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts-fips.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_partitionResult.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } + } if _UseFIPS == true { uriString := func() string { var out strings.Builder @@ -540,6 +585,45 @@ func (r *resolver) ResolveEndpoint( }(), }, nil } + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_partitionResult.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } uriString := func() string { var out strings.Builder out.WriteString("https://s3-outposts.") @@ -593,13 +677,17 @@ func (r *resolver) ResolveEndpoint( _ = _arnType if !(_arnType == "") { if _accessPointArn.Service == "s3-outposts" { - if _UseDualStack == true { - return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid configuration: Outpost Access Points do not support dual-stack") - } if exprVal := _accessPointArn.ResourceId.Get(1); exprVal != nil { _outpostId := *exprVal _ = _outpostId if rulesfn.IsValidHostLabel(_outpostId, false) { + if exprVal := params.Endpoint; exprVal != nil { + _Endpoint := *exprVal + _ = _Endpoint + if _UseDualStack == true { + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: DualStack and custom endpoint are not supported") + } + } if exprVal := params.UseArnRegion; exprVal != nil { _UseArnRegion := *exprVal _ = _UseArnRegion @@ -649,6 +737,52 @@ func (r *resolver) ResolveEndpoint( _accessPointName := *exprVal _ = _accessPointName if _outpostType == "accesspoint" { + if _UseFIPS == true { + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts-fips.") + out.WriteString(_accessPointArn.Region) + out.WriteString(".") + out.WriteString(_arnPartition.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", _accessPointArn.AccountId) + headers.Set("x-amz-outpost-id", _outpostId) + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _accessPointArn.Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } + } if _UseFIPS == true { uriString := func() string { var out strings.Builder @@ -693,6 +827,50 @@ func (r *resolver) ResolveEndpoint( }(), }, nil } + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts.") + out.WriteString(_accessPointArn.Region) + out.WriteString(".") + out.WriteString(_arnPartition.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", _accessPointArn.AccountId) + headers.Set("x-amz-outpost-id", _outpostId) + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _accessPointArn.Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } if exprVal := params.Endpoint; exprVal != nil { _Endpoint := *exprVal _ = _Endpoint @@ -857,13 +1035,17 @@ func (r *resolver) ResolveEndpoint( _ = _arnType if !(_arnType == "") { if _bucketArn.Service == "s3-outposts" { - if _UseDualStack == true { - return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid configuration: Outpost buckets do not support dual-stack") - } if exprVal := _bucketArn.ResourceId.Get(1); exprVal != nil { _outpostId := *exprVal _ = _outpostId if rulesfn.IsValidHostLabel(_outpostId, false) { + if exprVal := params.Endpoint; exprVal != nil { + _Endpoint := *exprVal + _ = _Endpoint + if _UseDualStack == true { + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: DualStack and custom endpoint are not supported") + } + } if exprVal := params.UseArnRegion; exprVal != nil { _UseArnRegion := *exprVal _ = _UseArnRegion @@ -913,6 +1095,52 @@ func (r *resolver) ResolveEndpoint( _bucketName := *exprVal _ = _bucketName if _outpostType == "bucket" { + if _UseFIPS == true { + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts-fips.") + out.WriteString(_bucketArn.Region) + out.WriteString(".") + out.WriteString(_arnPartition.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", _bucketArn.AccountId) + headers.Set("x-amz-outpost-id", _outpostId) + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _bucketArn.Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } + } if _UseFIPS == true { uriString := func() string { var out strings.Builder @@ -957,6 +1185,50 @@ func (r *resolver) ResolveEndpoint( }(), }, nil } + if _UseDualStack == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://s3-outposts.") + out.WriteString(_bucketArn.Region) + out.WriteString(".") + out.WriteString(_arnPartition.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", _bucketArn.AccountId) + headers.Set("x-amz-outpost-id", _outpostId) + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetDisableDoubleEncoding(&sp, true) + + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, _bucketArn.Region) + return sp + }(), + }, + }) + return out + }(), + }, nil + } if exprVal := params.Endpoint; exprVal != nil { _Endpoint := *exprVal _ = _Endpoint diff --git a/service/s3control/endpoints_test.go b/service/s3control/endpoints_test.go index ce39633355a..dc05ab8028d 100644 --- a/service/s3control/endpoints_test.go +++ b/service/s3control/endpoints_test.go @@ -1219,7 +1219,7 @@ func TestEndpointCase18(t *testing.T) { } } -// outpost access points do not support dualstack@us-west-2 +// outpost access points support dualstack@us-west-2 func TestEndpointCase19(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), @@ -1234,20 +1234,62 @@ func TestEndpointCase19(t *testing.T) { result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost Access Points do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://s3-outposts.us-west-2.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", "123456789012") + headers.Set("x-amz-outpost-id", "op-01234567890123456") + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "us-west-2") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } -// outpost access points do not support dualstack@cn-north-1 +// outpost access points support dualstack@af-south-1 func TestEndpointCase20(t *testing.T) { var params = EndpointParameters{ - AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), + AccessPointName: ptr.String("arn:aws:s3-outposts:af-south-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), AccountId: ptr.String("123456789012"), - Region: ptr.String("cn-north-1"), + Region: ptr.String("af-south-1"), RequiresAccountId: ptr.Bool(true), UseDualStack: ptr.Bool(true), UseFIPS: ptr.Bool(false), @@ -1257,34 +1299,118 @@ func TestEndpointCase20(t *testing.T) { result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost Access Points do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://s3-outposts.af-south-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", "123456789012") + headers.Set("x-amz-outpost-id", "op-01234567890123456") + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "af-south-1") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } -// outpost access points do not support dualstack@af-south-1 +// outpost access points support fips + dualstack@af-south-1 func TestEndpointCase21(t *testing.T) { var params = EndpointParameters{ - AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), + AccessPointName: ptr.String("arn:aws:s3-outposts:af-south-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), AccountId: ptr.String("123456789012"), Region: ptr.String("af-south-1"), RequiresAccountId: ptr.Bool(true), UseDualStack: ptr.Bool(true), - UseFIPS: ptr.Bool(false), + UseFIPS: ptr.Bool(true), } resolver := NewDefaultEndpointResolverV2() result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost Access Points do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://s3-outposts-fips.af-south-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", "123456789012") + headers.Set("x-amz-outpost-id", "op-01234567890123456") + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "af-south-1") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } @@ -1926,15 +2052,14 @@ func TestEndpointCase35(t *testing.T) { } } -// CreateBucket + OutpostId endpoint url@us-east-2 +// ListRegionalBucket + OutpostId + fips + dualstack@us-east-2 func TestEndpointCase36(t *testing.T) { var params = EndpointParameters{ - Bucket: ptr.String("blah"), - Endpoint: ptr.String("https://beta.example.com"), - OutpostId: ptr.String("123"), + AccountId: ptr.String("123456789012"), + OutpostId: ptr.String("op-123"), Region: ptr.String("us-east-2"), - RequiresAccountId: ptr.Bool(false), - UseDualStack: ptr.Bool(false), + RequiresAccountId: ptr.Bool(true), + UseDualStack: ptr.Bool(true), UseFIPS: ptr.Bool(true), } @@ -1946,7 +2071,7 @@ func TestEndpointCase36(t *testing.T) { t.Fatalf("expect no error, got %v", err) } - uri, _ := url.Parse("https://beta.example.com") + uri, _ := url.Parse("https://s3-outposts-fips.us-east-2.api.aws") expectEndpoint := smithyendpoints.Endpoint{ URI: *uri, @@ -1987,37 +2112,74 @@ func TestEndpointCase36(t *testing.T) { } } -// dualstack cannot be used with outposts when an endpoint URL is set@us-west-2. +// CreateBucket + OutpostId endpoint url@us-east-2 func TestEndpointCase37(t *testing.T) { var params = EndpointParameters{ - AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), + Bucket: ptr.String("blah"), Endpoint: ptr.String("https://beta.example.com"), - Region: ptr.String("us-west-2"), - RequiresAccountId: ptr.Bool(true), - UseDualStack: ptr.Bool(true), - UseFIPS: ptr.Bool(false), + OutpostId: ptr.String("123"), + Region: ptr.String("us-east-2"), + RequiresAccountId: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + UseFIPS: ptr.Bool(true), } resolver := NewDefaultEndpointResolverV2() result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost Access Points do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://beta.example.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "us-east-2") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } -// Dual-stack cannot be used with outposts@us-west-2 +// dualstack cannot be used with outposts when an endpoint URL is set@us-west-2. func TestEndpointCase38(t *testing.T) { var params = EndpointParameters{ - Bucket: ptr.String("bucketname"), - Endpoint: ptr.String("https://beta.example.com"), - OutpostId: ptr.String("op-123"), + AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), + Endpoint: ptr.String("https://s3-outposts.us-west-2.api.aws"), Region: ptr.String("us-west-2"), - RequiresAccountId: ptr.Bool(false), + RequiresAccountId: ptr.Bool(true), UseDualStack: ptr.Bool(true), UseFIPS: ptr.Bool(false), } @@ -2029,7 +2191,7 @@ func TestEndpointCase38(t *testing.T) { if err == nil { t.Fatalf("expect error, got none") } - if e, a := "Invalid configuration: Outposts do not support dual-stack", err.Error(); !strings.Contains(a, e) { + if e, a := "Invalid Configuration: DualStack and custom endpoint are not supported", err.Error(); !strings.Contains(a, e) { t.Errorf("expect %v error in %v", e, a) } } @@ -2355,25 +2517,67 @@ func TestEndpointCase43(t *testing.T) { } } -// Outposts do not support dualstack@us-west-2 +// bucket ARN in aws partition with fips + dualstack@us-east-2 func TestEndpointCase44(t *testing.T) { var params = EndpointParameters{ - Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), - Region: ptr.String("us-west-2"), + Bucket: ptr.String("arn:aws:s3-outposts:us-east-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), + Region: ptr.String("us-east-2"), RequiresAccountId: ptr.Bool(true), UseDualStack: ptr.Bool(true), - UseFIPS: ptr.Bool(false), + UseFIPS: ptr.Bool(true), } resolver := NewDefaultEndpointResolverV2() result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost buckets do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://s3-outposts-fips.us-east-2.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", "123456789012") + headers.Set("x-amz-outpost-id", "op-01234567890123456") + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "us-east-2") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } @@ -2698,7 +2902,7 @@ func TestEndpointCase49(t *testing.T) { } } -// Outposts do not support dualstack@us-west-2 +// Outposts support dualstack @us-west-2 func TestEndpointCase50(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), @@ -2712,11 +2916,53 @@ func TestEndpointCase50(t *testing.T) { result, err := resolver.ResolveEndpoint(context.Background(), params) _, _ = result, err - if err == nil { - t.Fatalf("expect error, got none") + if err != nil { + t.Fatalf("expect no error, got %v", err) } - if e, a := "Invalid configuration: Outpost buckets do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) + + uri, _ := url.Parse("https://s3-outposts.us-west-2.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: func() http.Header { + headers := http.Header{} + headers.Set("x-amz-account-id", "123456789012") + headers.Set("x-amz-outpost-id", "op-01234567890123456") + return headers + }(), + Properties: func() smithy.Properties { + var out smithy.Properties + smithyauth.SetAuthOptions(&out, []*smithyauth.Option{ + { + SchemeID: "aws.auth#sigv4", + SignerProperties: func() smithy.Properties { + var sp smithy.Properties + smithyhttp.SetSigV4SigningName(&sp, "s3-outposts") + smithyhttp.SetSigV4ASigningName(&sp, "s3-outposts") + + smithyhttp.SetSigV4SigningRegion(&sp, "us-west-2") + + smithyhttp.SetDisableDoubleEncoding(&sp, true) + return sp + }(), + }, + }) + return out + }(), + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) } } @@ -3041,30 +3287,8 @@ func TestEndpointCase55(t *testing.T) { } } -// Outposts do not support dualstack@us-west-2 -func TestEndpointCase56(t *testing.T) { - var params = EndpointParameters{ - Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), - Region: ptr.String("us-west-2"), - RequiresAccountId: ptr.Bool(true), - UseDualStack: ptr.Bool(true), - UseFIPS: ptr.Bool(false), - } - - resolver := NewDefaultEndpointResolverV2() - result, err := resolver.ResolveEndpoint(context.Background(), params) - _, _ = result, err - - if err == nil { - t.Fatalf("expect error, got none") - } - if e, a := "Invalid configuration: Outpost buckets do not support dual-stack", err.Error(); !strings.Contains(a, e) { - t.Errorf("expect %v error in %v", e, a) - } -} - // Invalid ARN: missing outpost id and bucket@us-west-2 -func TestEndpointCase57(t *testing.T) { +func TestEndpointCase56(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost"), Region: ptr.String("us-west-2"), @@ -3086,7 +3310,7 @@ func TestEndpointCase57(t *testing.T) { } // Invalid ARN: missing bucket@us-west-2 -func TestEndpointCase58(t *testing.T) { +func TestEndpointCase57(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456"), Region: ptr.String("us-west-2"), @@ -3108,7 +3332,7 @@ func TestEndpointCase58(t *testing.T) { } // Invalid ARN: missing outpost and bucket ids@us-west-2 -func TestEndpointCase59(t *testing.T) { +func TestEndpointCase58(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:bucket"), Region: ptr.String("us-west-2"), @@ -3130,7 +3354,7 @@ func TestEndpointCase59(t *testing.T) { } // Invalid ARN: missing bucket id@us-west-2 -func TestEndpointCase60(t *testing.T) { +func TestEndpointCase59(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket"), Region: ptr.String("us-west-2"), @@ -3152,7 +3376,7 @@ func TestEndpointCase60(t *testing.T) { } // account id inserted into hostname@us-west-2 -func TestEndpointCase61(t *testing.T) { +func TestEndpointCase60(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("1234567890"), Region: ptr.String("us-west-2"), @@ -3211,7 +3435,7 @@ func TestEndpointCase61(t *testing.T) { } // account id prefix with dualstack@us-east-1 -func TestEndpointCase62(t *testing.T) { +func TestEndpointCase61(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("1234567890"), Region: ptr.String("us-east-1"), @@ -3270,7 +3494,7 @@ func TestEndpointCase62(t *testing.T) { } // account id prefix with fips@us-east-1 -func TestEndpointCase63(t *testing.T) { +func TestEndpointCase62(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("1234567890"), Region: ptr.String("us-east-1"), @@ -3329,7 +3553,7 @@ func TestEndpointCase63(t *testing.T) { } // custom account id prefix with fips@us-east-1 -func TestEndpointCase64(t *testing.T) { +func TestEndpointCase63(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -3388,7 +3612,7 @@ func TestEndpointCase64(t *testing.T) { } // standard url @ us-east-1 -func TestEndpointCase65(t *testing.T) { +func TestEndpointCase64(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), } @@ -3443,7 +3667,7 @@ func TestEndpointCase65(t *testing.T) { } // fips url @ us-east-1 -func TestEndpointCase66(t *testing.T) { +func TestEndpointCase65(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), UseFIPS: ptr.Bool(true), @@ -3499,7 +3723,7 @@ func TestEndpointCase66(t *testing.T) { } // dualstack url @ us-east-1 -func TestEndpointCase67(t *testing.T) { +func TestEndpointCase66(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), UseDualStack: ptr.Bool(true), @@ -3555,7 +3779,7 @@ func TestEndpointCase67(t *testing.T) { } // fips,dualstack url @ us-east-1 -func TestEndpointCase68(t *testing.T) { +func TestEndpointCase67(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), UseDualStack: ptr.Bool(true), @@ -3612,7 +3836,7 @@ func TestEndpointCase68(t *testing.T) { } // standard url @ cn-north-1 -func TestEndpointCase69(t *testing.T) { +func TestEndpointCase68(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("cn-north-1"), } @@ -3667,7 +3891,7 @@ func TestEndpointCase69(t *testing.T) { } // fips @ cn-north-1 -func TestEndpointCase70(t *testing.T) { +func TestEndpointCase69(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("cn-north-1"), UseDualStack: ptr.Bool(true), @@ -3687,7 +3911,7 @@ func TestEndpointCase70(t *testing.T) { } // custom account id prefix @us-east-1 -func TestEndpointCase71(t *testing.T) { +func TestEndpointCase70(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -3746,7 +3970,7 @@ func TestEndpointCase71(t *testing.T) { } // invalid account id prefix @us-east-1 -func TestEndpointCase72(t *testing.T) { +func TestEndpointCase71(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("/?invalid¬-host*label"), Region: ptr.String("us-east-1"), @@ -3768,7 +3992,7 @@ func TestEndpointCase72(t *testing.T) { } // custom account id prefix with fips@us-east-1 -func TestEndpointCase73(t *testing.T) { +func TestEndpointCase72(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -3827,7 +4051,7 @@ func TestEndpointCase73(t *testing.T) { } // custom account id prefix with dualstack,fips@us-east-1 -func TestEndpointCase74(t *testing.T) { +func TestEndpointCase73(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -3886,7 +4110,7 @@ func TestEndpointCase74(t *testing.T) { } // custom account id with custom endpoint -func TestEndpointCase75(t *testing.T) { +func TestEndpointCase74(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -3944,7 +4168,7 @@ func TestEndpointCase75(t *testing.T) { } // RequiresAccountId with AccountId unset -func TestEndpointCase76(t *testing.T) { +func TestEndpointCase75(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), RequiresAccountId: ptr.Bool(true), @@ -3963,7 +4187,7 @@ func TestEndpointCase76(t *testing.T) { } // RequiresAccountId with AccountId unset and custom endpoint -func TestEndpointCase77(t *testing.T) { +func TestEndpointCase76(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), Endpoint: ptr.String("https://beta.example.com"), @@ -3983,7 +4207,7 @@ func TestEndpointCase77(t *testing.T) { } // RequiresAccountId with invalid AccountId and custom endpoint -func TestEndpointCase78(t *testing.T) { +func TestEndpointCase77(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), Endpoint: ptr.String("https://beta.example.com"), @@ -4004,7 +4228,7 @@ func TestEndpointCase78(t *testing.T) { } // account id with custom endpoint, fips -func TestEndpointCase79(t *testing.T) { +func TestEndpointCase78(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("123456789012"), Region: ptr.String("us-east-1"), @@ -4063,7 +4287,7 @@ func TestEndpointCase79(t *testing.T) { } // custom endpoint, fips -func TestEndpointCase80(t *testing.T) { +func TestEndpointCase79(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), Endpoint: ptr.String("https://example.com"), @@ -4120,7 +4344,7 @@ func TestEndpointCase80(t *testing.T) { } // custom endpoint, fips -func TestEndpointCase81(t *testing.T) { +func TestEndpointCase80(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), Endpoint: ptr.String("https://example.com"), @@ -4177,7 +4401,7 @@ func TestEndpointCase81(t *testing.T) { } // custom endpoint, DualStack -func TestEndpointCase82(t *testing.T) { +func TestEndpointCase81(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("us-east-1"), Endpoint: ptr.String("https://example.com"), @@ -4198,7 +4422,7 @@ func TestEndpointCase82(t *testing.T) { } // region not set -func TestEndpointCase83(t *testing.T) { +func TestEndpointCase82(t *testing.T) { var params = EndpointParameters{} resolver := NewDefaultEndpointResolverV2() @@ -4214,7 +4438,7 @@ func TestEndpointCase83(t *testing.T) { } // invalid partition -func TestEndpointCase84(t *testing.T) { +func TestEndpointCase83(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("invalid-region 42"), } @@ -4232,7 +4456,7 @@ func TestEndpointCase84(t *testing.T) { } // ListRegionalBuckets + OutpostId without accountId set. -func TestEndpointCase85(t *testing.T) { +func TestEndpointCase84(t *testing.T) { var params = EndpointParameters{ OutpostId: ptr.String("op-123"), Region: ptr.String("us-east-2"), @@ -4254,7 +4478,7 @@ func TestEndpointCase85(t *testing.T) { } // ListRegionalBuckets + OutpostId with invalid accountId set. -func TestEndpointCase86(t *testing.T) { +func TestEndpointCase85(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("/?invalid¬-host*label"), OutpostId: ptr.String("op-123"), @@ -4277,7 +4501,7 @@ func TestEndpointCase86(t *testing.T) { } // accesspoint set but missing accountId -func TestEndpointCase87(t *testing.T) { +func TestEndpointCase86(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("myaccesspoint"), Region: ptr.String("us-west-2"), @@ -4299,7 +4523,7 @@ func TestEndpointCase87(t *testing.T) { } // outpost accesspoint ARN with missing accountId -func TestEndpointCase88(t *testing.T) { +func TestEndpointCase87(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2::outpost:op-01234567890123456:outpost:op1"), Region: ptr.String("us-west-2"), @@ -4321,7 +4545,7 @@ func TestEndpointCase88(t *testing.T) { } // bucket ARN with missing accountId -func TestEndpointCase89(t *testing.T) { +func TestEndpointCase88(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2::outpost:op-01234567890123456:bucket:mybucket"), Region: ptr.String("us-west-2"), @@ -4343,7 +4567,7 @@ func TestEndpointCase89(t *testing.T) { } // endpoint url with accesspoint (non-arn) -func TestEndpointCase90(t *testing.T) { +func TestEndpointCase89(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("apname"), Endpoint: ptr.String("https://beta.example.com"), @@ -4404,7 +4628,7 @@ func TestEndpointCase90(t *testing.T) { } // access point name with an accesspoint arn@us-west-2 -func TestEndpointCase91(t *testing.T) { +func TestEndpointCase90(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), Endpoint: ptr.String("https://beta.example.com"), @@ -4469,7 +4693,7 @@ func TestEndpointCase91(t *testing.T) { } // DualStack + Custom endpoint is not supported(non-arn) -func TestEndpointCase92(t *testing.T) { +func TestEndpointCase91(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("apname"), Endpoint: ptr.String("https://beta.example.com"), @@ -4492,11 +4716,11 @@ func TestEndpointCase92(t *testing.T) { } } -// get bucket with endpoint_url and dualstack is not supported@us-west-2 -func TestEndpointCase93(t *testing.T) { +// get bucket with custom endpoint and dualstack is not supported@us-west-2 +func TestEndpointCase92(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), - Endpoint: ptr.String("https://beta.example.com"), + Endpoint: ptr.String("https://s3-outposts.us-west-2.api.aws"), Region: ptr.String("us-west-2"), RequiresAccountId: ptr.Bool(true), UseDualStack: ptr.Bool(true), @@ -4510,13 +4734,13 @@ func TestEndpointCase93(t *testing.T) { if err == nil { t.Fatalf("expect error, got none") } - if e, a := "Invalid configuration: Outpost buckets do not support dual-stack", err.Error(); !strings.Contains(a, e) { + if e, a := "Invalid Configuration: DualStack and custom endpoint are not supported", err.Error(); !strings.Contains(a, e) { t.Errorf("expect %v error in %v", e, a) } } // ListRegionalBuckets + OutpostId with fips in CN. -func TestEndpointCase94(t *testing.T) { +func TestEndpointCase93(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("0123456789012"), OutpostId: ptr.String("op-123"), @@ -4539,7 +4763,7 @@ func TestEndpointCase94(t *testing.T) { } // ListRegionalBuckets + invalid OutpostId. -func TestEndpointCase95(t *testing.T) { +func TestEndpointCase94(t *testing.T) { var params = EndpointParameters{ AccountId: ptr.String("0123456789012"), OutpostId: ptr.String("?outpost/invalid+"), @@ -4562,7 +4786,7 @@ func TestEndpointCase95(t *testing.T) { } // bucket ARN with mismatched accountId -func TestEndpointCase96(t *testing.T) { +func TestEndpointCase95(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:999999:outpost:op-01234567890123456:bucket:mybucket"), AccountId: ptr.String("0123456789012"), @@ -4585,7 +4809,7 @@ func TestEndpointCase96(t *testing.T) { } // OutpostId with invalid region -func TestEndpointCase97(t *testing.T) { +func TestEndpointCase96(t *testing.T) { var params = EndpointParameters{ OutpostId: ptr.String("op-123"), Region: ptr.String("invalid-region 42"), @@ -4608,7 +4832,7 @@ func TestEndpointCase97(t *testing.T) { } // OutpostId with RequireAccountId unset -func TestEndpointCase98(t *testing.T) { +func TestEndpointCase97(t *testing.T) { var params = EndpointParameters{ OutpostId: ptr.String("op-123"), Region: ptr.String("us-west-2"), @@ -4667,7 +4891,7 @@ func TestEndpointCase98(t *testing.T) { // Outpost Accesspoint ARN with arn region and client region mismatch with // UseArnRegion=false -func TestEndpointCase99(t *testing.T) { +func TestEndpointCase98(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), AccountId: ptr.String("123456789012"), @@ -4692,7 +4916,7 @@ func TestEndpointCase99(t *testing.T) { // Outpost Bucket ARN with arn region and client region mismatch with // UseArnRegion=false -func TestEndpointCase100(t *testing.T) { +func TestEndpointCase99(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket"), Endpoint: ptr.String("https://beta.example.com"), @@ -4716,7 +4940,7 @@ func TestEndpointCase100(t *testing.T) { } // Accesspoint ARN with region mismatch and UseArnRegion unset -func TestEndpointCase101(t *testing.T) { +func TestEndpointCase100(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), AccountId: ptr.String("123456789012"), @@ -4781,7 +5005,7 @@ func TestEndpointCase101(t *testing.T) { } // Bucket ARN with region mismatch and UseArnRegion unset -func TestEndpointCase102(t *testing.T) { +func TestEndpointCase101(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket"), Region: ptr.String("us-west-2"), @@ -4845,7 +5069,7 @@ func TestEndpointCase102(t *testing.T) { } // Outpost Bucket ARN with partition mismatch with UseArnRegion=true -func TestEndpointCase103(t *testing.T) { +func TestEndpointCase102(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:bucket:mybucket"), Region: ptr.String("us-west-2"), @@ -4868,7 +5092,7 @@ func TestEndpointCase103(t *testing.T) { } // Accesspoint ARN with partition mismatch and UseArnRegion=true -func TestEndpointCase104(t *testing.T) { +func TestEndpointCase103(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), AccountId: ptr.String("123456789012"), @@ -4892,7 +5116,7 @@ func TestEndpointCase104(t *testing.T) { } // Accesspoint ARN with region mismatch, UseArnRegion=false and custom endpoint -func TestEndpointCase105(t *testing.T) { +func TestEndpointCase104(t *testing.T) { var params = EndpointParameters{ AccessPointName: ptr.String("arn:aws:s3-outposts:cn-north-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"), Region: ptr.String("us-west-2"), @@ -4916,7 +5140,7 @@ func TestEndpointCase105(t *testing.T) { } // outpost bucket arn@us-west-2 -func TestEndpointCase106(t *testing.T) { +func TestEndpointCase105(t *testing.T) { var params = EndpointParameters{ Bucket: ptr.String("arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"), Region: ptr.String("us-west-2"), @@ -4980,7 +5204,7 @@ func TestEndpointCase106(t *testing.T) { } // S3 Snow Control with bucket -func TestEndpointCase107(t *testing.T) { +func TestEndpointCase106(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Bucket: ptr.String("bucketName"), @@ -5039,7 +5263,7 @@ func TestEndpointCase107(t *testing.T) { } // S3 Snow Control without bucket -func TestEndpointCase108(t *testing.T) { +func TestEndpointCase107(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Endpoint: ptr.String("https://10.0.1.12:433"), @@ -5097,7 +5321,7 @@ func TestEndpointCase108(t *testing.T) { } // S3 Snow Control with bucket and without port -func TestEndpointCase109(t *testing.T) { +func TestEndpointCase108(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Bucket: ptr.String("bucketName"), @@ -5156,7 +5380,7 @@ func TestEndpointCase109(t *testing.T) { } // S3 Snow Control with bucket and with DNS -func TestEndpointCase110(t *testing.T) { +func TestEndpointCase109(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Bucket: ptr.String("bucketName"), @@ -5215,7 +5439,7 @@ func TestEndpointCase110(t *testing.T) { } // S3 Snow Control with FIPS enabled -func TestEndpointCase111(t *testing.T) { +func TestEndpointCase110(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Bucket: ptr.String("bucketName"), @@ -5237,7 +5461,7 @@ func TestEndpointCase111(t *testing.T) { } // S3 Snow Control with Dualstack enabled -func TestEndpointCase112(t *testing.T) { +func TestEndpointCase111(t *testing.T) { var params = EndpointParameters{ Region: ptr.String("snow"), Bucket: ptr.String("bucketName"), diff --git a/service/supplychain/LICENSE.txt b/service/supplychain/LICENSE.txt new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/service/supplychain/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/service/supplychain/api_client.go b/service/supplychain/api_client.go new file mode 100644 index 00000000000..83ca4d3e457 --- /dev/null +++ b/service/supplychain/api_client.go @@ -0,0 +1,491 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + cryptorand "crypto/rand" + "fmt" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/defaults" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" + internalauth "github.com/aws/aws-sdk-go-v2/internal/auth" + internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy" + internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources" + smithy "github.com/aws/smithy-go" + smithydocument "github.com/aws/smithy-go/document" + "github.com/aws/smithy-go/logging" + "github.com/aws/smithy-go/middleware" + smithyrand "github.com/aws/smithy-go/rand" + smithyhttp "github.com/aws/smithy-go/transport/http" + "net" + "net/http" + "time" +) + +const ServiceID = "SupplyChain" +const ServiceAPIVersion = "2024-01-01" + +// Client provides the API client to make operations call for AWS Supply Chain. +type Client struct { + options Options +} + +// New returns an initialized Client based on the functional options. Provide +// additional functional options to further configure the behavior of the client, +// such as changing the client's endpoint or adding custom middleware behavior. +func New(options Options, optFns ...func(*Options)) *Client { + options = options.Copy() + + resolveDefaultLogger(&options) + + setResolvedDefaultsMode(&options) + + resolveRetryer(&options) + + resolveHTTPClient(&options) + + resolveHTTPSignerV4(&options) + + resolveIdempotencyTokenProvider(&options) + + resolveEndpointResolverV2(&options) + + resolveAuthSchemeResolver(&options) + + for _, fn := range optFns { + fn(&options) + } + + finalizeRetryMaxAttempts(&options) + + ignoreAnonymousAuth(&options) + + wrapWithAnonymousAuth(&options) + + resolveAuthSchemes(&options) + + client := &Client{ + options: options, + } + + return client +} + +// Options returns a copy of the client configuration. +// +// Callers SHOULD NOT perform mutations on any inner structures within client +// config. Config overrides should instead be made on a per-operation basis through +// functional options. +func (c *Client) Options() Options { + return c.options.Copy() +} + +func (c *Client) invokeOperation(ctx context.Context, opID string, params interface{}, optFns []func(*Options), stackFns ...func(*middleware.Stack, Options) error) (result interface{}, metadata middleware.Metadata, err error) { + ctx = middleware.ClearStackValues(ctx) + stack := middleware.NewStack(opID, smithyhttp.NewStackRequest) + options := c.options.Copy() + + for _, fn := range optFns { + fn(&options) + } + + finalizeOperationRetryMaxAttempts(&options, *c) + + finalizeClientEndpointResolverOptions(&options) + + for _, fn := range stackFns { + if err := fn(stack, options); err != nil { + return nil, metadata, err + } + } + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, metadata, err + } + } + + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err = handler.Handle(ctx, params) + if err != nil { + err = &smithy.OperationError{ + ServiceID: ServiceID, + OperationName: opID, + Err: err, + } + } + return result, metadata, err +} + +type operationInputKey struct{} + +func setOperationInput(ctx context.Context, input interface{}) context.Context { + return middleware.WithStackValue(ctx, operationInputKey{}, input) +} + +func getOperationInput(ctx context.Context) interface{} { + return middleware.GetStackValue(ctx, operationInputKey{}) +} + +type setOperationInputMiddleware struct { +} + +func (*setOperationInputMiddleware) ID() string { + return "setOperationInput" +} + +func (m *setOperationInputMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + ctx = setOperationInput(ctx, in.Parameters) + return next.HandleSerialize(ctx, in) +} + +func addProtocolFinalizerMiddlewares(stack *middleware.Stack, options Options, operation string) error { + if err := stack.Finalize.Add(&resolveAuthSchemeMiddleware{operation: operation, options: options}, middleware.Before); err != nil { + return fmt.Errorf("add ResolveAuthScheme: %w", err) + } + if err := stack.Finalize.Insert(&getIdentityMiddleware{options: options}, "ResolveAuthScheme", middleware.After); err != nil { + return fmt.Errorf("add GetIdentity: %v", err) + } + if err := stack.Finalize.Insert(&resolveEndpointV2Middleware{options: options}, "GetIdentity", middleware.After); err != nil { + return fmt.Errorf("add ResolveEndpointV2: %v", err) + } + if err := stack.Finalize.Insert(&signRequestMiddleware{}, "ResolveEndpointV2", middleware.After); err != nil { + return fmt.Errorf("add Signing: %w", err) + } + return nil +} +func resolveAuthSchemeResolver(options *Options) { + if options.AuthSchemeResolver == nil { + options.AuthSchemeResolver = &defaultAuthSchemeResolver{} + } +} + +func resolveAuthSchemes(options *Options) { + if options.AuthSchemes == nil { + options.AuthSchemes = []smithyhttp.AuthScheme{ + internalauth.NewHTTPAuthScheme("aws.auth#sigv4", &internalauthsmithy.V4SignerAdapter{ + Signer: options.HTTPSignerV4, + Logger: options.Logger, + LogSigning: options.ClientLogMode.IsSigning(), + }), + } + } +} + +type noSmithyDocumentSerde = smithydocument.NoSerde + +type legacyEndpointContextSetter struct { + LegacyResolver EndpointResolver +} + +func (*legacyEndpointContextSetter) ID() string { + return "legacyEndpointContextSetter" +} + +func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + if m.LegacyResolver != nil { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true) + } + + return next.HandleInitialize(ctx, in) + +} +func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error { + return stack.Initialize.Add(&legacyEndpointContextSetter{ + LegacyResolver: o.EndpointResolver, + }, middleware.Before) +} + +func resolveDefaultLogger(o *Options) { + if o.Logger != nil { + return + } + o.Logger = logging.Nop{} +} + +func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error { + return middleware.AddSetLoggerMiddleware(stack, o.Logger) +} + +func setResolvedDefaultsMode(o *Options) { + if len(o.resolvedDefaultsMode) > 0 { + return + } + + var mode aws.DefaultsMode + mode.SetFromString(string(o.DefaultsMode)) + + if mode == aws.DefaultsModeAuto { + mode = defaults.ResolveDefaultsModeAuto(o.Region, o.RuntimeEnvironment) + } + + o.resolvedDefaultsMode = mode +} + +// NewFromConfig returns a new client from the provided config. +func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { + opts := Options{ + Region: cfg.Region, + DefaultsMode: cfg.DefaultsMode, + RuntimeEnvironment: cfg.RuntimeEnvironment, + HTTPClient: cfg.HTTPClient, + Credentials: cfg.Credentials, + APIOptions: cfg.APIOptions, + Logger: cfg.Logger, + ClientLogMode: cfg.ClientLogMode, + AppID: cfg.AppID, + } + resolveAWSRetryerProvider(cfg, &opts) + resolveAWSRetryMaxAttempts(cfg, &opts) + resolveAWSRetryMode(cfg, &opts) + resolveAWSEndpointResolver(cfg, &opts) + resolveUseDualStackEndpoint(cfg, &opts) + resolveUseFIPSEndpoint(cfg, &opts) + resolveBaseEndpoint(cfg, &opts) + return New(opts, optFns...) +} + +func resolveHTTPClient(o *Options) { + var buildable *awshttp.BuildableClient + + if o.HTTPClient != nil { + var ok bool + buildable, ok = o.HTTPClient.(*awshttp.BuildableClient) + if !ok { + return + } + } else { + buildable = awshttp.NewBuildableClient() + } + + modeConfig, err := defaults.GetModeConfiguration(o.resolvedDefaultsMode) + if err == nil { + buildable = buildable.WithDialerOptions(func(dialer *net.Dialer) { + if dialerTimeout, ok := modeConfig.GetConnectTimeout(); ok { + dialer.Timeout = dialerTimeout + } + }) + + buildable = buildable.WithTransportOptions(func(transport *http.Transport) { + if tlsHandshakeTimeout, ok := modeConfig.GetTLSNegotiationTimeout(); ok { + transport.TLSHandshakeTimeout = tlsHandshakeTimeout + } + }) + } + + o.HTTPClient = buildable +} + +func resolveRetryer(o *Options) { + if o.Retryer != nil { + return + } + + if len(o.RetryMode) == 0 { + modeConfig, err := defaults.GetModeConfiguration(o.resolvedDefaultsMode) + if err == nil { + o.RetryMode = modeConfig.RetryMode + } + } + if len(o.RetryMode) == 0 { + o.RetryMode = aws.RetryModeStandard + } + + var standardOptions []func(*retry.StandardOptions) + if v := o.RetryMaxAttempts; v != 0 { + standardOptions = append(standardOptions, func(so *retry.StandardOptions) { + so.MaxAttempts = v + }) + } + + switch o.RetryMode { + case aws.RetryModeAdaptive: + var adaptiveOptions []func(*retry.AdaptiveModeOptions) + if len(standardOptions) != 0 { + adaptiveOptions = append(adaptiveOptions, func(ao *retry.AdaptiveModeOptions) { + ao.StandardOptions = append(ao.StandardOptions, standardOptions...) + }) + } + o.Retryer = retry.NewAdaptiveMode(adaptiveOptions...) + + default: + o.Retryer = retry.NewStandard(standardOptions...) + } +} + +func resolveAWSRetryerProvider(cfg aws.Config, o *Options) { + if cfg.Retryer == nil { + return + } + o.Retryer = cfg.Retryer() +} + +func resolveAWSRetryMode(cfg aws.Config, o *Options) { + if len(cfg.RetryMode) == 0 { + return + } + o.RetryMode = cfg.RetryMode +} +func resolveAWSRetryMaxAttempts(cfg aws.Config, o *Options) { + if cfg.RetryMaxAttempts == 0 { + return + } + o.RetryMaxAttempts = cfg.RetryMaxAttempts +} + +func finalizeRetryMaxAttempts(o *Options) { + if o.RetryMaxAttempts == 0 { + return + } + + o.Retryer = retry.AddWithMaxAttempts(o.Retryer, o.RetryMaxAttempts) +} + +func finalizeOperationRetryMaxAttempts(o *Options, client Client) { + if v := o.RetryMaxAttempts; v == 0 || v == client.options.RetryMaxAttempts { + return + } + + o.Retryer = retry.AddWithMaxAttempts(o.Retryer, o.RetryMaxAttempts) +} + +func resolveAWSEndpointResolver(cfg aws.Config, o *Options) { + if cfg.EndpointResolver == nil && cfg.EndpointResolverWithOptions == nil { + return + } + o.EndpointResolver = withEndpointResolver(cfg.EndpointResolver, cfg.EndpointResolverWithOptions) +} + +func addClientUserAgent(stack *middleware.Stack, options Options) error { + if err := awsmiddleware.AddSDKAgentKeyValue(awsmiddleware.APIMetadata, "supplychain", goModuleVersion)(stack); err != nil { + return err + } + + if len(options.AppID) > 0 { + return awsmiddleware.AddSDKAgentKey(awsmiddleware.ApplicationIdentifier, options.AppID)(stack) + } + + return nil +} + +type HTTPSignerV4 interface { + SignHTTP(ctx context.Context, credentials aws.Credentials, r *http.Request, payloadHash string, service string, region string, signingTime time.Time, optFns ...func(*v4.SignerOptions)) error +} + +func resolveHTTPSignerV4(o *Options) { + if o.HTTPSignerV4 != nil { + return + } + o.HTTPSignerV4 = newDefaultV4Signer(*o) +} + +func newDefaultV4Signer(o Options) *v4.Signer { + return v4.NewSigner(func(so *v4.SignerOptions) { + so.Logger = o.Logger + so.LogSigning = o.ClientLogMode.IsSigning() + }) +} + +func resolveIdempotencyTokenProvider(o *Options) { + if o.IdempotencyTokenProvider != nil { + return + } + o.IdempotencyTokenProvider = smithyrand.NewUUIDIdempotencyToken(cryptorand.Reader) +} + +func addRetryMiddlewares(stack *middleware.Stack, o Options) error { + mo := retry.AddRetryMiddlewaresOptions{ + Retryer: o.Retryer, + LogRetryAttempts: o.ClientLogMode.IsRetries(), + } + return retry.AddRetryMiddlewares(stack, mo) +} + +// resolves dual-stack endpoint configuration +func resolveUseDualStackEndpoint(cfg aws.Config, o *Options) error { + if len(cfg.ConfigSources) == 0 { + return nil + } + value, found, err := internalConfig.ResolveUseDualStackEndpoint(context.Background(), cfg.ConfigSources) + if err != nil { + return err + } + if found { + o.EndpointOptions.UseDualStackEndpoint = value + } + return nil +} + +// resolves FIPS endpoint configuration +func resolveUseFIPSEndpoint(cfg aws.Config, o *Options) error { + if len(cfg.ConfigSources) == 0 { + return nil + } + value, found, err := internalConfig.ResolveUseFIPSEndpoint(context.Background(), cfg.ConfigSources) + if err != nil { + return err + } + if found { + o.EndpointOptions.UseFIPSEndpoint = value + } + return nil +} + +// IdempotencyTokenProvider interface for providing idempotency token +type IdempotencyTokenProvider interface { + GetIdempotencyToken() (string, error) +} + +func addRequestIDRetrieverMiddleware(stack *middleware.Stack) error { + return awsmiddleware.AddRequestIDRetrieverMiddleware(stack) +} + +func addResponseErrorMiddleware(stack *middleware.Stack) error { + return awshttp.AddResponseErrorMiddleware(stack) +} + +func addRequestResponseLogging(stack *middleware.Stack, o Options) error { + return stack.Deserialize.Add(&smithyhttp.RequestResponseLogger{ + LogRequest: o.ClientLogMode.IsRequest(), + LogRequestWithBody: o.ClientLogMode.IsRequestWithBody(), + LogResponse: o.ClientLogMode.IsResponse(), + LogResponseWithBody: o.ClientLogMode.IsResponseWithBody(), + }, middleware.After) +} + +type disableHTTPSMiddleware struct { + DisableHTTPS bool +} + +func (*disableHTTPSMiddleware) ID() string { + return "disableHTTPS" +} + +func (m *disableHTTPSMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + req, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) + } + + if m.DisableHTTPS && !smithyhttp.GetHostnameImmutable(ctx) { + req.URL.Scheme = "http" + } + + return next.HandleFinalize(ctx, in) +} + +func addDisableHTTPSMiddleware(stack *middleware.Stack, o Options) error { + return stack.Finalize.Insert(&disableHTTPSMiddleware{ + DisableHTTPS: o.EndpointOptions.DisableHTTPS, + }, "ResolveEndpointV2", middleware.After) +} diff --git a/service/supplychain/api_client_test.go b/service/supplychain/api_client_test.go new file mode 100644 index 00000000000..60746e757ed --- /dev/null +++ b/service/supplychain/api_client_test.go @@ -0,0 +1,127 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" + "io/ioutil" + "net/http" + "strings" + "testing" +) + +func TestClient_resolveRetryOptions(t *testing.T) { + nopClient := smithyhttp.ClientDoFunc(func(_ *http.Request) (*http.Response, error) { + return &http.Response{ + StatusCode: 200, + Header: http.Header{}, + Body: ioutil.NopCloser(strings.NewReader("")), + }, nil + }) + + cases := map[string]struct { + defaultsMode aws.DefaultsMode + retryer aws.Retryer + retryMaxAttempts int + opRetryMaxAttempts *int + retryMode aws.RetryMode + expectClientRetryMode aws.RetryMode + expectClientMaxAttempts int + expectOpMaxAttempts int + }{ + "defaults": { + defaultsMode: aws.DefaultsModeStandard, + expectClientRetryMode: aws.RetryModeStandard, + expectClientMaxAttempts: 3, + expectOpMaxAttempts: 3, + }, + "custom default retry": { + retryMode: aws.RetryModeAdaptive, + retryMaxAttempts: 10, + expectClientRetryMode: aws.RetryModeAdaptive, + expectClientMaxAttempts: 10, + expectOpMaxAttempts: 10, + }, + "custom op max attempts": { + retryMode: aws.RetryModeAdaptive, + retryMaxAttempts: 10, + opRetryMaxAttempts: aws.Int(2), + expectClientRetryMode: aws.RetryModeAdaptive, + expectClientMaxAttempts: 10, + expectOpMaxAttempts: 2, + }, + "custom op no change max attempts": { + retryMode: aws.RetryModeAdaptive, + retryMaxAttempts: 10, + opRetryMaxAttempts: aws.Int(10), + expectClientRetryMode: aws.RetryModeAdaptive, + expectClientMaxAttempts: 10, + expectOpMaxAttempts: 10, + }, + "custom op 0 max attempts": { + retryMode: aws.RetryModeAdaptive, + retryMaxAttempts: 10, + opRetryMaxAttempts: aws.Int(0), + expectClientRetryMode: aws.RetryModeAdaptive, + expectClientMaxAttempts: 10, + expectOpMaxAttempts: 10, + }, + } + + for name, c := range cases { + t.Run(name, func(t *testing.T) { + client := NewFromConfig(aws.Config{ + DefaultsMode: c.defaultsMode, + Retryer: func() func() aws.Retryer { + if c.retryer == nil { + return nil + } + + return func() aws.Retryer { return c.retryer } + }(), + HTTPClient: nopClient, + RetryMaxAttempts: c.retryMaxAttempts, + RetryMode: c.retryMode, + }, func(o *Options) { + if o.Retryer == nil { + t.Errorf("retryer must not be nil in functional options") + } + }) + + if e, a := c.expectClientRetryMode, client.options.RetryMode; e != a { + t.Errorf("expect %v retry mode, got %v", e, a) + } + if e, a := c.expectClientMaxAttempts, client.options.Retryer.MaxAttempts(); e != a { + t.Errorf("expect %v max attempts, got %v", e, a) + } + + _, _, err := client.invokeOperation(context.Background(), "mockOperation", struct{}{}, + []func(*Options){ + func(o *Options) { + if c.opRetryMaxAttempts == nil { + return + } + o.RetryMaxAttempts = *c.opRetryMaxAttempts + }, + }, + func(s *middleware.Stack, o Options) error { + s.Initialize.Clear() + s.Serialize.Clear() + s.Build.Clear() + s.Finalize.Clear() + s.Deserialize.Clear() + + if e, a := c.expectOpMaxAttempts, o.Retryer.MaxAttempts(); e != a { + t.Errorf("expect %v op max attempts, got %v", e, a) + } + return nil + }) + if err != nil { + t.Fatalf("expect no operation error, got %v", err) + } + }) + } +} diff --git a/service/supplychain/api_op_CreateBillOfMaterialsImportJob.go b/service/supplychain/api_op_CreateBillOfMaterialsImportJob.go new file mode 100644 index 00000000000..95f75d8cc1a --- /dev/null +++ b/service/supplychain/api_op_CreateBillOfMaterialsImportJob.go @@ -0,0 +1,189 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "fmt" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +// CreateBillOfMaterialsImportJob creates an import job for the Product Bill Of +// Materials (BOM) entity. For information on the product_bom entity, see the AWS +// Supply Chain User Guide. The CSV file must be located in an Amazon S3 location +// accessible to AWS Supply Chain. It is recommended to use the same Amazon S3 +// bucket created during your AWS Supply Chain instance creation. +func (c *Client) CreateBillOfMaterialsImportJob(ctx context.Context, params *CreateBillOfMaterialsImportJobInput, optFns ...func(*Options)) (*CreateBillOfMaterialsImportJobOutput, error) { + if params == nil { + params = &CreateBillOfMaterialsImportJobInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "CreateBillOfMaterialsImportJob", params, optFns, c.addOperationCreateBillOfMaterialsImportJobMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*CreateBillOfMaterialsImportJobOutput) + out.ResultMetadata = metadata + return out, nil +} + +// The request parameters for CreateBillOfMaterialsImportJob. +type CreateBillOfMaterialsImportJobInput struct { + + // The AWS Supply Chain instance identifier. + // + // This member is required. + InstanceId *string + + // The S3 URI of the CSV file to be imported. The bucket must grant permissions + // for AWS Supply Chain to read the file. + // + // This member is required. + S3uri *string + + // An idempotency token. + ClientToken *string + + noSmithyDocumentSerde +} + +// The response parameters of CreateBillOfMaterialsImportJob. +type CreateBillOfMaterialsImportJobOutput struct { + + // The new BillOfMaterialsImportJob identifier. + // + // This member is required. + JobId *string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationCreateBillOfMaterialsImportJobMiddlewares(stack *middleware.Stack, options Options) (err error) { + if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil { + return err + } + err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateBillOfMaterialsImportJob{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateBillOfMaterialsImportJob{}, middleware.After) + if err != nil { + return err + } + if err := addProtocolFinalizerMiddlewares(stack, options, "CreateBillOfMaterialsImportJob"); err != nil { + return fmt.Errorf("add protocol finalizers: %v", err) + } + + if err = addlegacyEndpointContextSetter(stack, options); err != nil { + return err + } + if err = addSetLoggerMiddleware(stack, options); err != nil { + return err + } + if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { + return err + } + if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { + return err + } + if err = addRetryMiddlewares(stack, options); err != nil { + return err + } + if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { + return err + } + if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { + return err + } + if err = addClientUserAgent(stack, options); err != nil { + return err + } + if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { + return err + } + if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + return err + } + if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil { + return err + } + if err = addIdempotencyToken_opCreateBillOfMaterialsImportJobMiddleware(stack, options); err != nil { + return err + } + if err = addOpCreateBillOfMaterialsImportJobValidationMiddleware(stack); err != nil { + return err + } + if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateBillOfMaterialsImportJob(options.Region), middleware.Before); err != nil { + return err + } + if err = awsmiddleware.AddRecursionDetection(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + return nil +} + +type idempotencyToken_initializeOpCreateBillOfMaterialsImportJob struct { + tokenProvider IdempotencyTokenProvider +} + +func (*idempotencyToken_initializeOpCreateBillOfMaterialsImportJob) ID() string { + return "OperationIdempotencyTokenAutoFill" +} + +func (m *idempotencyToken_initializeOpCreateBillOfMaterialsImportJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + if m.tokenProvider == nil { + return next.HandleInitialize(ctx, in) + } + + input, ok := in.Parameters.(*CreateBillOfMaterialsImportJobInput) + if !ok { + return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateBillOfMaterialsImportJobInput ") + } + + if input.ClientToken == nil { + t, err := m.tokenProvider.GetIdempotencyToken() + if err != nil { + return out, metadata, err + } + input.ClientToken = &t + } + return next.HandleInitialize(ctx, in) +} +func addIdempotencyToken_opCreateBillOfMaterialsImportJobMiddleware(stack *middleware.Stack, cfg Options) error { + return stack.Initialize.Add(&idempotencyToken_initializeOpCreateBillOfMaterialsImportJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) +} + +func newServiceMetadataMiddleware_opCreateBillOfMaterialsImportJob(region string) *awsmiddleware.RegisterServiceMetadata { + return &awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceID: ServiceID, + OperationName: "CreateBillOfMaterialsImportJob", + } +} diff --git a/service/supplychain/api_op_GetBillOfMaterialsImportJob.go b/service/supplychain/api_op_GetBillOfMaterialsImportJob.go new file mode 100644 index 00000000000..dccdff6f28a --- /dev/null +++ b/service/supplychain/api_op_GetBillOfMaterialsImportJob.go @@ -0,0 +1,146 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "fmt" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + "github.com/aws/aws-sdk-go-v2/service/supplychain/types" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +// Get status and details of a BillOfMaterialsImportJob. +func (c *Client) GetBillOfMaterialsImportJob(ctx context.Context, params *GetBillOfMaterialsImportJobInput, optFns ...func(*Options)) (*GetBillOfMaterialsImportJobOutput, error) { + if params == nil { + params = &GetBillOfMaterialsImportJobInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "GetBillOfMaterialsImportJob", params, optFns, c.addOperationGetBillOfMaterialsImportJobMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*GetBillOfMaterialsImportJobOutput) + out.ResultMetadata = metadata + return out, nil +} + +// The request parameters for GetBillOfMaterialsImportJob. +type GetBillOfMaterialsImportJobInput struct { + + // The AWS Supply Chain instance identifier. + // + // This member is required. + InstanceId *string + + // The BillOfMaterialsImportJob identifier. + // + // This member is required. + JobId *string + + noSmithyDocumentSerde +} + +// The response parameters for GetBillOfMaterialsImportJob. +type GetBillOfMaterialsImportJobOutput struct { + + // The BillOfMaterialsImportJob. + // + // This member is required. + Job *types.BillOfMaterialsImportJob + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (c *Client) addOperationGetBillOfMaterialsImportJobMiddlewares(stack *middleware.Stack, options Options) (err error) { + if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil { + return err + } + err = stack.Serialize.Add(&awsRestjson1_serializeOpGetBillOfMaterialsImportJob{}, middleware.After) + if err != nil { + return err + } + err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetBillOfMaterialsImportJob{}, middleware.After) + if err != nil { + return err + } + if err := addProtocolFinalizerMiddlewares(stack, options, "GetBillOfMaterialsImportJob"); err != nil { + return fmt.Errorf("add protocol finalizers: %v", err) + } + + if err = addlegacyEndpointContextSetter(stack, options); err != nil { + return err + } + if err = addSetLoggerMiddleware(stack, options); err != nil { + return err + } + if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { + return err + } + if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { + return err + } + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { + return err + } + if err = addRetryMiddlewares(stack, options); err != nil { + return err + } + if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { + return err + } + if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { + return err + } + if err = addClientUserAgent(stack, options); err != nil { + return err + } + if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { + return err + } + if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + return err + } + if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil { + return err + } + if err = addOpGetBillOfMaterialsImportJobValidationMiddleware(stack); err != nil { + return err + } + if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBillOfMaterialsImportJob(options.Region), middleware.Before); err != nil { + return err + } + if err = awsmiddleware.AddRecursionDetection(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + return nil +} + +func newServiceMetadataMiddleware_opGetBillOfMaterialsImportJob(region string) *awsmiddleware.RegisterServiceMetadata { + return &awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceID: ServiceID, + OperationName: "GetBillOfMaterialsImportJob", + } +} diff --git a/service/supplychain/auth.go b/service/supplychain/auth.go new file mode 100644 index 00000000000..dd9c57b6702 --- /dev/null +++ b/service/supplychain/auth.go @@ -0,0 +1,284 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "fmt" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + smithy "github.com/aws/smithy-go" + smithyauth "github.com/aws/smithy-go/auth" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +func bindAuthParamsRegion(params *AuthResolverParameters, _ interface{}, options Options) { + params.Region = options.Region +} + +type setLegacyContextSigningOptionsMiddleware struct { +} + +func (*setLegacyContextSigningOptionsMiddleware) ID() string { + return "setLegacyContextSigningOptions" +} + +func (m *setLegacyContextSigningOptionsMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + rscheme := getResolvedAuthScheme(ctx) + schemeID := rscheme.Scheme.SchemeID() + + if sn := awsmiddleware.GetSigningName(ctx); sn != "" { + if schemeID == "aws.auth#sigv4" { + smithyhttp.SetSigV4SigningName(&rscheme.SignerProperties, sn) + } else if schemeID == "aws.auth#sigv4a" { + smithyhttp.SetSigV4ASigningName(&rscheme.SignerProperties, sn) + } + } + + if sr := awsmiddleware.GetSigningRegion(ctx); sr != "" { + if schemeID == "aws.auth#sigv4" { + smithyhttp.SetSigV4SigningRegion(&rscheme.SignerProperties, sr) + } else if schemeID == "aws.auth#sigv4a" { + smithyhttp.SetSigV4ASigningRegions(&rscheme.SignerProperties, []string{sr}) + } + } + + return next.HandleFinalize(ctx, in) +} + +func addSetLegacyContextSigningOptionsMiddleware(stack *middleware.Stack) error { + return stack.Finalize.Insert(&setLegacyContextSigningOptionsMiddleware{}, "Signing", middleware.Before) +} + +type withAnonymous struct { + resolver AuthSchemeResolver +} + +var _ AuthSchemeResolver = (*withAnonymous)(nil) + +func (v *withAnonymous) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) { + opts, err := v.resolver.ResolveAuthSchemes(ctx, params) + if err != nil { + return nil, err + } + + opts = append(opts, &smithyauth.Option{ + SchemeID: smithyauth.SchemeIDAnonymous, + }) + return opts, nil +} + +func wrapWithAnonymousAuth(options *Options) { + if _, ok := options.AuthSchemeResolver.(*defaultAuthSchemeResolver); !ok { + return + } + + options.AuthSchemeResolver = &withAnonymous{ + resolver: options.AuthSchemeResolver, + } +} + +// AuthResolverParameters contains the set of inputs necessary for auth scheme +// resolution. +type AuthResolverParameters struct { + // The name of the operation being invoked. + Operation string + + // The region in which the operation is being invoked. + Region string +} + +func bindAuthResolverParams(operation string, input interface{}, options Options) *AuthResolverParameters { + params := &AuthResolverParameters{ + Operation: operation, + } + + bindAuthParamsRegion(params, input, options) + + return params +} + +// AuthSchemeResolver returns a set of possible authentication options for an +// operation. +type AuthSchemeResolver interface { + ResolveAuthSchemes(context.Context, *AuthResolverParameters) ([]*smithyauth.Option, error) +} + +type defaultAuthSchemeResolver struct{} + +var _ AuthSchemeResolver = (*defaultAuthSchemeResolver)(nil) + +func (*defaultAuthSchemeResolver) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) { + if overrides, ok := operationAuthOptions[params.Operation]; ok { + return overrides(params), nil + } + return serviceAuthOptions(params), nil +} + +var operationAuthOptions = map[string]func(*AuthResolverParameters) []*smithyauth.Option{} + +func serviceAuthOptions(params *AuthResolverParameters) []*smithyauth.Option { + return []*smithyauth.Option{ + { + SchemeID: smithyauth.SchemeIDSigV4, + SignerProperties: func() smithy.Properties { + var props smithy.Properties + smithyhttp.SetSigV4SigningName(&props, "scn") + smithyhttp.SetSigV4SigningRegion(&props, params.Region) + return props + }(), + }, + } +} + +type resolveAuthSchemeMiddleware struct { + operation string + options Options +} + +func (*resolveAuthSchemeMiddleware) ID() string { + return "ResolveAuthScheme" +} + +func (m *resolveAuthSchemeMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + params := bindAuthResolverParams(m.operation, getOperationInput(ctx), m.options) + options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params) + if err != nil { + return out, metadata, fmt.Errorf("resolve auth scheme: %w", err) + } + + scheme, ok := m.selectScheme(options) + if !ok { + return out, metadata, fmt.Errorf("could not select an auth scheme") + } + + ctx = setResolvedAuthScheme(ctx, scheme) + return next.HandleFinalize(ctx, in) +} + +func (m *resolveAuthSchemeMiddleware) selectScheme(options []*smithyauth.Option) (*resolvedAuthScheme, bool) { + for _, option := range options { + if option.SchemeID == smithyauth.SchemeIDAnonymous { + return newResolvedAuthScheme(smithyhttp.NewAnonymousScheme(), option), true + } + + for _, scheme := range m.options.AuthSchemes { + if scheme.SchemeID() != option.SchemeID { + continue + } + + if scheme.IdentityResolver(m.options) != nil { + return newResolvedAuthScheme(scheme, option), true + } + } + } + + return nil, false +} + +type resolvedAuthSchemeKey struct{} + +type resolvedAuthScheme struct { + Scheme smithyhttp.AuthScheme + IdentityProperties smithy.Properties + SignerProperties smithy.Properties +} + +func newResolvedAuthScheme(scheme smithyhttp.AuthScheme, option *smithyauth.Option) *resolvedAuthScheme { + return &resolvedAuthScheme{ + Scheme: scheme, + IdentityProperties: option.IdentityProperties, + SignerProperties: option.SignerProperties, + } +} + +func setResolvedAuthScheme(ctx context.Context, scheme *resolvedAuthScheme) context.Context { + return middleware.WithStackValue(ctx, resolvedAuthSchemeKey{}, scheme) +} + +func getResolvedAuthScheme(ctx context.Context) *resolvedAuthScheme { + v, _ := middleware.GetStackValue(ctx, resolvedAuthSchemeKey{}).(*resolvedAuthScheme) + return v +} + +type getIdentityMiddleware struct { + options Options +} + +func (*getIdentityMiddleware) ID() string { + return "GetIdentity" +} + +func (m *getIdentityMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + rscheme := getResolvedAuthScheme(ctx) + if rscheme == nil { + return out, metadata, fmt.Errorf("no resolved auth scheme") + } + + resolver := rscheme.Scheme.IdentityResolver(m.options) + if resolver == nil { + return out, metadata, fmt.Errorf("no identity resolver") + } + + identity, err := resolver.GetIdentity(ctx, rscheme.IdentityProperties) + if err != nil { + return out, metadata, fmt.Errorf("get identity: %w", err) + } + + ctx = setIdentity(ctx, identity) + return next.HandleFinalize(ctx, in) +} + +type identityKey struct{} + +func setIdentity(ctx context.Context, identity smithyauth.Identity) context.Context { + return middleware.WithStackValue(ctx, identityKey{}, identity) +} + +func getIdentity(ctx context.Context) smithyauth.Identity { + v, _ := middleware.GetStackValue(ctx, identityKey{}).(smithyauth.Identity) + return v +} + +type signRequestMiddleware struct { +} + +func (*signRequestMiddleware) ID() string { + return "Signing" +} + +func (m *signRequestMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + req, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, fmt.Errorf("unexpected transport type %T", in.Request) + } + + rscheme := getResolvedAuthScheme(ctx) + if rscheme == nil { + return out, metadata, fmt.Errorf("no resolved auth scheme") + } + + identity := getIdentity(ctx) + if identity == nil { + return out, metadata, fmt.Errorf("no identity") + } + + signer := rscheme.Scheme.Signer() + if signer == nil { + return out, metadata, fmt.Errorf("no signer") + } + + if err := signer.SignRequest(ctx, req, identity, rscheme.SignerProperties); err != nil { + return out, metadata, fmt.Errorf("sign request: %w", err) + } + + return next.HandleFinalize(ctx, in) +} diff --git a/service/supplychain/deserializers.go b/service/supplychain/deserializers.go new file mode 100644 index 00000000000..a7798829890 --- /dev/null +++ b/service/supplychain/deserializers.go @@ -0,0 +1,961 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" + "github.com/aws/aws-sdk-go-v2/service/supplychain/types" + smithy "github.com/aws/smithy-go" + smithyio "github.com/aws/smithy-go/io" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" + smithyhttp "github.com/aws/smithy-go/transport/http" + "io" + "strings" +) + +type awsRestjson1_deserializeOpCreateBillOfMaterialsImportJob struct { +} + +func (*awsRestjson1_deserializeOpCreateBillOfMaterialsImportJob) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpCreateBillOfMaterialsImportJob) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorCreateBillOfMaterialsImportJob(response, &metadata) + } + output := &CreateBillOfMaterialsImportJobOutput{} + out.Result = output + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(response.Body, ringBuffer) + + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return out, metadata, err + } + + err = awsRestjson1_deserializeOpDocumentCreateBillOfMaterialsImportJobOutput(&output, shape) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorCreateBillOfMaterialsImportJob(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + if len(headerCode) != 0 { + errorCode = restjson.SanitizeErrorCode(headerCode) + } + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + jsonCode, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if len(headerCode) == 0 && len(jsonCode) != 0 { + errorCode = restjson.SanitizeErrorCode(jsonCode) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("AccessDeniedException", errorCode): + return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + + case strings.EqualFold("ConflictException", errorCode): + return awsRestjson1_deserializeErrorConflictException(response, errorBody) + + case strings.EqualFold("InternalServerException", errorCode): + return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) + + case strings.EqualFold("ResourceNotFoundException", errorCode): + return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody) + + case strings.EqualFold("ServiceQuotaExceededException", errorCode): + return awsRestjson1_deserializeErrorServiceQuotaExceededException(response, errorBody) + + case strings.EqualFold("ThrottlingException", errorCode): + return awsRestjson1_deserializeErrorThrottlingException(response, errorBody) + + case strings.EqualFold("ValidationException", errorCode): + return awsRestjson1_deserializeErrorValidationException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeOpDocumentCreateBillOfMaterialsImportJobOutput(v **CreateBillOfMaterialsImportJobOutput, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *CreateBillOfMaterialsImportJobOutput + if *v == nil { + sv = &CreateBillOfMaterialsImportJobOutput{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "jobId": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected UUID to be of type string, got %T instead", value) + } + sv.JobId = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +type awsRestjson1_deserializeOpGetBillOfMaterialsImportJob struct { +} + +func (*awsRestjson1_deserializeOpGetBillOfMaterialsImportJob) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpGetBillOfMaterialsImportJob) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorGetBillOfMaterialsImportJob(response, &metadata) + } + output := &GetBillOfMaterialsImportJobOutput{} + out.Result = output + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(response.Body, ringBuffer) + + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return out, metadata, err + } + + err = awsRestjson1_deserializeOpDocumentGetBillOfMaterialsImportJobOutput(&output, shape) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorGetBillOfMaterialsImportJob(response *smithyhttp.Response, metadata *middleware.Metadata) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + headerCode := response.Header.Get("X-Amzn-ErrorType") + if len(headerCode) != 0 { + errorCode = restjson.SanitizeErrorCode(headerCode) + } + + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + jsonCode, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + if len(headerCode) == 0 && len(jsonCode) != 0 { + errorCode = restjson.SanitizeErrorCode(jsonCode) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("AccessDeniedException", errorCode): + return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) + + case strings.EqualFold("ConflictException", errorCode): + return awsRestjson1_deserializeErrorConflictException(response, errorBody) + + case strings.EqualFold("InternalServerException", errorCode): + return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) + + case strings.EqualFold("ResourceNotFoundException", errorCode): + return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody) + + case strings.EqualFold("ServiceQuotaExceededException", errorCode): + return awsRestjson1_deserializeErrorServiceQuotaExceededException(response, errorBody) + + case strings.EqualFold("ThrottlingException", errorCode): + return awsRestjson1_deserializeErrorThrottlingException(response, errorBody) + + case strings.EqualFold("ValidationException", errorCode): + return awsRestjson1_deserializeErrorValidationException(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeOpDocumentGetBillOfMaterialsImportJobOutput(v **GetBillOfMaterialsImportJobOutput, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *GetBillOfMaterialsImportJobOutput + if *v == nil { + sv = &GetBillOfMaterialsImportJobOutput{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "job": + if err := awsRestjson1_deserializeDocumentBillOfMaterialsImportJob(&sv.Job, value); err != nil { + return err + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeErrorAccessDeniedException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.AccessDeniedException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentAccessDeniedException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorConflictException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.ConflictException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentConflictException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorInternalServerException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.InternalServerException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentInternalServerException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorResourceNotFoundException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.ResourceNotFoundException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentResourceNotFoundException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorServiceQuotaExceededException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.ServiceQuotaExceededException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentServiceQuotaExceededException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorThrottlingException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.ThrottlingException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentThrottlingException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeErrorValidationException(response *smithyhttp.Response, errorBody *bytes.Reader) error { + output := &types.ValidationException{} + var buff [1024]byte + ringBuffer := smithyio.NewRingBuffer(buff[:]) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + var shape interface{} + if err := decoder.Decode(&shape); err != nil && err != io.EOF { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + err := awsRestjson1_deserializeDocumentValidationException(&output, shape) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + err = &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + return err + } + + errorBody.Seek(0, io.SeekStart) + + return output +} + +func awsRestjson1_deserializeDocumentAccessDeniedException(v **types.AccessDeniedException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.AccessDeniedException + if *v == nil { + sv = &types.AccessDeniedException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentBillOfMaterialsImportJob(v **types.BillOfMaterialsImportJob, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.BillOfMaterialsImportJob + if *v == nil { + sv = &types.BillOfMaterialsImportJob{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "instanceId": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected UUID to be of type string, got %T instead", value) + } + sv.InstanceId = ptr.String(jtv) + } + + case "jobId": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected UUID to be of type string, got %T instead", value) + } + sv.JobId = ptr.String(jtv) + } + + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + case "s3uri": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ConfigurationS3Uri to be of type string, got %T instead", value) + } + sv.S3uri = ptr.String(jtv) + } + + case "status": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ConfigurationJobStatus to be of type string, got %T instead", value) + } + sv.Status = types.ConfigurationJobStatus(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentConflictException(v **types.ConflictException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.ConflictException + if *v == nil { + sv = &types.ConflictException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentInternalServerException(v **types.InternalServerException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.InternalServerException + if *v == nil { + sv = &types.InternalServerException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentResourceNotFoundException(v **types.ResourceNotFoundException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.ResourceNotFoundException + if *v == nil { + sv = &types.ResourceNotFoundException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentServiceQuotaExceededException(v **types.ServiceQuotaExceededException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.ServiceQuotaExceededException + if *v == nil { + sv = &types.ServiceQuotaExceededException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentThrottlingException(v **types.ThrottlingException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.ThrottlingException + if *v == nil { + sv = &types.ThrottlingException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} + +func awsRestjson1_deserializeDocumentValidationException(v **types.ValidationException, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var sv *types.ValidationException + if *v == nil { + sv = &types.ValidationException{} + } else { + sv = *v + } + + for key, value := range shape { + switch key { + case "message": + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", value) + } + sv.Message = ptr.String(jtv) + } + + default: + _, _ = key, value + + } + } + *v = sv + return nil +} diff --git a/service/supplychain/doc.go b/service/supplychain/doc.go new file mode 100644 index 00000000000..f8f06d87c60 --- /dev/null +++ b/service/supplychain/doc.go @@ -0,0 +1,15 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +// Package supplychain provides the API client, operations, and parameter types +// for AWS Supply Chain. +// +// AWS Supply Chain is a cloud-based application that works with your enterprise +// resource planning (ERP) and supply chain management systems. Using AWS Supply +// Chain, you can connect and extract your inventory, supply, and demand related +// data from existing ERP or supply chain systems into a single data model. The AWS +// Supply Chain API supports configuration data import for Supply Planning. All AWS +// Supply chain API operations are Amazon-authenticated and certificate-signed. +// They not only require the use of the AWS SDK, but also allow for the exclusive +// use of AWS Identity and Access Management users and roles to help facilitate +// access, trust, and permission policies. +package supplychain diff --git a/service/supplychain/endpoints.go b/service/supplychain/endpoints.go new file mode 100644 index 00000000000..b8e7fc27f5d --- /dev/null +++ b/service/supplychain/endpoints.go @@ -0,0 +1,509 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "errors" + "fmt" + "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources" + "github.com/aws/aws-sdk-go-v2/internal/endpoints" + "github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn" + internalendpoints "github.com/aws/aws-sdk-go-v2/service/supplychain/internal/endpoints" + smithyauth "github.com/aws/smithy-go/auth" + smithyendpoints "github.com/aws/smithy-go/endpoints" + "github.com/aws/smithy-go/middleware" + "github.com/aws/smithy-go/ptr" + smithyhttp "github.com/aws/smithy-go/transport/http" + "net/http" + "net/url" + "os" + "strings" +) + +// EndpointResolverOptions is the service endpoint resolver options +type EndpointResolverOptions = internalendpoints.Options + +// EndpointResolver interface for resolving service endpoints. +type EndpointResolver interface { + ResolveEndpoint(region string, options EndpointResolverOptions) (aws.Endpoint, error) +} + +var _ EndpointResolver = &internalendpoints.Resolver{} + +// NewDefaultEndpointResolver constructs a new service endpoint resolver +func NewDefaultEndpointResolver() *internalendpoints.Resolver { + return internalendpoints.New() +} + +// EndpointResolverFunc is a helper utility that wraps a function so it satisfies +// the EndpointResolver interface. This is useful when you want to add additional +// endpoint resolving logic, or stub out specific endpoints with custom values. +type EndpointResolverFunc func(region string, options EndpointResolverOptions) (aws.Endpoint, error) + +func (fn EndpointResolverFunc) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) { + return fn(region, options) +} + +// EndpointResolverFromURL returns an EndpointResolver configured using the +// provided endpoint url. By default, the resolved endpoint resolver uses the +// client region as signing region, and the endpoint source is set to +// EndpointSourceCustom.You can provide functional options to configure endpoint +// values for the resolved endpoint. +func EndpointResolverFromURL(url string, optFns ...func(*aws.Endpoint)) EndpointResolver { + e := aws.Endpoint{URL: url, Source: aws.EndpointSourceCustom} + for _, fn := range optFns { + fn(&e) + } + + return EndpointResolverFunc( + func(region string, options EndpointResolverOptions) (aws.Endpoint, error) { + if len(e.SigningRegion) == 0 { + e.SigningRegion = region + } + return e, nil + }, + ) +} + +type ResolveEndpoint struct { + Resolver EndpointResolver + Options EndpointResolverOptions +} + +func (*ResolveEndpoint) ID() string { + return "ResolveEndpoint" +} + +func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + if !awsmiddleware.GetRequiresLegacyEndpoints(ctx) { + return next.HandleSerialize(ctx, in) + } + + req, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) + } + + if m.Resolver == nil { + return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil") + } + + eo := m.Options + eo.Logger = middleware.GetLogger(ctx) + + var endpoint aws.Endpoint + endpoint, err = m.Resolver.ResolveEndpoint(awsmiddleware.GetRegion(ctx), eo) + if err != nil { + nf := (&aws.EndpointNotFoundError{}) + if errors.As(err, &nf) { + ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, false) + return next.HandleSerialize(ctx, in) + } + return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err) + } + + req.URL, err = url.Parse(endpoint.URL) + if err != nil { + return out, metadata, fmt.Errorf("failed to parse endpoint URL: %w", err) + } + + if len(awsmiddleware.GetSigningName(ctx)) == 0 { + signingName := endpoint.SigningName + if len(signingName) == 0 { + signingName = "scn" + } + ctx = awsmiddleware.SetSigningName(ctx, signingName) + } + ctx = awsmiddleware.SetEndpointSource(ctx, endpoint.Source) + ctx = smithyhttp.SetHostnameImmutable(ctx, endpoint.HostnameImmutable) + ctx = awsmiddleware.SetSigningRegion(ctx, endpoint.SigningRegion) + ctx = awsmiddleware.SetPartitionID(ctx, endpoint.PartitionID) + return next.HandleSerialize(ctx, in) +} +func addResolveEndpointMiddleware(stack *middleware.Stack, o Options) error { + return stack.Serialize.Insert(&ResolveEndpoint{ + Resolver: o.EndpointResolver, + Options: o.EndpointOptions, + }, "OperationSerializer", middleware.Before) +} + +func removeResolveEndpointMiddleware(stack *middleware.Stack) error { + _, err := stack.Serialize.Remove((&ResolveEndpoint{}).ID()) + return err +} + +type wrappedEndpointResolver struct { + awsResolver aws.EndpointResolverWithOptions +} + +func (w *wrappedEndpointResolver) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) { + return w.awsResolver.ResolveEndpoint(ServiceID, region, options) +} + +type awsEndpointResolverAdaptor func(service, region string) (aws.Endpoint, error) + +func (a awsEndpointResolverAdaptor) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) { + return a(service, region) +} + +var _ aws.EndpointResolverWithOptions = awsEndpointResolverAdaptor(nil) + +// withEndpointResolver returns an aws.EndpointResolverWithOptions that first delegates endpoint resolution to the awsResolver. +// If awsResolver returns aws.EndpointNotFoundError error, the v1 resolver middleware will swallow the error, +// and set an appropriate context flag such that fallback will occur when EndpointResolverV2 is invoked +// via its middleware. +// +// If another error (besides aws.EndpointNotFoundError) is returned, then that error will be propagated. +func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptions aws.EndpointResolverWithOptions) EndpointResolver { + var resolver aws.EndpointResolverWithOptions + + if awsResolverWithOptions != nil { + resolver = awsResolverWithOptions + } else if awsResolver != nil { + resolver = awsEndpointResolverAdaptor(awsResolver.ResolveEndpoint) + } + + return &wrappedEndpointResolver{ + awsResolver: resolver, + } +} + +func finalizeClientEndpointResolverOptions(options *Options) { + options.EndpointOptions.LogDeprecated = options.ClientLogMode.IsDeprecatedUsage() + + if len(options.EndpointOptions.ResolvedRegion) == 0 { + const fipsInfix = "-fips-" + const fipsPrefix = "fips-" + const fipsSuffix = "-fips" + + if strings.Contains(options.Region, fipsInfix) || + strings.Contains(options.Region, fipsPrefix) || + strings.Contains(options.Region, fipsSuffix) { + options.EndpointOptions.ResolvedRegion = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll( + options.Region, fipsInfix, "-"), fipsPrefix, ""), fipsSuffix, "") + options.EndpointOptions.UseFIPSEndpoint = aws.FIPSEndpointStateEnabled + } + } + +} + +func resolveEndpointResolverV2(options *Options) { + if options.EndpointResolverV2 == nil { + options.EndpointResolverV2 = NewDefaultEndpointResolverV2() + } +} + +func resolveBaseEndpoint(cfg aws.Config, o *Options) { + if cfg.BaseEndpoint != nil { + o.BaseEndpoint = cfg.BaseEndpoint + } + + _, g := os.LookupEnv("AWS_ENDPOINT_URL") + _, s := os.LookupEnv("AWS_ENDPOINT_URL_SUPPLYCHAIN") + + if g && !s { + return + } + + value, found, err := internalConfig.ResolveServiceBaseEndpoint(context.Background(), "SupplyChain", cfg.ConfigSources) + if found && err == nil { + o.BaseEndpoint = &value + } +} + +// EndpointParameters provides the parameters that influence how endpoints are +// resolved. +type EndpointParameters struct { + // The AWS region used to dispatch the request. + // + // Parameter is + // required. + // + // AWS::Region + Region *string + + // When true, use the dual-stack endpoint. If the configured endpoint does not + // support dual-stack, dispatching the request MAY return an error. + // + // Defaults to + // false if no value is provided. + // + // AWS::UseDualStack + UseDualStack *bool + + // When true, send this request to the FIPS-compliant regional endpoint. If the + // configured endpoint does not have a FIPS compliant endpoint, dispatching the + // request will return an error. + // + // Defaults to false if no value is + // provided. + // + // AWS::UseFIPS + UseFIPS *bool + + // Override the endpoint used to send this request + // + // Parameter is + // required. + // + // SDK::Endpoint + Endpoint *string +} + +// ValidateRequired validates required parameters are set. +func (p EndpointParameters) ValidateRequired() error { + if p.UseDualStack == nil { + return fmt.Errorf("parameter UseDualStack is required") + } + + if p.UseFIPS == nil { + return fmt.Errorf("parameter UseFIPS is required") + } + + return nil +} + +// WithDefaults returns a shallow copy of EndpointParameterswith default values +// applied to members where applicable. +func (p EndpointParameters) WithDefaults() EndpointParameters { + if p.UseDualStack == nil { + p.UseDualStack = ptr.Bool(false) + } + + if p.UseFIPS == nil { + p.UseFIPS = ptr.Bool(false) + } + return p +} + +// EndpointResolverV2 provides the interface for resolving service endpoints. +type EndpointResolverV2 interface { + // ResolveEndpoint attempts to resolve the endpoint with the provided options, + // returning the endpoint if found. Otherwise an error is returned. + ResolveEndpoint(ctx context.Context, params EndpointParameters) ( + smithyendpoints.Endpoint, error, + ) +} + +// resolver provides the implementation for resolving endpoints. +type resolver struct{} + +func NewDefaultEndpointResolverV2() EndpointResolverV2 { + return &resolver{} +} + +// ResolveEndpoint attempts to resolve the endpoint with the provided options, +// returning the endpoint if found. Otherwise an error is returned. +func (r *resolver) ResolveEndpoint( + ctx context.Context, params EndpointParameters, +) ( + endpoint smithyendpoints.Endpoint, err error, +) { + params = params.WithDefaults() + if err = params.ValidateRequired(); err != nil { + return endpoint, fmt.Errorf("endpoint parameters are not valid, %w", err) + } + _UseDualStack := *params.UseDualStack + _UseFIPS := *params.UseFIPS + + if exprVal := params.Endpoint; exprVal != nil { + _Endpoint := *exprVal + _ = _Endpoint + if _UseFIPS == true { + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: FIPS and custom endpoint are not supported") + } + if _UseDualStack == true { + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Dualstack and custom endpoint are not supported") + } + uriString := _Endpoint + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + } + if exprVal := params.Region; exprVal != nil { + _Region := *exprVal + _ = _Region + if exprVal := awsrulesfn.GetPartition(_Region); exprVal != nil { + _PartitionResult := *exprVal + _ = _PartitionResult + if _UseFIPS == true { + if _UseDualStack == true { + if true == _PartitionResult.SupportsFIPS { + if true == _PartitionResult.SupportsDualStack { + uriString := func() string { + var out strings.Builder + out.WriteString("https://scn-fips.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_PartitionResult.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + } + } + return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both") + } + } + if _UseFIPS == true { + if _PartitionResult.SupportsFIPS == true { + uriString := func() string { + var out strings.Builder + out.WriteString("https://scn-fips.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_PartitionResult.DnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + } + return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS") + } + if _UseDualStack == true { + if true == _PartitionResult.SupportsDualStack { + uriString := func() string { + var out strings.Builder + out.WriteString("https://scn.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_PartitionResult.DualStackDnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + } + return endpoint, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack") + } + uriString := func() string { + var out strings.Builder + out.WriteString("https://scn.") + out.WriteString(_Region) + out.WriteString(".") + out.WriteString(_PartitionResult.DnsSuffix) + return out.String() + }() + + uri, err := url.Parse(uriString) + if err != nil { + return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString) + } + + return smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + }, nil + } + return endpoint, fmt.Errorf("Endpoint resolution failed. Invalid operation or environment input.") + } + return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region") +} + +type endpointParamsBinder interface { + bindEndpointParams(*EndpointParameters) +} + +func bindEndpointParams(input interface{}, options Options) *EndpointParameters { + params := &EndpointParameters{} + + params.Region = aws.String(endpoints.MapFIPSRegion(options.Region)) + params.UseDualStack = aws.Bool(options.EndpointOptions.UseDualStackEndpoint == aws.DualStackEndpointStateEnabled) + params.UseFIPS = aws.Bool(options.EndpointOptions.UseFIPSEndpoint == aws.FIPSEndpointStateEnabled) + params.Endpoint = options.BaseEndpoint + + if b, ok := input.(endpointParamsBinder); ok { + b.bindEndpointParams(params) + } + + return params +} + +type resolveEndpointV2Middleware struct { + options Options +} + +func (*resolveEndpointV2Middleware) ID() string { + return "ResolveEndpointV2" +} + +func (m *resolveEndpointV2Middleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) ( + out middleware.FinalizeOutput, metadata middleware.Metadata, err error, +) { + if awsmiddleware.GetRequiresLegacyEndpoints(ctx) { + return next.HandleFinalize(ctx, in) + } + + req, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) + } + + if m.options.EndpointResolverV2 == nil { + return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil") + } + + params := bindEndpointParams(getOperationInput(ctx), m.options) + endpt, err := m.options.EndpointResolverV2.ResolveEndpoint(ctx, *params) + if err != nil { + return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err) + } + + if endpt.URI.RawPath == "" && req.URL.RawPath != "" { + endpt.URI.RawPath = endpt.URI.Path + } + req.URL.Scheme = endpt.URI.Scheme + req.URL.Host = endpt.URI.Host + req.URL.Path = smithyhttp.JoinPath(endpt.URI.Path, req.URL.Path) + req.URL.RawPath = smithyhttp.JoinPath(endpt.URI.RawPath, req.URL.RawPath) + for k := range endpt.Headers { + req.Header.Set(k, endpt.Headers.Get(k)) + } + + rscheme := getResolvedAuthScheme(ctx) + if rscheme == nil { + return out, metadata, fmt.Errorf("no resolved auth scheme") + } + + opts, _ := smithyauth.GetAuthOptions(&endpt.Properties) + for _, o := range opts { + rscheme.SignerProperties.SetAll(&o.SignerProperties) + } + + return next.HandleFinalize(ctx, in) +} diff --git a/service/supplychain/endpoints_config_test.go b/service/supplychain/endpoints_config_test.go new file mode 100644 index 00000000000..6bfe3aa8554 --- /dev/null +++ b/service/supplychain/endpoints_config_test.go @@ -0,0 +1,139 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "os" + "reflect" + "testing" +) + +type mockConfigSource struct { + global string + service string + ignore bool +} + +// GetIgnoreConfiguredEndpoints is used in knowing when to disable configured +// endpoints feature. +func (m mockConfigSource) GetIgnoreConfiguredEndpoints(context.Context) (bool, bool, error) { + return m.ignore, m.ignore, nil +} + +// GetServiceBaseEndpoint is used to retrieve a normalized SDK ID for use +// with configured endpoints. +func (m mockConfigSource) GetServiceBaseEndpoint(ctx context.Context, sdkID string) (string, bool, error) { + if m.service != "" { + return m.service, true, nil + } + return "", false, nil +} + +func TestResolveBaseEndpoint(t *testing.T) { + cases := map[string]struct { + envGlobal string + envService string + envIgnore bool + configGlobal string + configService string + configIgnore bool + clientEndpoint *string + expectURL *string + }{ + "env ignore": { + envGlobal: "https://env-global.dev", + envService: "https://env-supplychain.dev", + envIgnore: true, + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + expectURL: nil, + }, + "env global": { + envGlobal: "https://env-global.dev", + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + expectURL: aws.String("https://env-global.dev"), + }, + "env service": { + envGlobal: "https://env-global.dev", + envService: "https://env-supplychain.dev", + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + expectURL: aws.String("https://env-supplychain.dev"), + }, + "config ignore": { + envGlobal: "https://env-global.dev", + envService: "https://env-supplychain.dev", + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + configIgnore: true, + expectURL: nil, + }, + "config global": { + configGlobal: "http://config-global.dev", + expectURL: aws.String("http://config-global.dev"), + }, + "config service": { + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + expectURL: aws.String("http://config-supplychain.dev"), + }, + "client": { + envGlobal: "https://env-global.dev", + envService: "https://env-supplychain.dev", + configGlobal: "http://config-global.dev", + configService: "http://config-supplychain.dev", + clientEndpoint: aws.String("https://client-supplychain.dev"), + expectURL: aws.String("https://client-supplychain.dev"), + }, + } + + for name, c := range cases { + t.Run(name, func(t *testing.T) { + os.Clearenv() + + awsConfig := aws.Config{} + ignore := c.envIgnore || c.configIgnore + + if c.configGlobal != "" && !ignore { + awsConfig.BaseEndpoint = aws.String(c.configGlobal) + } + + if c.envGlobal != "" { + t.Setenv("AWS_ENDPOINT_URL", c.envGlobal) + if !ignore { + awsConfig.BaseEndpoint = aws.String(c.envGlobal) + } + } + + if c.envService != "" { + t.Setenv("AWS_ENDPOINT_URL_SUPPLYCHAIN", c.envService) + } + + awsConfig.ConfigSources = []interface{}{ + mockConfigSource{ + global: c.envGlobal, + service: c.envService, + ignore: c.envIgnore, + }, + mockConfigSource{ + global: c.configGlobal, + service: c.configService, + ignore: c.configIgnore, + }, + } + + client := NewFromConfig(awsConfig, func(o *Options) { + if c.clientEndpoint != nil { + o.BaseEndpoint = c.clientEndpoint + } + }) + + if e, a := c.expectURL, client.options.BaseEndpoint; !reflect.DeepEqual(e, a) { + t.Errorf("expect endpoint %v , got %v", e, a) + } + }) + } +} diff --git a/service/supplychain/endpoints_test.go b/service/supplychain/endpoints_test.go new file mode 100644 index 00000000000..81551b6356e --- /dev/null +++ b/service/supplychain/endpoints_test.go @@ -0,0 +1,856 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + smithy "github.com/aws/smithy-go" + smithyendpoints "github.com/aws/smithy-go/endpoints" + "github.com/aws/smithy-go/ptr" + "github.com/google/go-cmp/cmp" + "net/http" + "net/url" + "strings" + "testing" +) + +// For region us-east-1 with FIPS enabled and DualStack enabled +func TestEndpointCase0(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-east-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-east-1 with FIPS enabled and DualStack disabled +func TestEndpointCase1(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-east-1.amazonaws.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-east-1 with FIPS disabled and DualStack enabled +func TestEndpointCase2(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-east-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-east-1 with FIPS disabled and DualStack disabled +func TestEndpointCase3(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-east-1.amazonaws.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region cn-north-1 with FIPS enabled and DualStack enabled +func TestEndpointCase4(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("cn-north-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.cn-north-1.api.amazonwebservices.com.cn") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region cn-north-1 with FIPS enabled and DualStack disabled +func TestEndpointCase5(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("cn-north-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.cn-north-1.amazonaws.com.cn") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region cn-north-1 with FIPS disabled and DualStack enabled +func TestEndpointCase6(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("cn-north-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.cn-north-1.api.amazonwebservices.com.cn") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region cn-north-1 with FIPS disabled and DualStack disabled +func TestEndpointCase7(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("cn-north-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.cn-north-1.amazonaws.com.cn") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-gov-east-1 with FIPS enabled and DualStack enabled +func TestEndpointCase8(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-gov-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-gov-east-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-gov-east-1 with FIPS enabled and DualStack disabled +func TestEndpointCase9(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-gov-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-gov-east-1.amazonaws.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-gov-east-1 with FIPS disabled and DualStack enabled +func TestEndpointCase10(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-gov-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-gov-east-1.api.aws") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-gov-east-1 with FIPS disabled and DualStack disabled +func TestEndpointCase11(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-gov-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-gov-east-1.amazonaws.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-iso-east-1 with FIPS enabled and DualStack enabled +func TestEndpointCase12(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-iso-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "FIPS and DualStack are enabled, but this partition does not support one or both", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// For region us-iso-east-1 with FIPS enabled and DualStack disabled +func TestEndpointCase13(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-iso-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-iso-east-1.c2s.ic.gov") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-iso-east-1 with FIPS disabled and DualStack enabled +func TestEndpointCase14(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-iso-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "DualStack is enabled but this partition does not support DualStack", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// For region us-iso-east-1 with FIPS disabled and DualStack disabled +func TestEndpointCase15(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-iso-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-iso-east-1.c2s.ic.gov") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-isob-east-1 with FIPS enabled and DualStack enabled +func TestEndpointCase16(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-isob-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "FIPS and DualStack are enabled, but this partition does not support one or both", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// For region us-isob-east-1 with FIPS enabled and DualStack disabled +func TestEndpointCase17(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-isob-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn-fips.us-isob-east-1.sc2s.sgov.gov") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For region us-isob-east-1 with FIPS disabled and DualStack enabled +func TestEndpointCase18(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-isob-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "DualStack is enabled but this partition does not support DualStack", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// For region us-isob-east-1 with FIPS disabled and DualStack disabled +func TestEndpointCase19(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-isob-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://scn.us-isob-east-1.sc2s.sgov.gov") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For custom endpoint with region set and fips disabled and dualstack disabled +func TestEndpointCase20(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + Endpoint: ptr.String("https://example.com"), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://example.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For custom endpoint with region not set and fips disabled and dualstack disabled +func TestEndpointCase21(t *testing.T) { + var params = EndpointParameters{ + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(false), + Endpoint: ptr.String("https://example.com"), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err != nil { + t.Fatalf("expect no error, got %v", err) + } + + uri, _ := url.Parse("https://example.com") + + expectEndpoint := smithyendpoints.Endpoint{ + URI: *uri, + Headers: http.Header{}, + Properties: smithy.Properties{}, + } + + if e, a := expectEndpoint.URI, result.URI; e != a { + t.Errorf("expect %v URI, got %v", e, a) + } + + if diff := cmp.Diff(expectEndpoint.Headers, result.Headers); diff != "" { + t.Errorf("expect headers to match\n%s", diff) + } + + if diff := cmp.Diff(expectEndpoint.Properties, result.Properties, + cmp.AllowUnexported(smithy.Properties{}), + ); diff != "" { + t.Errorf("expect properties to match\n%s", diff) + } +} + +// For custom endpoint with fips enabled and dualstack disabled +func TestEndpointCase22(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(true), + UseDualStack: ptr.Bool(false), + Endpoint: ptr.String("https://example.com"), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "Invalid Configuration: FIPS and custom endpoint are not supported", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// For custom endpoint with fips disabled and dualstack enabled +func TestEndpointCase23(t *testing.T) { + var params = EndpointParameters{ + Region: ptr.String("us-east-1"), + UseFIPS: ptr.Bool(false), + UseDualStack: ptr.Bool(true), + Endpoint: ptr.String("https://example.com"), + } + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "Invalid Configuration: Dualstack and custom endpoint are not supported", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} + +// Missing region +func TestEndpointCase24(t *testing.T) { + var params = EndpointParameters{} + + resolver := NewDefaultEndpointResolverV2() + result, err := resolver.ResolveEndpoint(context.Background(), params) + _, _ = result, err + + if err == nil { + t.Fatalf("expect error, got none") + } + if e, a := "Invalid Configuration: Missing Region", err.Error(); !strings.Contains(a, e) { + t.Errorf("expect %v error in %v", e, a) + } +} diff --git a/service/supplychain/generated.json b/service/supplychain/generated.json new file mode 100644 index 00000000000..a220e39477e --- /dev/null +++ b/service/supplychain/generated.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "github.com/aws/aws-sdk-go-v2": "v1.4.0", + "github.com/aws/aws-sdk-go-v2/internal/configsources": "v0.0.0-00010101000000-000000000000", + "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2": "v2.0.0-00010101000000-000000000000", + "github.com/aws/smithy-go": "v1.4.0", + "github.com/google/go-cmp": "v0.5.4" + }, + "files": [ + "api_client.go", + "api_client_test.go", + "api_op_CreateBillOfMaterialsImportJob.go", + "api_op_GetBillOfMaterialsImportJob.go", + "auth.go", + "deserializers.go", + "doc.go", + "endpoints.go", + "endpoints_config_test.go", + "endpoints_test.go", + "generated.json", + "internal/endpoints/endpoints.go", + "internal/endpoints/endpoints_test.go", + "options.go", + "protocol_test.go", + "serializers.go", + "types/enums.go", + "types/errors.go", + "types/types.go", + "validators.go" + ], + "go": "1.15", + "module": "github.com/aws/aws-sdk-go-v2/service/supplychain", + "unstable": false +} diff --git a/service/supplychain/go.mod b/service/supplychain/go.mod new file mode 100644 index 00000000000..3159331fd5a --- /dev/null +++ b/service/supplychain/go.mod @@ -0,0 +1,17 @@ +module github.com/aws/aws-sdk-go-v2/service/supplychain + +go 1.19 + +require ( + github.com/aws/aws-sdk-go-v2 v1.24.1 + github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 + github.com/aws/smithy-go v1.19.0 + github.com/google/go-cmp v0.5.8 +) + +replace github.com/aws/aws-sdk-go-v2 => ../../ + +replace github.com/aws/aws-sdk-go-v2/internal/configsources => ../../internal/configsources/ + +replace github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => ../../internal/endpoints/v2/ diff --git a/service/supplychain/go.sum b/service/supplychain/go.sum new file mode 100644 index 00000000000..5795dbe697e --- /dev/null +++ b/service/supplychain/go.sum @@ -0,0 +1,4 @@ +github.com/aws/smithy-go v1.19.0 h1:KWFKQV80DpP3vJrrA9sVAHQ5gc2z8i4EzrLhLlWXcBM= +github.com/aws/smithy-go v1.19.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/service/supplychain/go_module_metadata.go b/service/supplychain/go_module_metadata.go new file mode 100644 index 00000000000..9c8744136eb --- /dev/null +++ b/service/supplychain/go_module_metadata.go @@ -0,0 +1,6 @@ +// Code generated by internal/repotools/cmd/updatemodulemeta DO NOT EDIT. + +package supplychain + +// goModuleVersion is the tagged release for this module +const goModuleVersion = "tip" diff --git a/service/supplychain/internal/endpoints/endpoints.go b/service/supplychain/internal/endpoints/endpoints.go new file mode 100644 index 00000000000..1f9bced0ed2 --- /dev/null +++ b/service/supplychain/internal/endpoints/endpoints.go @@ -0,0 +1,296 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package endpoints + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + endpoints "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2" + "github.com/aws/smithy-go/logging" + "regexp" +) + +// Options is the endpoint resolver configuration options +type Options struct { + // Logger is a logging implementation that log events should be sent to. + Logger logging.Logger + + // LogDeprecated indicates that deprecated endpoints should be logged to the + // provided logger. + LogDeprecated bool + + // ResolvedRegion is used to override the region to be resolved, rather then the + // using the value passed to the ResolveEndpoint method. This value is used by the + // SDK to translate regions like fips-us-east-1 or us-east-1-fips to an alternative + // name. You must not set this value directly in your application. + ResolvedRegion string + + // DisableHTTPS informs the resolver to return an endpoint that does not use the + // HTTPS scheme. + DisableHTTPS bool + + // UseDualStackEndpoint specifies the resolver must resolve a dual-stack endpoint. + UseDualStackEndpoint aws.DualStackEndpointState + + // UseFIPSEndpoint specifies the resolver must resolve a FIPS endpoint. + UseFIPSEndpoint aws.FIPSEndpointState +} + +func (o Options) GetResolvedRegion() string { + return o.ResolvedRegion +} + +func (o Options) GetDisableHTTPS() bool { + return o.DisableHTTPS +} + +func (o Options) GetUseDualStackEndpoint() aws.DualStackEndpointState { + return o.UseDualStackEndpoint +} + +func (o Options) GetUseFIPSEndpoint() aws.FIPSEndpointState { + return o.UseFIPSEndpoint +} + +func transformToSharedOptions(options Options) endpoints.Options { + return endpoints.Options{ + Logger: options.Logger, + LogDeprecated: options.LogDeprecated, + ResolvedRegion: options.ResolvedRegion, + DisableHTTPS: options.DisableHTTPS, + UseDualStackEndpoint: options.UseDualStackEndpoint, + UseFIPSEndpoint: options.UseFIPSEndpoint, + } +} + +// Resolver SupplyChain endpoint resolver +type Resolver struct { + partitions endpoints.Partitions +} + +// ResolveEndpoint resolves the service endpoint for the given region and options +func (r *Resolver) ResolveEndpoint(region string, options Options) (endpoint aws.Endpoint, err error) { + if len(region) == 0 { + return endpoint, &aws.MissingRegionError{} + } + + opt := transformToSharedOptions(options) + return r.partitions.ResolveEndpoint(region, opt) +} + +// New returns a new Resolver +func New() *Resolver { + return &Resolver{ + partitions: defaultPartitions, + } +} + +var partitionRegexp = struct { + Aws *regexp.Regexp + AwsCn *regexp.Regexp + AwsIso *regexp.Regexp + AwsIsoB *regexp.Regexp + AwsIsoE *regexp.Regexp + AwsIsoF *regexp.Regexp + AwsUsGov *regexp.Regexp +}{ + + Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af|il)\\-\\w+\\-\\d+$"), + AwsCn: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"), + AwsIso: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"), + AwsIsoB: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"), + AwsIsoE: regexp.MustCompile("^eu\\-isoe\\-\\w+\\-\\d+$"), + AwsIsoF: regexp.MustCompile("^us\\-isof\\-\\w+\\-\\d+$"), + AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"), +} + +var defaultPartitions = endpoints.Partitions{ + { + ID: "aws", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.DualStackVariant, + }: { + Hostname: "scn.{region}.api.aws", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant | endpoints.DualStackVariant, + }: { + Hostname: "scn-fips.{region}.api.aws", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.Aws, + IsRegionalized: true, + }, + { + ID: "aws-cn", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.DualStackVariant, + }: { + Hostname: "scn.{region}.api.amazonwebservices.com.cn", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.amazonaws.com.cn", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant | endpoints.DualStackVariant, + }: { + Hostname: "scn-fips.{region}.api.amazonwebservices.com.cn", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.amazonaws.com.cn", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsCn, + IsRegionalized: true, + }, + { + ID: "aws-iso", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.c2s.ic.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.c2s.ic.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsIso, + IsRegionalized: true, + }, + { + ID: "aws-iso-b", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.sc2s.sgov.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.sc2s.sgov.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsIsoB, + IsRegionalized: true, + }, + { + ID: "aws-iso-e", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.cloud.adc-e.uk", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.cloud.adc-e.uk", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsIsoE, + IsRegionalized: true, + }, + { + ID: "aws-iso-f", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.csp.hci.ic.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.csp.hci.ic.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsIsoF, + IsRegionalized: true, + }, + { + ID: "aws-us-gov", + Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{ + { + Variant: endpoints.DualStackVariant, + }: { + Hostname: "scn.{region}.api.aws", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant, + }: { + Hostname: "scn-fips.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: endpoints.FIPSVariant | endpoints.DualStackVariant, + }: { + Hostname: "scn-fips.{region}.api.aws", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + { + Variant: 0, + }: { + Hostname: "scn.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + }, + RegionRegex: partitionRegexp.AwsUsGov, + IsRegionalized: true, + }, +} diff --git a/service/supplychain/internal/endpoints/endpoints_test.go b/service/supplychain/internal/endpoints/endpoints_test.go new file mode 100644 index 00000000000..08e5da2d833 --- /dev/null +++ b/service/supplychain/internal/endpoints/endpoints_test.go @@ -0,0 +1,11 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package endpoints + +import ( + "testing" +) + +func TestRegexCompile(t *testing.T) { + _ = defaultPartitions +} diff --git a/service/supplychain/options.go b/service/supplychain/options.go new file mode 100644 index 00000000000..197e9c8a081 --- /dev/null +++ b/service/supplychain/options.go @@ -0,0 +1,221 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy" + smithyauth "github.com/aws/smithy-go/auth" + "github.com/aws/smithy-go/logging" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" + "net/http" +) + +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +type Options struct { + // Set of options to modify how an operation is invoked. These apply to all + // operations invoked for this client. Use functional options on operation call to + // modify this list for per operation behavior. + APIOptions []func(*middleware.Stack) error + + // The optional application specific identifier appended to the User-Agent header. + AppID string + + // This endpoint will be given as input to an EndpointResolverV2. It is used for + // providing a custom base endpoint that is subject to modifications by the + // processing EndpointResolverV2. + BaseEndpoint *string + + // Configures the events that will be sent to the configured logger. + ClientLogMode aws.ClientLogMode + + // The credentials object to use when signing requests. + Credentials aws.CredentialsProvider + + // The configuration DefaultsMode that the SDK should use when constructing the + // clients initial default settings. + DefaultsMode aws.DefaultsMode + + // The endpoint options to be used when attempting to resolve an endpoint. + EndpointOptions EndpointResolverOptions + + // The service endpoint resolver. + // + // Deprecated: Deprecated: EndpointResolver and WithEndpointResolver. Providing a + // value for this field will likely prevent you from using any endpoint-related + // service features released after the introduction of EndpointResolverV2 and + // BaseEndpoint. To migrate an EndpointResolver implementation that uses a custom + // endpoint, set the client option BaseEndpoint instead. + EndpointResolver EndpointResolver + + // Resolves the endpoint used for a particular service operation. This should be + // used over the deprecated EndpointResolver. + EndpointResolverV2 EndpointResolverV2 + + // Signature Version 4 (SigV4) Signer + HTTPSignerV4 HTTPSignerV4 + + // Provides idempotency tokens values that will be automatically populated into + // idempotent API operations. + IdempotencyTokenProvider IdempotencyTokenProvider + + // The logger writer interface to write logging messages to. + Logger logging.Logger + + // The region to send requests to. (Required) + Region string + + // RetryMaxAttempts specifies the maximum number attempts an API client will call + // an operation that fails with a retryable error. A value of 0 is ignored, and + // will not be used to configure the API client created default retryer, or modify + // per operation call's retry max attempts. If specified in an operation call's + // functional options with a value that is different than the constructed client's + // Options, the Client's Retryer will be wrapped to use the operation's specific + // RetryMaxAttempts value. + RetryMaxAttempts int + + // RetryMode specifies the retry mode the API client will be created with, if + // Retryer option is not also specified. When creating a new API Clients this + // member will only be used if the Retryer Options member is nil. This value will + // be ignored if Retryer is not nil. Currently does not support per operation call + // overrides, may in the future. + RetryMode aws.RetryMode + + // Retryer guides how HTTP requests should be retried in case of recoverable + // failures. When nil the API client will use a default retryer. The kind of + // default retry created by the API client can be changed with the RetryMode + // option. + Retryer aws.Retryer + + // The RuntimeEnvironment configuration, only populated if the DefaultsMode is set + // to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You + // should not populate this structure programmatically, or rely on the values here + // within your applications. + RuntimeEnvironment aws.RuntimeEnvironment + + // The initial DefaultsMode used when the client options were constructed. If the + // DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved + // value was at that point in time. Currently does not support per operation call + // overrides, may in the future. + resolvedDefaultsMode aws.DefaultsMode + + // The HTTP client to invoke API calls with. Defaults to client's default HTTP + // implementation if nil. + HTTPClient HTTPClient + + // The auth scheme resolver which determines how to authenticate for each + // operation. + AuthSchemeResolver AuthSchemeResolver + + // The list of auth schemes supported by the client. + AuthSchemes []smithyhttp.AuthScheme +} + +// Copy creates a clone where the APIOptions list is deep copied. +func (o Options) Copy() Options { + to := o + to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions)) + copy(to.APIOptions, o.APIOptions) + + return to +} + +func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver { + if schemeID == "aws.auth#sigv4" { + return getSigV4IdentityResolver(o) + } + if schemeID == "smithy.api#noAuth" { + return &smithyauth.AnonymousIdentityResolver{} + } + return nil +} + +// WithAPIOptions returns a functional option for setting the Client's APIOptions +// option. +func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) { + return func(o *Options) { + o.APIOptions = append(o.APIOptions, optFns...) + } +} + +// Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for +// this field will likely prevent you from using any endpoint-related service +// features released after the introduction of EndpointResolverV2 and BaseEndpoint. +// To migrate an EndpointResolver implementation that uses a custom endpoint, set +// the client option BaseEndpoint instead. +func WithEndpointResolver(v EndpointResolver) func(*Options) { + return func(o *Options) { + o.EndpointResolver = v + } +} + +// WithEndpointResolverV2 returns a functional option for setting the Client's +// EndpointResolverV2 option. +func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) { + return func(o *Options) { + o.EndpointResolverV2 = v + } +} + +func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver { + if o.Credentials != nil { + return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials} + } + return nil +} + +// WithSigV4SigningName applies an override to the authentication workflow to +// use the given signing name for SigV4-authenticated operations. +// +// This is an advanced setting. The value here is FINAL, taking precedence over +// the resolved signing name from both auth scheme resolution and endpoint +// resolution. +func WithSigV4SigningName(name string) func(*Options) { + fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, + ) { + return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in) + } + return func(o *Options) { + o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { + return s.Initialize.Add( + middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn), + middleware.Before, + ) + }) + } +} + +// WithSigV4SigningRegion applies an override to the authentication workflow to +// use the given signing region for SigV4-authenticated operations. +// +// This is an advanced setting. The value here is FINAL, taking precedence over +// the resolved signing region from both auth scheme resolution and endpoint +// resolution. +func WithSigV4SigningRegion(region string) func(*Options) { + fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, + ) { + return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in) + } + return func(o *Options) { + o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { + return s.Initialize.Add( + middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn), + middleware.Before, + ) + }) + } +} + +func ignoreAnonymousAuth(options *Options) { + if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) { + options.Credentials = nil + } +} diff --git a/service/supplychain/protocol_test.go b/service/supplychain/protocol_test.go new file mode 100644 index 00000000000..f20f288acb0 --- /dev/null +++ b/service/supplychain/protocol_test.go @@ -0,0 +1,3 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain diff --git a/service/supplychain/serializers.go b/service/supplychain/serializers.go new file mode 100644 index 00000000000..11563379cc7 --- /dev/null +++ b/service/supplychain/serializers.go @@ -0,0 +1,181 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "bytes" + "context" + "fmt" + smithy "github.com/aws/smithy-go" + "github.com/aws/smithy-go/encoding/httpbinding" + smithyjson "github.com/aws/smithy-go/encoding/json" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +type awsRestjson1_serializeOpCreateBillOfMaterialsImportJob struct { +} + +func (*awsRestjson1_serializeOpCreateBillOfMaterialsImportJob) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpCreateBillOfMaterialsImportJob) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*CreateBillOfMaterialsImportJobInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/api/configuration/instances/{instanceId}/bill-of-materials-import-jobs") + request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) + request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) + request.Method = "POST" + var restEncoder *httpbinding.Encoder + if request.URL.RawPath == "" { + restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + } else { + request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) + restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) + } + + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if err := awsRestjson1_serializeOpHttpBindingsCreateBillOfMaterialsImportJobInput(input, restEncoder); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + restEncoder.SetHeader("Content-Type").String("application/json") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsRestjson1_serializeOpDocumentCreateBillOfMaterialsImportJobInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeOpHttpBindingsCreateBillOfMaterialsImportJobInput(v *CreateBillOfMaterialsImportJobInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + if v.InstanceId == nil || len(*v.InstanceId) == 0 { + return &smithy.SerializationError{Err: fmt.Errorf("input member instanceId must not be empty")} + } + if v.InstanceId != nil { + if err := encoder.SetURI("instanceId").String(*v.InstanceId); err != nil { + return err + } + } + + return nil +} + +func awsRestjson1_serializeOpDocumentCreateBillOfMaterialsImportJobInput(v *CreateBillOfMaterialsImportJobInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.ClientToken != nil { + ok := object.Key("clientToken") + ok.String(*v.ClientToken) + } + + if v.S3uri != nil { + ok := object.Key("s3uri") + ok.String(*v.S3uri) + } + + return nil +} + +type awsRestjson1_serializeOpGetBillOfMaterialsImportJob struct { +} + +func (*awsRestjson1_serializeOpGetBillOfMaterialsImportJob) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpGetBillOfMaterialsImportJob) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*GetBillOfMaterialsImportJobInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/api/configuration/instances/{instanceId}/bill-of-materials-import-jobs/{jobId}") + request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath) + request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery) + request.Method = "GET" + var restEncoder *httpbinding.Encoder + if request.URL.RawPath == "" { + restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + } else { + request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath) + restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header) + } + + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if err := awsRestjson1_serializeOpHttpBindingsGetBillOfMaterialsImportJobInput(input, restEncoder); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeOpHttpBindingsGetBillOfMaterialsImportJobInput(v *GetBillOfMaterialsImportJobInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + if v.InstanceId == nil || len(*v.InstanceId) == 0 { + return &smithy.SerializationError{Err: fmt.Errorf("input member instanceId must not be empty")} + } + if v.InstanceId != nil { + if err := encoder.SetURI("instanceId").String(*v.InstanceId); err != nil { + return err + } + } + + if v.JobId == nil || len(*v.JobId) == 0 { + return &smithy.SerializationError{Err: fmt.Errorf("input member jobId must not be empty")} + } + if v.JobId != nil { + if err := encoder.SetURI("jobId").String(*v.JobId); err != nil { + return err + } + } + + return nil +} diff --git a/service/supplychain/types/enums.go b/service/supplychain/types/enums.go new file mode 100644 index 00000000000..b2168ef99cf --- /dev/null +++ b/service/supplychain/types/enums.go @@ -0,0 +1,27 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +type ConfigurationJobStatus string + +// Enum values for ConfigurationJobStatus +const ( + ConfigurationJobStatusNew ConfigurationJobStatus = "NEW" + ConfigurationJobStatusFailed ConfigurationJobStatus = "FAILED" + ConfigurationJobStatusInProgress ConfigurationJobStatus = "IN_PROGRESS" + ConfigurationJobStatusQueued ConfigurationJobStatus = "QUEUED" + ConfigurationJobStatusSuccess ConfigurationJobStatus = "SUCCESS" +) + +// Values returns all known values for ConfigurationJobStatus. Note that this can +// be expanded in the future, and so it is only as up to date as the client. The +// ordering of this slice is not guaranteed to be stable across updates. +func (ConfigurationJobStatus) Values() []ConfigurationJobStatus { + return []ConfigurationJobStatus{ + "NEW", + "FAILED", + "IN_PROGRESS", + "QUEUED", + "SUCCESS", + } +} diff --git a/service/supplychain/types/errors.go b/service/supplychain/types/errors.go new file mode 100644 index 00000000000..bed0eb1a4f1 --- /dev/null +++ b/service/supplychain/types/errors.go @@ -0,0 +1,190 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +import ( + "fmt" + smithy "github.com/aws/smithy-go" +) + +// You do not have the required privileges to perform this action. +type AccessDeniedException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *AccessDeniedException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *AccessDeniedException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *AccessDeniedException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "AccessDeniedException" + } + return *e.ErrorCodeOverride +} +func (e *AccessDeniedException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } + +// Updating or deleting a resource can cause an inconsistent state. +type ConflictException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *ConflictException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ConflictException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ConflictException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ConflictException" + } + return *e.ErrorCodeOverride +} +func (e *ConflictException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } + +// Unexpected error during processing of request. +type InternalServerException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *InternalServerException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *InternalServerException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *InternalServerException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "InternalServerException" + } + return *e.ErrorCodeOverride +} +func (e *InternalServerException) ErrorFault() smithy.ErrorFault { return smithy.FaultServer } + +// Request references a resource which does not exist. +type ResourceNotFoundException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *ResourceNotFoundException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ResourceNotFoundException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ResourceNotFoundException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ResourceNotFoundException" + } + return *e.ErrorCodeOverride +} +func (e *ResourceNotFoundException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } + +// Request would cause a service quota to be exceeded. +type ServiceQuotaExceededException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *ServiceQuotaExceededException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ServiceQuotaExceededException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ServiceQuotaExceededException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ServiceQuotaExceededException" + } + return *e.ErrorCodeOverride +} +func (e *ServiceQuotaExceededException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } + +// Request was denied due to request throttling. +type ThrottlingException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *ThrottlingException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ThrottlingException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ThrottlingException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ThrottlingException" + } + return *e.ErrorCodeOverride +} +func (e *ThrottlingException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } + +// The input does not satisfy the constraints specified by an AWS service. +type ValidationException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *ValidationException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ValidationException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ValidationException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ValidationException" + } + return *e.ErrorCodeOverride +} +func (e *ValidationException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } diff --git a/service/supplychain/types/types.go b/service/supplychain/types/types.go new file mode 100644 index 00000000000..db6517f643b --- /dev/null +++ b/service/supplychain/types/types.go @@ -0,0 +1,39 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +import ( + smithydocument "github.com/aws/smithy-go/document" +) + +// The BillOfMaterialsImportJob details. +type BillOfMaterialsImportJob struct { + + // The BillOfMaterialsImportJob instanceId. + // + // This member is required. + InstanceId *string + + // The BillOfMaterialsImportJob jobId. + // + // This member is required. + JobId *string + + // The S3 URI from which the CSV is read. + // + // This member is required. + S3uri *string + + // The BillOfMaterialsImportJob ConfigurationJobStatus. + // + // This member is required. + Status ConfigurationJobStatus + + // When the BillOfMaterialsImportJob has reached a terminal state, there will be a + // message. + Message *string + + noSmithyDocumentSerde +} + +type noSmithyDocumentSerde = smithydocument.NoSerde diff --git a/service/supplychain/validators.go b/service/supplychain/validators.go new file mode 100644 index 00000000000..eb855f4f536 --- /dev/null +++ b/service/supplychain/validators.go @@ -0,0 +1,94 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package supplychain + +import ( + "context" + "fmt" + smithy "github.com/aws/smithy-go" + "github.com/aws/smithy-go/middleware" +) + +type validateOpCreateBillOfMaterialsImportJob struct { +} + +func (*validateOpCreateBillOfMaterialsImportJob) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpCreateBillOfMaterialsImportJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*CreateBillOfMaterialsImportJobInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpCreateBillOfMaterialsImportJobInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + +type validateOpGetBillOfMaterialsImportJob struct { +} + +func (*validateOpGetBillOfMaterialsImportJob) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpGetBillOfMaterialsImportJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*GetBillOfMaterialsImportJobInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpGetBillOfMaterialsImportJobInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + +func addOpCreateBillOfMaterialsImportJobValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpCreateBillOfMaterialsImportJob{}, middleware.After) +} + +func addOpGetBillOfMaterialsImportJobValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpGetBillOfMaterialsImportJob{}, middleware.After) +} + +func validateOpCreateBillOfMaterialsImportJobInput(v *CreateBillOfMaterialsImportJobInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "CreateBillOfMaterialsImportJobInput"} + if v.InstanceId == nil { + invalidParams.Add(smithy.NewErrParamRequired("InstanceId")) + } + if v.S3uri == nil { + invalidParams.Add(smithy.NewErrParamRequired("S3uri")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + +func validateOpGetBillOfMaterialsImportJobInput(v *GetBillOfMaterialsImportJobInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "GetBillOfMaterialsImportJobInput"} + if v.InstanceId == nil { + invalidParams.Add(smithy.NewErrParamRequired("InstanceId")) + } + if v.JobId == nil { + invalidParams.Add(smithy.NewErrParamRequired("JobId")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} diff --git a/service/transfer/deserializers.go b/service/transfer/deserializers.go index 670bd6ed26a..ce2f960c2da 100644 --- a/service/transfer/deserializers.go +++ b/service/transfer/deserializers.go @@ -8250,6 +8250,11 @@ func awsAwsjson11_deserializeDocumentDescribedConnector(v **types.DescribedConne sv.LoggingRole = ptr.String(jtv) } + case "ServiceManagedEgressIpAddresses": + if err := awsAwsjson11_deserializeDocumentServiceManagedEgressIpAddresses(&sv.ServiceManagedEgressIpAddresses, value); err != nil { + return err + } + case "SftpConfig": if err := awsAwsjson11_deserializeDocumentSftpConnectorConfig(&sv.SftpConfig, value); err != nil { return err @@ -8635,6 +8640,11 @@ func awsAwsjson11_deserializeDocumentDescribedServer(v **types.DescribedServer, sv.Arn = ptr.String(jtv) } + case "As2ServiceManagedEgressIpAddresses": + if err := awsAwsjson11_deserializeDocumentServiceManagedEgressIpAddresses(&sv.As2ServiceManagedEgressIpAddresses, value); err != nil { + return err + } + case "Certificate": if value != nil { jtv, ok := value.(string) @@ -11564,6 +11574,42 @@ func awsAwsjson11_deserializeDocumentSecurityPolicyOptions(v *[]string, value in return nil } +func awsAwsjson11_deserializeDocumentServiceManagedEgressIpAddresses(v *[]string, value interface{}) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + if value == nil { + return nil + } + + shape, ok := value.([]interface{}) + if !ok { + return fmt.Errorf("unexpected JSON type %v", value) + } + + var cv []string + if *v == nil { + cv = []string{} + } else { + cv = *v + } + + for _, value := range shape { + var col string + if value != nil { + jtv, ok := value.(string) + if !ok { + return fmt.Errorf("expected ServiceManagedEgressIpAddress to be of type string, got %T instead", value) + } + col = jtv + } + cv = append(cv, col) + + } + *v = cv + return nil +} + func awsAwsjson11_deserializeDocumentServiceMetadata(v **types.ServiceMetadata, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) diff --git a/service/transfer/types/types.go b/service/transfer/types/types.go index 5449665fb29..6d2f4563d77 100644 --- a/service/transfer/types/types.go +++ b/service/transfer/types/types.go @@ -422,6 +422,10 @@ type DescribedConnector struct { // set, you can view connector activity in your CloudWatch logs. LoggingRole *string + // The list of egress IP addresses of this connector. These IP addresses are + // assigned automatically when you create the connector. + ServiceManagedEgressIpAddresses []string + // A structure that contains the parameters for an SFTP connector object. SftpConfig *SftpConnectorConfig @@ -584,6 +588,13 @@ type DescribedServer struct { // This member is required. Arn *string + // The list of egress IP addresses of this server. These IP addresses are only + // relevant for servers that use the AS2 protocol. They are used for sending + // asynchronous MDNs. These IP addresses are assigned automatically when you create + // an AS2 server. Additionally, if you update an existing server and add the AS2 + // protocol, static IP addresses are assigned as well. + As2ServiceManagedEgressIpAddresses []string + // Specifies the ARN of the Amazon Web ServicesCertificate Manager (ACM) // certificate. Required when Protocols is set to FTPS . Certificate *string @@ -1017,7 +1028,8 @@ type HomeDirectoryMapEntry struct { // method of authentication. type IdentityProviderDetails struct { - // The identifier of the Directory Service directory that you want to stop sharing. + // The identifier of the Directory Service directory that you want to use as your + // identity provider. DirectoryId *string // The ARN for a Lambda function to use for the Identity provider.