示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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;
            }
        }
示例#4
0
        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);
        }