|
| 1 | +# WARNING: DO NOT EDIT, AUTO-GENERATED CODE! |
| 2 | +# See https://github.com/jkakar/aws-codegen for more details. |
| 3 | + |
| 4 | +defmodule AWS.AutoScaling do |
| 5 | + @moduledoc """ |
| 6 | + Application Auto Scaling is a general purpose Auto Scaling service for |
| 7 | + supported elastic AWS resources. With Application Auto Scaling, you can |
| 8 | + automatically scale your AWS resources, with an experience similar to that |
| 9 | + of Auto Scaling. |
| 10 | +
|
| 11 | + <note> At this time, Application Auto Scaling only supports scaling Amazon |
| 12 | + ECS services. |
| 13 | +
|
| 14 | + </note> For example, you can use Application Auto Scaling to accomplish the |
| 15 | + following tasks: |
| 16 | +
|
| 17 | + <ul> <li> Define scaling policies for automatically adjusting your |
| 18 | + application’s resources |
| 19 | +
|
| 20 | + </li> <li> Scale your resources in response to CloudWatch alarms |
| 21 | +
|
| 22 | + </li> <li> View history of your scaling events |
| 23 | +
|
| 24 | + </li> </ul> Application Auto Scaling is available in the following regions: |
| 25 | +
|
| 26 | + <ul> <li> `us-east-1` |
| 27 | +
|
| 28 | + </li> <li> `us-west-2` |
| 29 | +
|
| 30 | + </li> <li> `eu-west-1` |
| 31 | +
|
| 32 | + </li> </ul> |
| 33 | + """ |
| 34 | + |
| 35 | + @doc """ |
| 36 | + Deletes an Application Auto Scaling scaling policy that was previously |
| 37 | + created. If you are no longer using a scaling policy, you can delete it |
| 38 | + with this operation. |
| 39 | +
|
| 40 | + Deleting a policy deletes the underlying alarm action, but does not delete |
| 41 | + the CloudWatch alarm, even if it no longer has an associated action. |
| 42 | +
|
| 43 | + To create a new scaling policy or update an existing one, see |
| 44 | + `PutScalingPolicy`. |
| 45 | + """ |
| 46 | + def delete_scaling_policy(client, input, options \\ []) do |
| 47 | + request(client, "DeleteScalingPolicy", input, options) |
| 48 | + end |
| 49 | + |
| 50 | + @doc """ |
| 51 | + Deregisters a scalable target that was previously registered. If you are no |
| 52 | + longer using a scalable target, you can delete it with this operation. When |
| 53 | + you deregister a scalable target, all of the scaling policies that are |
| 54 | + associated with that scalable target are deleted. |
| 55 | +
|
| 56 | + To create a new scalable target or update an existing one, see |
| 57 | + `RegisterScalableTarget`. |
| 58 | + """ |
| 59 | + def deregister_scalable_target(client, input, options \\ []) do |
| 60 | + request(client, "DeregisterScalableTarget", input, options) |
| 61 | + end |
| 62 | + |
| 63 | + @doc """ |
| 64 | + Provides descriptive information for scalable targets with a specified |
| 65 | + service namespace. |
| 66 | +
|
| 67 | + You can filter the results in a service namespace with the `ResourceIds` |
| 68 | + and `ScalableDimension` parameters. |
| 69 | +
|
| 70 | + To create a new scalable target or update an existing one, see |
| 71 | + `RegisterScalableTarget`. If you are no longer using a scalable target, you |
| 72 | + can deregister it with `DeregisterScalableTarget`. |
| 73 | + """ |
| 74 | + def describe_scalable_targets(client, input, options \\ []) do |
| 75 | + request(client, "DescribeScalableTargets", input, options) |
| 76 | + end |
| 77 | + |
| 78 | + @doc """ |
| 79 | + Provides descriptive information for scaling activities with a specified |
| 80 | + service namespace. |
| 81 | +
|
| 82 | + You can filter the results in a service namespace with the `ResourceId` and |
| 83 | + `ScalableDimension` parameters. |
| 84 | +
|
| 85 | + Scaling activities are triggered by CloudWatch alarms that are associated |
| 86 | + with scaling policies. To view the existing scaling policies for a service |
| 87 | + namespace, see `DescribeScalingPolicies`. To create a new scaling policy or |
| 88 | + update an existing one, see `PutScalingPolicy`. |
| 89 | + """ |
| 90 | + def describe_scaling_activities(client, input, options \\ []) do |
| 91 | + request(client, "DescribeScalingActivities", input, options) |
| 92 | + end |
| 93 | + |
| 94 | + @doc """ |
| 95 | + Provides descriptive information for scaling policies with a specified |
| 96 | + service namespace. |
| 97 | +
|
| 98 | + You can filter the results in a service namespace with the `ResourceId`, |
| 99 | + `ScalableDimension`, and `PolicyNames` parameters. |
| 100 | +
|
| 101 | + To create a new scaling policy or update an existing one, see |
| 102 | + `PutScalingPolicy`. If you are no longer using a scaling policy, you can |
| 103 | + delete it with `DeleteScalingPolicy`. |
| 104 | + """ |
| 105 | + def describe_scaling_policies(client, input, options \\ []) do |
| 106 | + request(client, "DescribeScalingPolicies", input, options) |
| 107 | + end |
| 108 | + |
| 109 | + @doc """ |
| 110 | + Creates or updates a policy for an existing Application Auto Scaling |
| 111 | + scalable target. Each scalable target is identified by service namespace, a |
| 112 | + resource ID, and a scalable dimension, and a scaling policy applies to a |
| 113 | + scalable target that is identified by those three attributes. You cannot |
| 114 | + create a scaling policy without first registering a scalable target with |
| 115 | + `RegisterScalableTarget`. |
| 116 | +
|
| 117 | + To update an existing policy, use the existing policy name and set the |
| 118 | + parameters you want to change. Any existing parameter not changed in an |
| 119 | + update to an existing policy is not changed in this update request. |
| 120 | +
|
| 121 | + You can view the existing scaling policies for a service namespace with |
| 122 | + `DescribeScalingPolicies`. If you are no longer using a scaling policy, you |
| 123 | + can delete it with `DeleteScalingPolicy`. |
| 124 | + """ |
| 125 | + def put_scaling_policy(client, input, options \\ []) do |
| 126 | + request(client, "PutScalingPolicy", input, options) |
| 127 | + end |
| 128 | + |
| 129 | + @doc """ |
| 130 | + Registers or updates a scalable target. A scalable target is a resource |
| 131 | + that can be scaled up or down with Application Auto Scaling. After you have |
| 132 | + registered a scalable target, you can use this command to update the |
| 133 | + minimum and maximum values for your scalable dimension. |
| 134 | +
|
| 135 | + <note> At this time, Application Auto Scaling only supports scaling Amazon |
| 136 | + ECS services. |
| 137 | +
|
| 138 | + </note> After you register a scalable target with Application Auto Scaling, |
| 139 | + you can create and apply scaling policies to it with `PutScalingPolicy`. |
| 140 | + You can view the existing scaling policies for a service namespace with |
| 141 | + `DescribeScalableTargets`. If you are no longer using a scalable target, |
| 142 | + you can deregister it with `DeregisterScalableTarget`. |
| 143 | + """ |
| 144 | + def register_scalable_target(client, input, options \\ []) do |
| 145 | + request(client, "RegisterScalableTarget", input, options) |
| 146 | + end |
| 147 | + |
| 148 | + @spec request(map(), binary(), map(), list()) :: |
| 149 | + {:ok, Poison.Parser.t | nil, Poison.Response.t} | |
| 150 | + {:error, Poison.Parser.t} | |
| 151 | + {:error, HTTPoison.Error.t} |
| 152 | + defp request(client, action, input, options) do |
| 153 | + client = %{client | service: "autoscaling"} |
| 154 | + host = get_host("autoscaling", client) |
| 155 | + url = get_url(host, client) |
| 156 | + headers = [{"Host", host}, |
| 157 | + {"Content-Type", "application/x-amz-json-1.1"}, |
| 158 | + {"X-Amz-Target", "AnyScaleFrontendService.#{action}"}] |
| 159 | + payload = Poison.Encoder.encode(input, []) |
| 160 | + headers = AWS.Request.sign_v4(client, "POST", url, headers, payload) |
| 161 | + case HTTPoison.post(url, payload, headers, options) do |
| 162 | + {:ok, response=%HTTPoison.Response{status_code: 200, body: ""}} -> |
| 163 | + {:ok, nil, response} |
| 164 | + {:ok, response=%HTTPoison.Response{status_code: 200, body: body}} -> |
| 165 | + {:ok, Poison.Parser.parse!(body), response} |
| 166 | + {:ok, _response=%HTTPoison.Response{body: body}} -> |
| 167 | + error = Poison.Parser.parse!(body) |
| 168 | + exception = error["__type"] |
| 169 | + message = error["message"] |
| 170 | + {:error, {exception, message}} |
| 171 | + {:error, %HTTPoison.Error{reason: reason}} -> |
| 172 | + {:error, %HTTPoison.Error{reason: reason}} |
| 173 | + end |
| 174 | + end |
| 175 | + |
| 176 | + defp get_host(endpoint_prefix, client) do |
| 177 | + if client.region == "local" do |
| 178 | + "localhost" |
| 179 | + else |
| 180 | + "#{endpoint_prefix}.#{client.region}.#{client.endpoint}" |
| 181 | + end |
| 182 | + end |
| 183 | + |
| 184 | + defp get_url(host, %{:proto => proto, :port => port}) do |
| 185 | + "#{proto}://#{host}:#{port}/" |
| 186 | + end |
| 187 | + |
| 188 | +end |
0 commit comments