Skip to content
New issue

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

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

Already on GitHub? # to your account

Adds AWSPaginator attribute to methods in Paginator Factory interface that PowerShell consumes #3726

Open
wants to merge 6 commits into
base: main-staging
Choose a base branch
from

Conversation

afroz429
Copy link
Contributor

@afroz429 afroz429 commented Mar 26, 2025

Description

AWS Tools for PowerShell's(AWS PS) auto-iteration implementation requires metadata for paginators. This PR adds AWSPaginator attribute to Paginator methods in the Paginator Factory interface. AWS PS will use this metadata for auto-iteration implementation.
The attribute properties that are being added are InputToken, LimitKey and OutputToken.

Added following generated files for review

  • sdk/src/Services/AccessAnalyzer/Generated/Model/_bcl45+netstandard/IAccessAnalyzerPaginatorFactory.cs
  • sdk/src/Services/SimpleWorkflow/Generated/Model/_bcl45+netstandard/ISimpleWorkflowPaginatorFactory.cs

Motivation and Context

Add metadata that AWS PS can use for generating auto-iteration.

Testing

DRY Run succeeded.
Tested AWS PS generation code after copying the assemblies and verifying that the attributes are readable.

            var pageFactoryInterfaceTypeName = string.Format("{0}.Model.I{1}PaginatorFactory", CurrentModel.ServiceNamespace, CurrentModel.AssemblyName);
            
            var pageFactoryInterfaceType = CurrentServiceAssembly.GetType(pageFactoryInterfaceTypeName);

            if (pageFactoryInterfaceType != null)
            {
                var pageFactoryInterfaceMethods = pageFactoryInterfaceType.GetMethods().OrderBy(m => m.Name).ToList();
                foreach (var pageFactoryMethod in pageFactoryInterfaceMethods)
                {
                    dynamic awsPaginatorFactoryAttribute = pageFactoryMethod
                        .GetCustomAttributes().SingleOrDefault(attribute =>
                            attribute.GetType().FullName == "Amazon.Runtime.Internal.AWSPaginatorAttribute");
                    if (awsPaginatorFactoryAttribute != null)
                    {
                        if (awsPaginatorFactoryAttribute.LimitKey == null)
                        {
                            Console.WriteLine("limitkey null");
                        }
                        Console.WriteLine(awsPaginatorFactoryAttribute);
                    }
                }
            
            }

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@afroz429 afroz429 changed the base branch from main to main-staging March 26, 2025 16:13
@afroz429 afroz429 requested a review from normj March 26, 2025 16:14
namespace Amazon.Runtime.Internal
{
[AttributeUsage(AttributeTargets.Method)]
public sealed class AWSPaginatorAttribute : Attribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add attributes above InputToken, LimitKey and OutputToken instead of the Paginator attribute? Then you can add them to the properties themselves, this way you can select the properties you need from the pagination request/response types in PowerShell based on the attributes instead of having to select them by name.

Copy link
Contributor Author

@afroz429 afroz429 Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add attributes above InputToken, LimitKey and OutputToken instead of the Paginator attribute?

Can you clarify this statement?

this way you can select the properties you need from the pagination request/response types in PowerShell

A paginator property value may not match the Request or Response property. InputToken and OutputToken values in paginators model file can be a list or a single property name. Additionally OutputToken can be a JMESPath e.g "output_token": "StreamDescription.Shards[-1].ShardId". Also semantically, the paginators model is defined for operations so makes more sense to add the metadata on the Paginators methods. See https://github.com/aws/aws-models/blob/master/secretsmanager/2017-10-17/paginators-1.json

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants