public async Task <IEnumerable <AttributeKey> > GetAttributeKeys(TempSessionWithSecrets userSession, string objectId) { var attributeApi = new AttributeApi(); attributeApi.Configuration.ApiKey["api_key"] = userSession.ApiKey; return(await attributeApi.AttributesGetAsync(objectId)); }
public async Task SetAttribute <T>(TempSessionWithSecrets userSession, string objectId, string key, T value) { var attributeApi = new AttributeApi(); attributeApi.Configuration.ApiKey["api_key"] = userSession.ApiKey; await attributeApi.AttributePutAsync(objectId, key, JsonConvert.SerializeObject(value)); }
public async Task <T> GetAttribute <T>(TempSessionWithSecrets userSession, string objectId, string ownerId, string key) { var attributeApi = new AttributeApi(); attributeApi.Configuration.ApiKey["api_key"] = userSession.ApiKey; try { var result = await attributeApi.AttributeGetAsync(objectId, key, ownerId); return(JsonConvert.DeserializeObject <T>(result.Value)); } catch (JsonException) { // Badly formatted data, to prevent other sessions // potentially causing issues by storing incorrect data, // we just return the default value for T here. return(default(T)); } catch (ApiException ex) { if (ex.ErrorCode == 404) { return(default(T)); } throw; } }
internal RestApi(string serverUrl, string apiKey) { mBaseUri = new Uri(serverUrl); mApiKey = apiKey; Users = new UsersApi(mBaseUri, apiKey); MergeReports = new MergeReportsApi(mBaseUri, apiKey); Issues = new IssuesApi(mBaseUri, apiKey); Notify = new NotifyApi(mBaseUri, apiKey); CI = new CIApi(mBaseUri, apiKey); Labels = new LabelApi(mBaseUri, apiKey); Attributes = new AttributeApi(mBaseUri, apiKey); CodeReviews = new CodeReviewApi(mBaseUri, apiKey); }