Beispiel #1
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonGlueConfig config = new AmazonGlueConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonGlueClient client = new AmazonGlueClient(creds, config);

            GetDatabasesResponse resp = new GetDatabasesResponse();

            do
            {
                GetDatabasesRequest req = new GetDatabasesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.GetDatabases(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.DatabaseList)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDatabasesResponse response = new GetDatabasesResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("DatabaseList", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Database, DatabaseUnmarshaller>(DatabaseUnmarshaller.Instance);
                    response.DatabaseList = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public async Task ListDatabasesAsync_ShouldSucceed()
        {
            GetDatabasesResponse result = await _fixture.DatabaseClientSystem.GetDatabasesAsync();

            Assert.False(result.Error);
            Assert.Equal(HttpStatusCode.OK, result.Code);
            Assert.True(result.Result.Count() > 0);
        }
        public async Task GetCurrentDatabaseInfoAsync_ShouldReturnError_WhenDatabaseDoesNotExist()
        {
            GetDatabasesResponse getDatabasesResponse = await _fixture.DatabaseClientNonExistent.GetDatabasesAsync();

            Assert.False(getDatabasesResponse.IsSuccess);
            Assert.Equal(HttpStatusCode.NotFound, getDatabasesResponse.ResponseDetails.Code);
            Assert.Equal(1228, getDatabasesResponse.ResponseDetails.ErrorNum);
        }
        public async Task ListUserDatabasesAsync_ShouldSucceed()
        {
            GetDatabasesResponse result = await _fixture.DatabaseClientOther.GetUserDatabasesAsync();

            Assert.False(result.ResponseDetails.Error);
            Assert.Equal(HttpStatusCode.OK, result.ResponseDetails.Code);
            Assert.True(result.Results.Count > 0);
        }
        public async Task ListDatabasesAsync_ShouldReturnError_WhenDatabaseIsNotSystem()
        {
            GetDatabasesResponse getDatabasesResponse = await _fixture.DatabaseClientOther.GetDatabasesAsync();

            Assert.False(getDatabasesResponse.IsSuccess);
            Assert.Equal(HttpStatusCode.Forbidden, getDatabasesResponse.ResponseDetails.Code);
            Assert.Equal(1230, getDatabasesResponse.ResponseDetails.ErrorNum);
        }
        public async Task ListDatabasesAsync_ShouldThrow_WhenDatabaseDoesNotExist()
        {
            _systemClient.ThrowErrorsAsExceptions = true;
            GetDatabasesResponse getDatabasesResponse = await _fixture.DatabaseClientNonExistent.GetDatabasesAsync();

            Assert.False(getDatabasesResponse.IsSuccess);
            Assert.Equal(HttpStatusCode.NotFound, getDatabasesResponse.ResponseDetails.Code);
            Assert.Equal(1228, getDatabasesResponse.ResponseDetails.ErrorNum);
        }