Skip to content

Commit

Permalink
feat(Discovery): Add size parameter to updateEnvironment method
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Oliveri committed Oct 19, 2018
1 parent 28efe1e commit 725e1d5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Source/DiscoveryV1/Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public class Discovery {

- parameter name: Name that identifies the environment.
- parameter description: Description of the environment.
- parameter size: Size of the environment.
- parameter size: Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all
other plans the default is `S`.
- parameter headers: A dictionary of request headers to be sent with this request.
- parameter failure: A function executed if an error occurs.
- parameter success: A function executed with the successful result.
Expand Down Expand Up @@ -284,6 +285,8 @@ public class Discovery {
- parameter environmentID: The ID of the environment.
- parameter name: Name that identifies the environment.
- parameter description: Description of the environment.
- parameter size: Size that the environment should be increased to. Environment size cannot be modified when
using a Lite plan. Environment size can only increased and not decreased.
- parameter headers: A dictionary of request headers to be sent with this request.
- parameter failure: A function executed if an error occurs.
- parameter success: A function executed with the successful result.
Expand All @@ -292,12 +295,13 @@ public class Discovery {
environmentID: String,
name: String? = nil,
description: String? = nil,
size: String? = nil,
headers: [String: String]? = nil,
failure: ((Error) -> Void)? = nil,
success: @escaping (Environment) -> Void)
{
// construct body
let updateEnvironmentRequest = UpdateEnvironmentRequest(name: name, description: description)
let updateEnvironmentRequest = UpdateEnvironmentRequest(name: name, description: description, size: size)
guard let body = try? JSONEncoder().encode(updateEnvironmentRequest) else {
failure?(RestError.serializationError)
return
Expand Down
28 changes: 27 additions & 1 deletion Source/DiscoveryV1/Models/UpdateEnvironmentRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ import Foundation
/** UpdateEnvironmentRequest. */
internal struct UpdateEnvironmentRequest: Encodable {

/**
Size that the environment should be increased to. Environment size cannot be modified when using a Lite plan.
Environment size can only increased and not decreased.
*/
public enum Size: String {
case s = "S"
case ms = "MS"
case m = "M"
case ml = "ML"
case l = "L"
case xl = "XL"
case xxl = "XXL"
case xxxl = "XXXL"
}

/**
Name that identifies the environment.
*/
Expand All @@ -29,27 +44,38 @@ internal struct UpdateEnvironmentRequest: Encodable {
*/
public var description: String?

/**
Size that the environment should be increased to. Environment size cannot be modified when using a Lite plan.
Environment size can only increased and not decreased.
*/
public var size: String?

// Map each property name to the key that shall be used for encoding/decoding.
private enum CodingKeys: String, CodingKey {
case name = "name"
case description = "description"
case size = "size"
}

/**
Initialize a `UpdateEnvironmentRequest` with member variables.

- parameter name: Name that identifies the environment.
- parameter description: Description of the environment.
- parameter size: Size that the environment should be increased to. Environment size cannot be modified when
using a Lite plan. Environment size can only increased and not decreased.

- returns: An initialized `UpdateEnvironmentRequest`.
*/
public init(
name: String? = nil,
description: String? = nil
description: String? = nil,
size: String? = nil
)
{
self.name = name
self.description = description
self.size = size
}

}

0 comments on commit 725e1d5

Please sign in to comment.