@@ -100,11 +100,11 @@ func GetServiceIDByName(c rest.FrontClient, name string) (akid.ServiceID, error)
100
100
func GetServiceNameByServiceID (c rest.FrontClient , serviceID akid.ServiceID ) (string , error ) {
101
101
unexpectedErrMsg := "Something went wrong while starting the Agent. " +
102
102
"Please contact Postman support (" + consts .SupportEmail + ") with the error details"
103
- failedToVerifyServiceErrMsg := "Failed to verify service for given serviceID : %s\n "
103
+ failedToGetProjectErrMsg := "Failed to get project for given projectID : %s\n "
104
104
105
105
// Check if service is already verified and cached
106
106
if service , found := serviceIDCache .Get (serviceID .String ()); found {
107
- printer .Stderr .Debugf ("Cached service %v for serviceID %s\n " , service , akid .String (serviceID ))
107
+ printer .Stderr .Debugf ("Cached project %v for projectID %s\n " , service , akid .String (serviceID ))
108
108
return service .(rest.InsightsService ).Name , nil
109
109
}
110
110
@@ -115,23 +115,23 @@ func GetServiceNameByServiceID(c rest.FrontClient, serviceID akid.ServiceID) (st
115
115
if err != nil {
116
116
httpErr , ok := err .(rest.HTTPError )
117
117
if ! ok {
118
- printer .Stderr .Debugf (failedToVerifyServiceErrMsg , err )
118
+ printer .Stderr .Debugf (failedToGetProjectErrMsg , err )
119
119
return "" , errors .Wrap (err , unexpectedErrMsg )
120
120
}
121
121
122
122
var errorResponse rest.ErrorResponse
123
123
if err := json .Unmarshal (httpErr .Body , & errorResponse ); err != nil {
124
- printer .Stderr .Debugf (failedToVerifyServiceErrMsg , err )
124
+ printer .Stderr .Debugf (failedToGetProjectErrMsg , err )
125
125
return "" , errors .Wrap (err , unexpectedErrMsg )
126
126
}
127
127
128
128
if httpErr .StatusCode == 404 {
129
129
//lint:ignore ST1005 This is a user-facing error message
130
- return "" , fmt .Errorf ("There is no service with given ID %s. Ensure that your service ID is correct" , serviceID )
130
+ return "" , fmt .Errorf ("There is no project with given ID %s. Ensure that your projectID is correct" , serviceID )
131
131
} else if httpErr .StatusCode == 403 {
132
132
//lint:ignore ST1005 This is a user-facing error message
133
- return "" , fmt .Errorf ("You cannot send traffic to the service with ID %s. " +
134
- "Ensure that your service ID is correct and that you have required permissions. " +
133
+ return "" , fmt .Errorf ("You cannot send traffic to the project with ID %s. " +
134
+ "Ensure that your projectID is correct and that you have required permissions. " +
135
135
"If you do not have required permissions, please contact the workspace administrator" , serviceID )
136
136
}
137
137
@@ -175,7 +175,7 @@ func GetOrCreateServiceIDByPostmanCollectionID(c rest.FrontClient, collectionID
175
175
collectionID = strings .ToLower (collectionID )
176
176
unexpectedErrMsg := "Something went wrong while starting the Agent. " +
177
177
"Please contact Postman support (" + consts .SupportEmail + ") with the error details"
178
- failedToCreateServiceErrMsg := "Failed to create service for given collectionID: %s\n "
178
+ failedToCreateProjectErrMsg := "Failed to create project for given collectionID: %s\n "
179
179
180
180
if id , found := postmanCollectionIDCache .Get (collectionID ); found {
181
181
printer .Stderr .Debugf ("Cached collectionID %q is %q\n " , collectionID , akid .String (id .(akid.ServiceID )))
@@ -188,47 +188,48 @@ func GetOrCreateServiceIDByPostmanCollectionID(c rest.FrontClient, collectionID
188
188
189
189
serviceID , err := GetServiceIDByPostmanCollectionID (c , ctx , collectionID )
190
190
if err != nil {
191
- printer .Stderr .Debugf ("Failed to get list of services associated with the API Key: %s\n " , err )
191
+ printer .Stderr .Debugf ("Failed to get list of projects associated with the API Key: %s\n " , err )
192
192
return akid.ServiceID {}, errors .Wrap (err , unexpectedErrMsg )
193
193
}
194
194
195
195
if (serviceID != akid.ServiceID {}) {
196
- printer .Stderr .Debugf ("ServiceID for Postman collectionID %q is %q\n " , collectionID , serviceID )
196
+ printer .Stderr .Debugf ("ProjectID for given Postman collectionID %q is %q\n " , collectionID , serviceID )
197
197
postmanCollectionIDCache .Set (collectionID , serviceID , cache .DefaultExpiration )
198
198
return serviceID , nil
199
199
}
200
200
201
201
name := postmanRandomName ()
202
- printer .Debugf ("Found no service for given collectionID: %s, creating a new service %q\n " , collectionID , name )
202
+ printer .Debugf ("Found no project for given collectionID: %s, creating a new project %q\n " , collectionID , name )
203
203
// Create service for given postman collectionID
204
204
resp , err := c .CreateService (ctx , name , collectionID )
205
205
if err != nil {
206
206
httpErr , ok := err .(rest.HTTPError )
207
207
if ! ok {
208
- printer .Stderr .Debugf (failedToCreateServiceErrMsg , err )
208
+ printer .Stderr .Debugf (failedToCreateProjectErrMsg , err )
209
209
return akid.ServiceID {}, errors .Wrap (err , unexpectedErrMsg )
210
210
}
211
211
212
212
var errorResponse rest.ErrorResponse
213
213
if err := json .Unmarshal (httpErr .Body , & errorResponse ); err != nil {
214
- printer .Stderr .Debugf (failedToCreateServiceErrMsg , err )
214
+ printer .Stderr .Debugf (failedToCreateProjectErrMsg , err )
215
215
return akid.ServiceID {}, errors .Wrap (err , unexpectedErrMsg )
216
216
}
217
217
218
218
if httpErr .StatusCode == 409 && errorResponse .Message == "collection_already_mapped" {
219
219
serviceID , err := GetServiceIDByPostmanCollectionID (c , ctx , collectionID )
220
220
if err != nil {
221
- printer .Stderr .Debugf (failedToCreateServiceErrMsg , err )
221
+ printer .Stderr .Debugf (failedToCreateProjectErrMsg , err )
222
222
return akid.ServiceID {}, errors .Wrap (err , unexpectedErrMsg )
223
223
}
224
224
225
225
if (serviceID != akid.ServiceID {}) {
226
- printer .Stderr .Debugf ("ServiceID for Postman collectionID %q is %q\n " , collectionID , serviceID )
226
+ printer .Stderr .Debugf ("ProjectID for Postman collectionID %q is %q\n " , collectionID , serviceID )
227
227
postmanCollectionIDCache .Set (collectionID , serviceID , cache .DefaultExpiration )
228
228
return serviceID , nil
229
229
}
230
230
231
231
} else if httpErr .StatusCode == 403 {
232
+ //lint:ignore ST1005 This is a user-facing error message
232
233
error := fmt .Errorf ("you cannot send traffic to the collection with ID %s. " +
233
234
"Ensure that your collection ID is correct and that you have edit permissions on the collection. " +
234
235
"If you do not have edit permissions, please contact the workspace administrator to add you as a collection editor." , collectionID )
@@ -238,7 +239,7 @@ func GetOrCreateServiceIDByPostmanCollectionID(c rest.FrontClient, collectionID
238
239
return akid.ServiceID {}, errors .Wrap (err , unexpectedErrMsg )
239
240
}
240
241
241
- printer .Debugf ("Got service ID %s\n " , resp .ResourceID )
242
+ printer .Debugf ("Got projectID %s\n " , resp .ResourceID )
242
243
postmanCollectionIDCache .Set (collectionID , resp .ResourceID , cache .DefaultExpiration )
243
244
244
245
return resp .ResourceID , nil
0 commit comments