Skip to content

Commit

Permalink
Add account id to the built-in endpoint parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Aug 14, 2024
1 parent f142890 commit 3e7e76a
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once
#include <aws/dynamodb/DynamoDB_EXPORTS.h>
#include <aws/core/client/GenericClientConfiguration.h>
#include <aws/dynamodb/DynamoDBClientConfiguration.h>
#include <aws/core/endpoint/DefaultEndpointProvider.h>
#include <aws/core/endpoint/EndpointParameter.h>
#include <aws/core/utils/memory/stl/AWSString.h>
Expand All @@ -20,14 +20,20 @@ namespace DynamoDB
{
namespace Endpoint
{
using DynamoDBClientConfiguration = Aws::DynamoDB::DynamoDBClientConfiguration;
using EndpointParameters = Aws::Endpoint::EndpointParameters;
using Aws::Endpoint::EndpointProviderBase;
using Aws::Endpoint::DefaultEndpointProvider;

using DynamoDBClientContextParameters = Aws::Endpoint::ClientContextParameters;

using DynamoDBClientConfiguration = Aws::Client::GenericClientConfiguration;
using DynamoDBBuiltInParameters = Aws::Endpoint::BuiltInParameters;
class AWS_DYNAMODB_API DynamoDBBuiltInParameters : public Aws::Endpoint::BuiltInParameters
{
public:
virtual ~DynamoDBBuiltInParameters(){};
using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration;
virtual void SetFromClientConfiguration(const DynamoDBClientConfiguration& config);
};

/**
* The type for the DynamoDB Client Endpoint Provider.
Expand All @@ -40,6 +46,25 @@ using DynamoDBEndpointProviderBase =
using DynamoDBDefaultEpProviderBase =
DefaultEndpointProvider<DynamoDBClientConfiguration, DynamoDBBuiltInParameters, DynamoDBClientContextParameters>;

} // namespace Endpoint
} // namespace DynamoDB

namespace Endpoint
{
/**
* Export endpoint provider symbols for Windows DLL, otherwise declare as extern
*/
AWS_DYNAMODB_EXTERN template class AWS_DYNAMODB_API
Aws::Endpoint::EndpointProviderBase<DynamoDB::Endpoint::DynamoDBClientConfiguration, DynamoDB::Endpoint::DynamoDBBuiltInParameters, DynamoDB::Endpoint::DynamoDBClientContextParameters>;

AWS_DYNAMODB_EXTERN template class AWS_DYNAMODB_API
Aws::Endpoint::DefaultEndpointProvider<DynamoDB::Endpoint::DynamoDBClientConfiguration, DynamoDB::Endpoint::DynamoDBBuiltInParameters, DynamoDB::Endpoint::DynamoDBClientContextParameters>;
} // namespace Endpoint

namespace DynamoDB
{
namespace Endpoint
{
/**
* Default endpoint provider used for this service
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,31 @@

namespace Aws
{
#ifndef AWS_DYNAMODB_EXPORTS // Except for Windows DLL
namespace Endpoint
{
/**
* Instantiate endpoint providers
*/
template class Aws::Endpoint::EndpointProviderBase<DynamoDB::Endpoint::DynamoDBClientConfiguration,
DynamoDB::Endpoint::DynamoDBBuiltInParameters,
DynamoDB::Endpoint::DynamoDBClientContextParameters>;

template class Aws::Endpoint::DefaultEndpointProvider<DynamoDB::Endpoint::DynamoDBClientConfiguration,
DynamoDB::Endpoint::DynamoDBBuiltInParameters,
DynamoDB::Endpoint::DynamoDBClientContextParameters>;
} // namespace Endpoint
#endif

namespace DynamoDB
{
namespace Endpoint
{
void DynamoDBBuiltInParameters::SetFromClientConfiguration(const DynamoDBClientConfiguration& config)
{
SetFromClientConfiguration(static_cast<const DynamoDBClientConfiguration::BaseClientConfigClass&>(config));

}
} // namespace Endpoint
} // namespace DynamoDB
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once
#include <aws/timestream-query/TimestreamQuery_EXPORTS.h>
#include <aws/core/client/GenericClientConfiguration.h>
#include <aws/timestream-query/TimestreamQueryClientConfiguration.h>
#include <aws/core/endpoint/DefaultEndpointProvider.h>
#include <aws/core/endpoint/EndpointParameter.h>
#include <aws/core/utils/memory/stl/AWSString.h>
Expand All @@ -20,14 +20,20 @@ namespace TimestreamQuery
{
namespace Endpoint
{
using TimestreamQueryClientConfiguration = Aws::TimestreamQuery::TimestreamQueryClientConfiguration;
using EndpointParameters = Aws::Endpoint::EndpointParameters;
using Aws::Endpoint::EndpointProviderBase;
using Aws::Endpoint::DefaultEndpointProvider;

using TimestreamQueryClientContextParameters = Aws::Endpoint::ClientContextParameters;

using TimestreamQueryClientConfiguration = Aws::Client::GenericClientConfiguration;
using TimestreamQueryBuiltInParameters = Aws::Endpoint::BuiltInParameters;
class AWS_TIMESTREAMQUERY_API TimestreamQueryBuiltInParameters : public Aws::Endpoint::BuiltInParameters
{
public:
virtual ~TimestreamQueryBuiltInParameters(){};
using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration;
virtual void SetFromClientConfiguration(const TimestreamQueryClientConfiguration& config);
};

/**
* The type for the TimestreamQuery Client Endpoint Provider.
Expand All @@ -40,6 +46,25 @@ using TimestreamQueryEndpointProviderBase =
using TimestreamQueryDefaultEpProviderBase =
DefaultEndpointProvider<TimestreamQueryClientConfiguration, TimestreamQueryBuiltInParameters, TimestreamQueryClientContextParameters>;

} // namespace Endpoint
} // namespace TimestreamQuery

namespace Endpoint
{
/**
* Export endpoint provider symbols for Windows DLL, otherwise declare as extern
*/
AWS_TIMESTREAMQUERY_EXTERN template class AWS_TIMESTREAMQUERY_API
Aws::Endpoint::EndpointProviderBase<TimestreamQuery::Endpoint::TimestreamQueryClientConfiguration, TimestreamQuery::Endpoint::TimestreamQueryBuiltInParameters, TimestreamQuery::Endpoint::TimestreamQueryClientContextParameters>;

AWS_TIMESTREAMQUERY_EXTERN template class AWS_TIMESTREAMQUERY_API
Aws::Endpoint::DefaultEndpointProvider<TimestreamQuery::Endpoint::TimestreamQueryClientConfiguration, TimestreamQuery::Endpoint::TimestreamQueryBuiltInParameters, TimestreamQuery::Endpoint::TimestreamQueryClientContextParameters>;
} // namespace Endpoint

namespace TimestreamQuery
{
namespace Endpoint
{
/**
* Default endpoint provider used for this service
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,31 @@

namespace Aws
{
#ifndef AWS_TIMESTREAMQUERY_EXPORTS // Except for Windows DLL
namespace Endpoint
{
/**
* Instantiate endpoint providers
*/
template class Aws::Endpoint::EndpointProviderBase<TimestreamQuery::Endpoint::TimestreamQueryClientConfiguration,
TimestreamQuery::Endpoint::TimestreamQueryBuiltInParameters,
TimestreamQuery::Endpoint::TimestreamQueryClientContextParameters>;

template class Aws::Endpoint::DefaultEndpointProvider<TimestreamQuery::Endpoint::TimestreamQueryClientConfiguration,
TimestreamQuery::Endpoint::TimestreamQueryBuiltInParameters,
TimestreamQuery::Endpoint::TimestreamQueryClientContextParameters>;
} // namespace Endpoint
#endif

namespace TimestreamQuery
{
namespace Endpoint
{
void TimestreamQueryBuiltInParameters::SetFromClientConfiguration(const TimestreamQueryClientConfiguration& config)
{
SetFromClientConfiguration(static_cast<const TimestreamQueryClientConfiguration::BaseClientConfigClass&>(config));

}
} // namespace Endpoint
} // namespace TimestreamQuery
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once
#include <aws/timestream-write/TimestreamWrite_EXPORTS.h>
#include <aws/core/client/GenericClientConfiguration.h>
#include <aws/timestream-write/TimestreamWriteClientConfiguration.h>
#include <aws/core/endpoint/DefaultEndpointProvider.h>
#include <aws/core/endpoint/EndpointParameter.h>
#include <aws/core/utils/memory/stl/AWSString.h>
Expand All @@ -20,14 +20,20 @@ namespace TimestreamWrite
{
namespace Endpoint
{
using TimestreamWriteClientConfiguration = Aws::TimestreamWrite::TimestreamWriteClientConfiguration;
using EndpointParameters = Aws::Endpoint::EndpointParameters;
using Aws::Endpoint::EndpointProviderBase;
using Aws::Endpoint::DefaultEndpointProvider;

using TimestreamWriteClientContextParameters = Aws::Endpoint::ClientContextParameters;

using TimestreamWriteClientConfiguration = Aws::Client::GenericClientConfiguration;
using TimestreamWriteBuiltInParameters = Aws::Endpoint::BuiltInParameters;
class AWS_TIMESTREAMWRITE_API TimestreamWriteBuiltInParameters : public Aws::Endpoint::BuiltInParameters
{
public:
virtual ~TimestreamWriteBuiltInParameters(){};
using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration;
virtual void SetFromClientConfiguration(const TimestreamWriteClientConfiguration& config);
};

/**
* The type for the TimestreamWrite Client Endpoint Provider.
Expand All @@ -40,6 +46,25 @@ using TimestreamWriteEndpointProviderBase =
using TimestreamWriteDefaultEpProviderBase =
DefaultEndpointProvider<TimestreamWriteClientConfiguration, TimestreamWriteBuiltInParameters, TimestreamWriteClientContextParameters>;

} // namespace Endpoint
} // namespace TimestreamWrite

namespace Endpoint
{
/**
* Export endpoint provider symbols for Windows DLL, otherwise declare as extern
*/
AWS_TIMESTREAMWRITE_EXTERN template class AWS_TIMESTREAMWRITE_API
Aws::Endpoint::EndpointProviderBase<TimestreamWrite::Endpoint::TimestreamWriteClientConfiguration, TimestreamWrite::Endpoint::TimestreamWriteBuiltInParameters, TimestreamWrite::Endpoint::TimestreamWriteClientContextParameters>;

AWS_TIMESTREAMWRITE_EXTERN template class AWS_TIMESTREAMWRITE_API
Aws::Endpoint::DefaultEndpointProvider<TimestreamWrite::Endpoint::TimestreamWriteClientConfiguration, TimestreamWrite::Endpoint::TimestreamWriteBuiltInParameters, TimestreamWrite::Endpoint::TimestreamWriteClientContextParameters>;
} // namespace Endpoint

namespace TimestreamWrite
{
namespace Endpoint
{
/**
* Default endpoint provider used for this service
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,31 @@

namespace Aws
{
#ifndef AWS_TIMESTREAMWRITE_EXPORTS // Except for Windows DLL
namespace Endpoint
{
/**
* Instantiate endpoint providers
*/
template class Aws::Endpoint::EndpointProviderBase<TimestreamWrite::Endpoint::TimestreamWriteClientConfiguration,
TimestreamWrite::Endpoint::TimestreamWriteBuiltInParameters,
TimestreamWrite::Endpoint::TimestreamWriteClientContextParameters>;

template class Aws::Endpoint::DefaultEndpointProvider<TimestreamWrite::Endpoint::TimestreamWriteClientConfiguration,
TimestreamWrite::Endpoint::TimestreamWriteBuiltInParameters,
TimestreamWrite::Endpoint::TimestreamWriteClientContextParameters>;
} // namespace Endpoint
#endif

namespace TimestreamWrite
{
namespace Endpoint
{
void TimestreamWriteBuiltInParameters::SetFromClientConfiguration(const TimestreamWriteClientConfiguration& config)
{
SetFromClientConfiguration(static_cast<const TimestreamWriteClientConfiguration::BaseClientConfigClass&>(config));

}
} // namespace Endpoint
} // namespace TimestreamWrite
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j;

import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.ClientContextParams;
import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.EndpointRuleSetModel;
import com.amazonaws.util.awsclientgenerator.domainmodels.endpoints.EndpointTests;
import lombok.Data;

Expand All @@ -19,7 +20,8 @@ public class C2jServiceModel {
Map<String, C2jShape> shapes;
Map<String, C2jOperation> operations;
String serviceName;
String endpointRules;
String endpointRules; // as a blob
EndpointRuleSetModel endpointRuleSetModel;
EndpointTests endpointTests;
ClientContextParams clientContextParams;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

package com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration;

import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class EndpointRuleSetModel {
@Data
public static class Parameter {
@Data
public static class Deprecated {
private String message;
private String since;

}

private String type; // required in schema
private String builtIn;
private boolean required;
private String documentation;
private Deprecated deprecated;

}

private String version;
private String serviceId;
private Map<String, Parameter> parameters;
// private List<Rule> rules; // ignored by this SDK code gen at the moment
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public boolean hasOnlyBearerAuth() {
return operations.values().parallelStream().allMatch(operation -> operation.getSignerName().equals("Aws::Auth::BEARER_SIGNER"));
}

public boolean hasServiceSpecificClientConfig() {
return metadata.getServiceId().equalsIgnoreCase("S3") ||
metadata.getServiceId().equalsIgnoreCase("S3-CRT") ||
metadata.getServiceId().equalsIgnoreCase("S3 Control") ||
metadata.isHasEndpointDiscoveryTrait() ||
endpointRuleSetModel.getParameters().containsKey("AccountId") || endpointRuleSetModel.getParameters().containsKey("AccountIdEndpointMode");
}

public Operation getOperationForRequestShapeName(String requestShapeName) {
for (Map.Entry<String, Operation> opEntry : operations.entrySet()) {
Operation op = opEntry.getValue();
Expand All @@ -71,7 +79,8 @@ public Operation getOperationForRequestShapeName(String requestShapeName) {
return null;
}

String endpointRules;
String endpointRules; // as a blob
EndpointRuleSetModel endpointRuleSetModel;
EndpointTests endpointTests;
ClientContextParams clientContextParams;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.amazonaws.util.awsclientgenerator.generators;

import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jServiceModel;
import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.EndpointRuleSetModel;
import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.PartitionsModel;
import com.amazonaws.util.awsclientgenerator.domainmodels.defaults.BaseOption;
import com.amazonaws.util.awsclientgenerator.domainmodels.defaults.BaseOptionModifier;
Expand Down Expand Up @@ -42,6 +43,8 @@ public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, Strin
C2jServiceModel c2jServiceModel = gson.fromJson(rawJson, C2jServiceModel.class);
c2jServiceModel.setServiceName(serviceName);
c2jServiceModel.setEndpointRules(endpointRuleSet);
EndpointRuleSetModel endpointRuleSetBom = parseEndpointRuleSet(endpointRuleSet);
c2jServiceModel.setEndpointRuleSetModel(endpointRuleSetBom);
if (endpointRulesTests != null) {
EndpointTests endpointTestsModel = gson.fromJson(endpointRulesTests, EndpointTests.class);
c2jServiceModel.setEndpointTests(endpointTestsModel);
Expand Down Expand Up @@ -127,6 +130,18 @@ public PartitionsModel parsePartitions(final String rawJson) {
return gson.fromJson(rawJson, PartitionsModel.class);
}

/**
* Parse rawJson into a structured EndpointRuleSet object
*
* @param rawJson the raw json representation of the partitions object.
* @return a parsed object of partitions.
*/
public EndpointRuleSetModel parseEndpointRuleSet(final String rawJson) {
Gson gson = new Gson();
return gson.fromJson(rawJson, EndpointRuleSetModel.class);
}


/**
* A function to generate C++ source for service client tests
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ public SdkFileEntry[] generateSourceFiles(ServiceModel serviceModel) throws Exce
fileList.add(generateEndpointProviderHeaderFile(serviceModel));
fileList.add(generateEndpointProviderSourceFile(serviceModel));

if (serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3") ||
serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3-CRT") ||
serviceModel.getMetadata().getServiceId().equalsIgnoreCase("S3 Control") ||
serviceModel.getMetadata().isHasEndpointDiscoveryTrait()) {
if (serviceModel.hasServiceSpecificClientConfig()) {
fileList.add(generateServiceClientConfigurationHeaderFile(serviceModel));
fileList.add(generateServiceClientConfigurationSourceFile(serviceModel));
}
Expand Down
Loading

0 comments on commit 3e7e76a

Please sign in to comment.