@@ -82,6 +82,8 @@ protected abstract string ToolName
8282 get ;
8383 }
8484
85+ protected string UserAgentString => GetUserAgentString ( ) ;
86+
8587 /// <summary>
8688 /// The common options used by every command
8789 /// </summary>
@@ -753,11 +755,10 @@ private int WaitForIndexResponse(int min, int max)
753755 public IToolLogger Logger { get ; protected set ; }
754756 public string WorkingDirectory { get ; set ; }
755757
756- protected void SetUserAgentString ( )
758+ protected string GetUserAgentString ( )
757759 {
758760 string version = this . GetType ( ) . GetTypeInfo ( ) . Assembly . GetName ( ) . Version . ToString ( ) ;
759- Util . Internal . InternalSDKUtils . SetUserAgent ( this . ToolName ,
760- version ) ;
761+ return $ "lib/{ this . ToolName } #{ version } ";
761762 }
762763
763764 IAmazonSecurityTokenService _stsClient ;
@@ -767,12 +768,11 @@ public IAmazonSecurityTokenService STSClient
767768 {
768769 if ( this . _stsClient == null )
769770 {
770- SetUserAgentString ( ) ;
771-
772771 var config = new AmazonSecurityTokenServiceConfig ( ) ;
773772 config . RegionEndpoint = DetermineAWSRegion ( ) ;
774773
775774 this . _stsClient = new AmazonSecurityTokenServiceClient ( DetermineAWSCredentials ( ) , config ) ;
775+ Utilities . SetUserAgentString ( ( AmazonServiceClient ) _stsClient , UserAgentString ) ;
776776 }
777777 return this . _stsClient ;
778778 }
@@ -786,12 +786,11 @@ public IAmazonIdentityManagementService IAMClient
786786 {
787787 if ( this . _iamClient == null )
788788 {
789- SetUserAgentString ( ) ;
790-
791789 var config = new AmazonIdentityManagementServiceConfig ( ) ;
792790 config . RegionEndpoint = DetermineAWSRegion ( ) ;
793791
794792 this . _iamClient = new AmazonIdentityManagementServiceClient ( DetermineAWSCredentials ( ) , config ) ;
793+ Utilities . SetUserAgentString ( ( AmazonServiceClient ) _iamClient , UserAgentString ) ;
795794 }
796795 return this . _iamClient ;
797796 }
@@ -805,13 +804,12 @@ public IAmazonS3 S3Client
805804 {
806805 if ( this . _s3Client == null )
807806 {
808- SetUserAgentString ( ) ;
809-
810807 var config = new AmazonS3Config ( ) ;
811808 config . RegionEndpoint = DetermineAWSRegion ( ) ;
812809 config . Timeout = TimeSpan . FromHours ( 1 ) ;
813810
814811 this . _s3Client = new AmazonS3Client ( DetermineAWSCredentials ( ) , config ) ;
812+ Utilities . SetUserAgentString ( ( AmazonServiceClient ) _s3Client , UserAgentString ) ;
815813 }
816814 return this . _s3Client ;
817815 }
@@ -825,12 +823,11 @@ public IAmazonECR ECRClient
825823 {
826824 if ( this . _ecrClient == null )
827825 {
828- SetUserAgentString ( ) ;
829-
830826 var config = new AmazonECRConfig ( ) ;
831827 config . RegionEndpoint = DetermineAWSRegion ( ) ;
832828
833829 this . _ecrClient = new AmazonECRClient ( DetermineAWSCredentials ( ) , config ) ;
830+ Utilities . SetUserAgentString ( ( AmazonServiceClient ) _ecrClient , UserAgentString ) ;
834831 }
835832 return this . _ecrClient ;
836833 }
0 commit comments