17
17
18
18
using IBM . Cloud . SDK . Utilities ;
19
19
using System ;
20
- using System . Collections . Generic ;
21
-
20
+ using System . Collections . Generic ;
21
+
22
22
namespace IBM . Cloud . SDK
23
23
{
24
24
public class BaseService
@@ -40,7 +40,11 @@ public BaseService(string serviceId)
40
40
}
41
41
}
42
42
43
- string ApiKey = Environment . GetEnvironmentVariable ( serviceId . ToUpper ( ) + "_APIKEY" ) ;
43
+ string ApiKey = Environment . GetEnvironmentVariable ( serviceId . ToUpper ( ) + "_IAM_APIKEY" ) ;
44
+ // check for old IAM API key name as well
45
+ if ( string . IsNullOrEmpty ( apiKey ) ) {
46
+ apiKey = Environment . GetEnvironmentVariable ( ServiceName . ToUpper ( ) + "_APIKEY" ) ;
47
+ }
44
48
string Username = Environment . GetEnvironmentVariable ( serviceId . ToUpper ( ) + "_USERNAME" ) ;
45
49
string Password = Environment . GetEnvironmentVariable ( serviceId . ToUpper ( ) + "_PASSWORD" ) ;
46
50
string ServiceUrl = Environment . GetEnvironmentVariable ( serviceId . ToUpper ( ) + "_URL" ) ;
@@ -78,36 +82,36 @@ public BaseService(string versionDate, Credentials credentials, string serviceId
78
82
79
83
public BaseService ( Credentials credentials , string serviceId ) { }
80
84
81
- public void WithHeader ( string name , string value )
85
+ public void WithHeader ( string name , string value )
82
86
{
83
- if ( ! customRequestHeaders . ContainsKey ( name ) )
84
- {
85
- customRequestHeaders . Add ( name , value ) ;
87
+ if ( ! customRequestHeaders . ContainsKey ( name ) )
88
+ {
89
+ customRequestHeaders . Add ( name , value ) ;
90
+ }
91
+ else
92
+ {
93
+ customRequestHeaders [ name ] = value ;
86
94
}
87
- else
88
- {
89
- customRequestHeaders [ name ] = value ;
90
- }
91
95
}
92
96
93
- public void WithHeaders ( Dictionary < string , string > headers )
97
+ public void WithHeaders ( Dictionary < string , string > headers )
94
98
{
95
- foreach ( KeyValuePair < string , string > kvp in headers )
99
+ foreach ( KeyValuePair < string , string > kvp in headers )
96
100
{
97
- if ( ! customRequestHeaders . ContainsKey ( kvp . Key ) )
98
- {
99
- customRequestHeaders . Add ( kvp . Key , kvp . Value ) ;
101
+ if ( ! customRequestHeaders . ContainsKey ( kvp . Key ) )
102
+ {
103
+ customRequestHeaders . Add ( kvp . Key , kvp . Value ) ;
104
+ }
105
+ else
106
+ {
107
+ customRequestHeaders [ kvp . Key ] = kvp . Value ;
100
108
}
101
- else
102
- {
103
- customRequestHeaders [ kvp . Key ] = kvp . Value ;
104
- }
105
- }
109
+ }
106
110
}
107
111
108
- protected void ClearCustomRequestHeaders ( )
109
- {
110
- customRequestHeaders = new Dictionary < string , string > ( ) ;
112
+ protected void ClearCustomRequestHeaders ( )
113
+ {
114
+ customRequestHeaders = new Dictionary < string , string > ( ) ;
111
115
}
112
116
}
113
117
}
0 commit comments