Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
apis
Project
Commits
6c333afb
Commit
6c333afb
authored
Jun 26, 2020
by
Benedikt Heinrichs
Browse files
New: Create a method for getting quotas (coscine/issues#858)
parent
64f2c417
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Project.Tests/Project.Tests.csproj
View file @
6c333afb
...
...
@@ -65,8 +65,8 @@
<Reference
Include=
"Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database, Version=1.2
1
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
1
.0\lib\net461\Coscine.Database.dll
</HintPath>
<Reference
Include=
"Coscine.Database, Version=1.2
2
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
2
.0
-topic-858-quotaa0002
\lib\net461\Coscine.Database.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e1ed402bc3f6525e, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Logging.1.2.0\lib\net461\Coscine.Logging.dll
</HintPath>
...
...
src/Project.Tests/app.config
View file @
6c333afb
...
...
@@ -88,7 +88,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database"
publicKeyToken
=
"767d77427707b70a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
1
.0.0"
newVersion
=
"1.2
1
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
2
.0.0"
newVersion
=
"1.2
2
.0.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.IdentityModel.Tokens.Jwt"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
...
...
src/Project.Tests/packages.config
View file @
6c333afb
...
...
@@ -7,7 +7,7 @@
<
package
id
=
"Coscine.Action"
version
=
"1.13.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.8.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Configuration"
version
=
"1.5.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
1
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
2
.0
-topic-858-quotaa0002
"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Logging"
version
=
"1.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ProxyApi"
version
=
"1.2.1"
targetFramework
=
"net472"
/>
<
package
id
=
"EntityFramework"
version
=
"6.2.0"
targetFramework
=
"net472"
/>
...
...
src/Project/App.config
View file @
6c333afb
...
...
@@ -91,7 +91,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database"
publicKeyToken
=
"767d77427707b70a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
1
.0.0"
newVersion
=
"1.2
1
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
2
.0.0"
newVersion
=
"1.2
2
.0.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.IdentityModel.Tokens.Jwt"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
...
...
src/Project/Controllers/ProjectController.cs
View file @
6c333afb
...
...
@@ -112,7 +112,50 @@ namespace Coscine.Api.Project.Controllers
}
}
[
HttpGet
(
"[controller]/{id}/quotas"
)]
public
IActionResult
Quotas
(
string
id
)
{
var
user
=
_authenticator
.
GetUser
();
var
projectObject
=
ObjectFactory
<
ProjectObject
>.
DeserializeFromStream
(
Request
.
Body
);
var
guidId
=
Guid
.
Parse
(
id
);
var
project
=
_projectModel
.
GetById
(
guidId
);
if
(
_projectModel
.
HasAccess
(
user
,
project
,
UserRoles
.
Owner
))
{
ProjectQuotaModel
projectQuotaModel
=
new
ProjectQuotaModel
();
var
projectQuotas
=
projectQuotaModel
.
GetAllWhere
((
projectQuota
)
=>
projectQuota
.
ProjectId
==
guidId
&&
projectQuota
.
ResourceType
.
Enabled
==
true
)
.
Select
((
projectQuota
)
=>
projectQuotaModel
.
CreateReturnObjectFromDatabaseObject
(
projectQuota
));
ResourceModel
resourceModel
=
new
ResourceModel
();
RDSResourceTypeModel
rdsResourceTypeModel
=
new
RDSResourceTypeModel
();
var
returnList
=
new
List
<
dynamic
>();
foreach
(
var
projectQuota
in
projectQuotas
)
{
// TODO: Cleanup quota and give it to every resource, this hard coded solution seems not scalable
if
(
projectQuota
.
ResourceType
.
DisplayName
==
"rds"
)
{
var
resources
=
resourceModel
.
GetAllWhere
((
resource
)
=>
resource
.
TypeId
==
projectQuota
.
ResourceType
.
Id
);
var
size
=
resources
.
Sum
((
resource
)
=>
rdsResourceTypeModel
.
GetById
(
resource
.
ResourceTypeOptionId
.
Value
).
Size
);
returnList
.
Add
(
new
{
type
=
projectQuota
.
ResourceType
.
DisplayName
,
available
=
projectQuota
.
Quotas
,
allocated
=
size
});
}
}
return
Json
(
returnList
);
}
else
{
return
Unauthorized
(
"The user is not authorized to perform a get on the selected project!"
);
}
}
[
HttpPost
(
"[controller]/{id}"
)]
public
IActionResult
Update
(
string
id
)
...
...
src/Project/Project.csproj
View file @
6c333afb
...
...
@@ -58,8 +58,8 @@
<Reference
Include=
"Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database, Version=1.2
1
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
1
.0\lib\net461\Coscine.Database.dll
</HintPath>
<Reference
Include=
"Coscine.Database, Version=1.2
2
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
2
.0
-topic-858-quotaa0002
\lib\net461\Coscine.Database.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e1ed402bc3f6525e, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Logging.1.2.0\lib\net461\Coscine.Logging.dll
</HintPath>
...
...
src/Project/packages.config
View file @
6c333afb
...
...
@@ -7,7 +7,7 @@
<
package
id
=
"Coscine.Action"
version
=
"1.13.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.8.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Configuration"
version
=
"1.5.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
1
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
2
.0
-topic-858-quotaa0002
"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Logging"
version
=
"1.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ProxyApi"
version
=
"1.2.1"
targetFramework
=
"net472"
/>
<
package
id
=
"EntityFramework"
version
=
"6.2.0"
targetFramework
=
"net472"
/>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment