Ejemplo n.º 1
0
 private Amazon.ECR.Model.CreateRepositoryResponse CallAWSServiceOperation(IAmazonECR client, Amazon.ECR.Model.CreateRepositoryRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Registry", "CreateRepository");
     try
     {
         #if DESKTOP
         return(client.CreateRepository(request));
         #elif CORECLR
         return(client.CreateRepositoryAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a repository on ECR.
        /// </summary>
        /// <param name="repository"></param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task CreateRepositoryAsync(Models.Repository repository)
        {
            if (repository.Name.Equals(""))
            {
                throw new InvalidRepositoryName("Repository name cannot be an empty string.");
            }

            try
            {
                await _ecrClient.CreateRepositoryAsync(new CreateRepositoryRequest
                {
                    RepositoryName = repository.Name
                });
            }
            catch (RepositoryAlreadyExistsException)
            {
                throw;
            }
            catch (AmazonECRException)
            {
                throw;
            }
        }