public static bool CheckForDomains(string[] expectedDomains, AmazonSimpleDBClient sdbClient) { VerifyKeys(); ListDomainsRequest listDomainsRequest = new ListDomainsRequest(); ListDomainsResponse listDomainsResponse = sdbClient.ListDomains(listDomainsRequest); if (listDomainsResponse.IsSetListDomainsResult()) { ListDomainsResult result = listDomainsResponse.ListDomainsResult; foreach (string expectedDomain in expectedDomains) { if (!result.DomainName.Contains(expectedDomain)) { // No point checking any more domains because // at least 1 domain doesn't exist return false; } } // We got this far, indicating that all expectedDomains // were found in the domain list return true; } // No results were returned by the ListDomains call // or something else went wrong return false; }
protected override void ProcessRecord() { AmazonSimpleDB client = base.GetClient(); Amazon.SimpleDB.Model.ListDomainsRequest request = new Amazon.SimpleDB.Model.ListDomainsRequest(); request.MaxNumberOfDomains = this._MaxNumberOfDomains; request.NextToken = this._NextToken; Amazon.SimpleDB.Model.ListDomainsResponse response = client.ListDomains(request); base.WriteObject(response.ListDomainsResult, true); }
public static bool DoesDomainExist(string domainName, AmazonSimpleDB sdbClient) { ListDomainsRequest listDomainsRequest = new ListDomainsRequest(); ListDomainsResult result = sdbClient.ListDomains(listDomainsRequest).ListDomainsResult; if (result != null) { return result.DomainName.Contains(domainName); } return false; }
public static void CheckForDomain(string domainName, AmazonSimpleDB sdbClient) { VerifyKeys(); ListDomainsRequest listDomainsRequest = new ListDomainsRequest(); ListDomainsResponse listDomainsResponse = sdbClient.ListDomains(listDomainsRequest); if (!listDomainsResponse.ListDomainsResult.DomainName.Contains(domainName)) { CreateDomainRequest createDomainRequest = new CreateDomainRequest().WithDomainName(domainName); sdbClient.CreateDomain(createDomainRequest); } }
public SimpleDBAppender() { var client = new AmazonSimpleDBClient(); ListDomainsRequest request=new ListDomainsRequest(); var response = client.ListDomains(request); bool found = response.ListDomainsResult.DomainName.Any(d => d == DBName); if (!found) { CreateDomainRequest createDomainRequest = new CreateDomainRequest { DomainName = DBName }; client.CreateDomain(createDomainRequest); } }
public virtual bool DoesDomainExist(string domainName) { var exists = false; var client = this.GetClient(); var request = new ListDomainsRequest(); var response = client.ListDomains(request); response.ListDomainsResult.DomainName.ForEach(x => { if (x == domainName) { exists = true; } }); return exists; }
public override void ActivateOptions() { base.ActivateOptions(); var client = new AmazonSimpleDBClient(Utility.GetRegionEndpoint()); var request = new ListDomainsRequest(); var response = client.ListDomains(request); bool found = response.ListDomainsResult.DomainNames.Any(d => d == DBName); if (!found) { var createDomainRequest = new CreateDomainRequest { DomainName = DBName }; client.CreateDomain(createDomainRequest); } }
public static string GetServiceOutput() { StringBuilder sb = new StringBuilder(1024); using (StringWriter sr = new StringWriter(sb)) { sr.WriteLine("==========================================="); sr.WriteLine("Welcome to the AWS .NET SDK!"); sr.WriteLine("==========================================="); // Print the number of Amazon EC2 instances. IAmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(); DescribeInstancesRequest ec2Request = new DescribeInstancesRequest(); try { DescribeInstancesResponse ec2Response = ec2.DescribeInstances(ec2Request); int numInstances = 0; numInstances = ec2Response.Reservations.Count; sr.WriteLine(string.Format("You have {0} Amazon EC2 instance(s) running in the {1} region.", numInstances, ConfigurationManager.AppSettings["AWSRegion"])); } catch (AmazonEC2Exception ex) { if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure")) { sr.WriteLine("The account you are using is not signed up for Amazon EC2."); sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2"); } else { sr.WriteLine("Caught Exception: " + ex.Message); sr.WriteLine("Response Status Code: " + ex.StatusCode); sr.WriteLine("Error Code: " + ex.ErrorCode); sr.WriteLine("Error Type: " + ex.ErrorType); sr.WriteLine("Request ID: " + ex.RequestId); } } sr.WriteLine(); // Print the number of Amazon SimpleDB domains. IAmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(); ListDomainsRequest sdbRequest = new ListDomainsRequest(); try { ListDomainsResponse sdbResponse = sdb.ListDomains(sdbRequest); int numDomains = 0; numDomains = sdbResponse.DomainNames.Count; sr.WriteLine(string.Format("You have {0} Amazon SimpleDB domain(s) in the {1} region.", numDomains, ConfigurationManager.AppSettings["AWSRegion"])); } catch (AmazonSimpleDBException ex) { if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure")) { sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB."); sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb"); } else { sr.WriteLine("Caught Exception: " + ex.Message); sr.WriteLine("Response Status Code: " + ex.StatusCode); sr.WriteLine("Error Code: " + ex.ErrorCode); sr.WriteLine("Error Type: " + ex.ErrorType); sr.WriteLine("Request ID: " + ex.RequestId); } } sr.WriteLine(); // Print the number of Amazon S3 Buckets. IAmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(); try { ListBucketsResponse response = s3Client.ListBuckets(); int numBuckets = 0; if (response.Buckets != null && response.Buckets.Count > 0) { numBuckets = response.Buckets.Count; } sr.WriteLine("You have " + numBuckets + " Amazon S3 bucket(s)."); } catch (AmazonS3Exception ex) { if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") || ex.ErrorCode.Equals("InvalidSecurity"))) { sr.WriteLine("Please check the provided AWS Credentials."); sr.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3"); } else { sr.WriteLine("Caught Exception: " + ex.Message); sr.WriteLine("Response Status Code: " + ex.StatusCode); sr.WriteLine("Error Code: " + ex.ErrorCode); sr.WriteLine("Request ID: " + ex.RequestId); } } sr.WriteLine("Press any key to continue..."); } return sb.ToString(); }
/// <summary> /// Initiates the asynchronous execution of the ListDomains operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListDomains operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<ListDomainsResponse> ListDomainsAsync(ListDomainsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListDomainsRequestMarshaller(); var unmarshaller = ListDomainsResponseUnmarshaller.Instance; return InvokeAsync<ListDomainsRequest,ListDomainsResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// The <code>ListDomains</code> operation lists all domains associated with the Access /// Key ID. It returns domain names up to the limit set by <a href="#MaxNumberOfDomains">MaxNumberOfDomains</a>. /// A <a href="#NextToken">NextToken</a> is returned if there are more than <code>MaxNumberOfDomains</code> /// domains. Calling <code>ListDomains</code> successive times with the <code>NextToken</code> /// provided by the operation returns up to <code>MaxNumberOfDomains</code> more domain /// names with each successive operation call. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ListDomains service method.</param> /// /// <returns>The response from the ListDomains service method, as returned by SimpleDB.</returns> /// <exception cref="InvalidNextTokenException"> /// The specified NextToken is not valid. /// </exception> /// <exception cref="InvalidParameterValueException"> /// The value for a parameter is invalid. /// </exception> public ListDomainsResponse ListDomains(ListDomainsRequest request) { var marshaller = new ListDomainsRequestMarshaller(); var unmarshaller = ListDomainsResponseUnmarshaller.Instance; return Invoke<ListDomainsRequest,ListDomainsResponse>(request, marshaller, unmarshaller); }
private void EnsureDomain(string domain) { var listDomainsRequest = new ListDomainsRequest(); var listDomainsResponse = _client.ListDomains(listDomainsRequest); if (listDomainsResponse.ListDomainsResult.DomainName.Contains(domain)) { return; } var createDomainRequest = new CreateDomainRequest {DomainName = domain}; _client.CreateDomain(createDomainRequest); }
private void WriteSimpleDBInfo() { StringBuilder output = new StringBuilder(); ListDomainsRequest sdbRequest = new ListDomainsRequest(); ListDomainsResponse sdbResponse = sdb.ListDomains(sdbRequest); foreach (string domain in sdbResponse.ListDomainsResult.DomainName) { output.AppendFormat("<li>{0}</li>", domain); } this.sdbPlaceholder.Text = output.ToString(); }
private void ListDomainButton_Click(object sender, RoutedEventArgs e) { SimpleDB.Client.OnSimpleDBResponse += ListDomainWebResponse; ListDomainsRequest request = new ListDomainsRequest(); this.ListDomainMessage = "Please wait..."; this.DomainNameList.Clear(); SimpleDB.Client.BeginListDomains(request); }
/// <summary> /// Initiates the asynchronous execution of the ListDomains operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.ListDomains"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListDomains operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<ListDomainsResponse> ListDomainsAsync(ListDomainsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListDomainsRequestMarshaller(); var unmarshaller = ListDomainsResponseUnmarshaller.GetInstance(); return Invoke<IRequest, ListDomainsRequest, ListDomainsResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
public List<string> GetDomains() { ListDomainsRequest ListDomainsAction = new ListDomainsRequest(); ListDomainsResponse response = Service.ListDomains(ListDomainsAction); return response.ListDomainsResult.DomainName; }
internal ListDomainsResponse ListDomains(ListDomainsRequest request) { var task = ListDomainsAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
private IEnumerable<string> ListDomains() { var request = new ListDomainsRequest(); while (request != null) { var response = client.ListDomains(request); foreach (var domain in response.ListDomainsResult.DomainName) { yield return domain; } if (response.ListDomainsResult.IsSetNextToken()) { request.NextToken = response.ListDomainsResult.NextToken; } else { request = null; } } }
/// <summary> /// Initiates the asynchronous execution of the ListDomains operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListDomains operation on AmazonSimpleDBClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListDomains /// operation.</returns> public IAsyncResult BeginListDomains(ListDomainsRequest request, AsyncCallback callback, object state) { var marshaller = new ListDomainsRequestMarshaller(); var unmarshaller = ListDomainsResponseUnmarshaller.Instance; return BeginInvoke<ListDomainsRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Fetches the domain names and populates them to the domain list box. /// </summary> private void PopulateDomainNames() { SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { SimpleDB.Client.OnSimpleDBResponse -= handler; ListDomainsResponse response = args.Response as ListDomainsResponse; if (null != response) { ListDomainsResult listResult = response.ListDomainsResult; if (null != listResult) { this.Dispatcher.BeginInvoke(() => { this.DomainNameList.Clear(); listResult.DomainName.ForEach(domain => this.DomainNameList.Add(domain)); }); } } }; //Show a wait message. this.Dispatcher.BeginInvoke(() => { this.DomainNameList.Clear(); this.DomainNameList.Add("Please wait..."); }); SimpleDB.Client.OnSimpleDBResponse += handler; ListDomainsRequest request = new ListDomainsRequest(); SimpleDB.Client.BeginListDomains(request); }
IAsyncResult AmazonSimpleDB.BeginListDomains(ListDomainsRequest request, AsyncCallback callback, object state) { throw new NotImplementedException(); }
IAsyncResult invokeListDomains(ListDomainsRequest listDomainsRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new ListDomainsRequestMarshaller().Marshall(listDomainsRequest); var unmarshaller = ListDomainsResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
ListDomainsResponse AmazonSimpleDB.ListDomains(ListDomainsRequest request) { throw new NotImplementedException(); }
/// <summary> /// <para> The <c>ListDomains</c> operation lists all domains associated with the Access Key ID. It returns domain names up to the limit set by /// <a href="#MaxNumberOfDomains">MaxNumberOfDomains</a> . /// A <a href="#NextToken">NextToken</a> is returned if there are more than <c>MaxNumberOfDomains</c> domains. Calling /// <c>ListDomains</c> successive times with the <c>NextToken</c> provided by the operation returns up to <c>MaxNumberOfDomains</c> more domain /// names with each successive operation call. </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListDomains service method on AmazonSimpleDB.</param> /// /// <returns>The response from the ListDomains service method, as returned by AmazonSimpleDB.</returns> /// /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" /> /// <exception cref="T:Amazon.SimpleDB.Model.InvalidNextTokenException" /> public ListDomainsResponse ListDomains(ListDomainsRequest request) { var task = ListDomainsAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// <para> The <c>ListDomains</c> operation lists all domains associated with the Access Key ID. It returns domain names up to the limit set by /// <a href="#MaxNumberOfDomains" >MaxNumberOfDomains</a> . /// A <a href="#NextToken" >NextToken</a> is returned if there are more than <c>MaxNumberOfDomains</c> domains. Calling /// <c>ListDomains</c> successive times with the <c>NextToken</c> provided by the operation returns up to <c>MaxNumberOfDomains</c> more domain /// names with each successive operation call. </para> /// </summary> /// /// <param name="listDomainsRequest">Container for the necessary parameters to execute the ListDomains service method on AmazonSimpleDB.</param> /// /// <returns>The response from the ListDomains service method, as returned by AmazonSimpleDB.</returns> /// /// <exception cref="InvalidParameterValueException"/> /// <exception cref="InvalidNextTokenException"/> public ListDomainsResponse ListDomains(ListDomainsRequest listDomainsRequest) { IAsyncResult asyncResult = invokeListDomains(listDomainsRequest, null, null, true); return EndListDomains(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the ListDomains operation. /// <seealso cref="Amazon.SimpleDB.IAmazonSimpleDB.ListDomains"/> /// </summary> /// /// <param name="listDomainsRequest">Container for the necessary parameters to execute the ListDomains operation on AmazonSimpleDB.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListDomains /// operation.</returns> public IAsyncResult BeginListDomains(ListDomainsRequest listDomainsRequest, AsyncCallback callback, object state) { return invokeListDomains(listDomainsRequest, callback, state, false); }
/// <summary> /// <para> The <c>ListDomains</c> operation lists all domains associated with the Access Key ID. It returns domain names up to the limit set by /// <a href="#MaxNumberOfDomains">MaxNumberOfDomains</a> . /// A <a href="#NextToken">NextToken</a> is returned if there are more than <c>MaxNumberOfDomains</c> domains. Calling /// <c>ListDomains</c> successive times with the <c>NextToken</c> provided by the operation returns up to <c>MaxNumberOfDomains</c> more domain /// names with each successive operation call. </para> /// </summary> /// /// <param name="listDomainsRequest">Container for the necessary parameters to execute the ListDomains service method on AmazonSimpleDB.</param> /// /// <returns>The response from the ListDomains service method, as returned by AmazonSimpleDB.</returns> /// /// <exception cref="T:Amazon.SimpleDB.Model.InvalidParameterValueException" /> /// <exception cref="T:Amazon.SimpleDB.Model.InvalidNextTokenException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public async Task<ListDomainsResponse> ListDomainsAsync(ListDomainsRequest listDomainsRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListDomainsRequestMarshaller(); var unmarshaller = ListDomainsResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, ListDomainsRequest, ListDomainsResponse>(listDomainsRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
public bool DomainExists(string domainName) { var sdbRequest = new ListDomainsRequest(); var sdbResponse = _simpleDbClient.ListDomains(sdbRequest); return sdbResponse.ListDomainsResult.DomainName.Exists(x => x.Equals(domainName)); }