|
| 1 | +package tos |
| 2 | + |
| 3 | +import ( |
| 4 | + "bytes" |
| 5 | + "context" |
| 6 | + "net/http" |
| 7 | +) |
| 8 | + |
| 9 | +func (cli *ClientV2) CreateAccessPoint(ctx context.Context, input *CreateAccessPointInput) (*CreateAccessPointOutput, error) { |
| 10 | + |
| 11 | + if input == nil { |
| 12 | + return nil, InputIsNilClientError |
| 13 | + } |
| 14 | + data, contentMD5, err := marshalInput("CreateAccessPoint", input) |
| 15 | + if err != nil { |
| 16 | + return nil, err |
| 17 | + } |
| 18 | + |
| 19 | + res, err := cli.newControlBuilder(input.AccountID). |
| 20 | + SetGeneric(input.GenericInput). |
| 21 | + WithHeader(HeaderContentMD5, contentMD5). |
| 22 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 23 | + RequestControl(ctx, http.MethodPut, bytes.NewReader(data), "/accesspoint/"+input.AccessPointName, cli.roundTripper(http.StatusOK)) |
| 24 | + if err != nil { |
| 25 | + return nil, err |
| 26 | + } |
| 27 | + defer res.Close() |
| 28 | + output := CreateAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 29 | + if err := marshalOutput(res, &output); err != nil { |
| 30 | + return nil, err |
| 31 | + } |
| 32 | + return &output, nil |
| 33 | +} |
| 34 | + |
| 35 | +func (cli *ClientV2) GetAccessPoint(ctx context.Context, input *GetAccessPointInput) (*GetAccessPointOutput, error) { |
| 36 | + if input == nil { |
| 37 | + return nil, InputIsNilClientError |
| 38 | + } |
| 39 | + |
| 40 | + res, err := cli.newControlBuilder(input.AccountID). |
| 41 | + SetGeneric(input.GenericInput). |
| 42 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 43 | + RequestControl(ctx, http.MethodGet, nil, "/accesspoint/"+input.AccessPointName, cli.roundTripper(http.StatusOK)) |
| 44 | + if err != nil { |
| 45 | + return nil, err |
| 46 | + } |
| 47 | + defer res.Close() |
| 48 | + output := GetAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 49 | + if err := marshalOutput(res, &output); err != nil { |
| 50 | + return nil, err |
| 51 | + } |
| 52 | + return &output, nil |
| 53 | +} |
| 54 | + |
| 55 | +func (cli *ClientV2) ListAccessPoints(ctx context.Context, input *ListAccessPointsInput) (*ListAccessPointsOutput, error) { |
| 56 | + if input == nil { |
| 57 | + return nil, InputIsNilClientError |
| 58 | + } |
| 59 | + |
| 60 | + res, err := cli.newControlBuilder(input.AccountID). |
| 61 | + SetGeneric(input.GenericInput). |
| 62 | + WithParams(*input). |
| 63 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 64 | + RequestControl(ctx, http.MethodGet, nil, "/accesspoint", cli.roundTripper(http.StatusOK)) |
| 65 | + if err != nil { |
| 66 | + return nil, err |
| 67 | + } |
| 68 | + defer res.Close() |
| 69 | + output := ListAccessPointsOutput{RequestInfo: res.RequestInfo()} |
| 70 | + if err := marshalOutput(res, &output); err != nil { |
| 71 | + return nil, err |
| 72 | + } |
| 73 | + return &output, nil |
| 74 | +} |
| 75 | + |
| 76 | +func (cli *ClientV2) DeleteAccessPoint(ctx context.Context, input *DeleteAccessPointInput) (*DeleteAccessPointOutput, error) { |
| 77 | + if input == nil { |
| 78 | + return nil, InputIsNilClientError |
| 79 | + } |
| 80 | + |
| 81 | + res, err := cli.newControlBuilder(input.AccountID). |
| 82 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 83 | + RequestControl(ctx, http.MethodDelete, nil, "/accesspoint/"+input.AccessPointName, cli.roundTripper(http.StatusNoContent)) |
| 84 | + if err != nil { |
| 85 | + return nil, err |
| 86 | + } |
| 87 | + defer res.Close() |
| 88 | + output := DeleteAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 89 | + return &output, nil |
| 90 | +} |
| 91 | + |
| 92 | +func (cli *ClientV2) ListBindAcceleratorForAccessPoint(ctx context.Context, input *ListBindAcceleratorForAccessPointInput) (*ListBindAcceleratorForAccessPointOutput, error) { |
| 93 | + if input == nil { |
| 94 | + return nil, InputIsNilClientError |
| 95 | + } |
| 96 | + |
| 97 | + res, err := cli.newControlBuilder(input.AccountID). |
| 98 | + SetGeneric(input.GenericInput). |
| 99 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 100 | + RequestControl(ctx, http.MethodGet, nil, "/accesspoint/"+input.AccessPointName+"/accelerator", cli.roundTripper(http.StatusOK)) |
| 101 | + if err != nil { |
| 102 | + return nil, err |
| 103 | + } |
| 104 | + defer res.Close() |
| 105 | + output := ListBindAcceleratorForAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 106 | + if err := marshalOutput(res, &output); err != nil { |
| 107 | + return nil, err |
| 108 | + } |
| 109 | + return &output, nil |
| 110 | +} |
| 111 | + |
| 112 | +func (cli *ClientV2) ListBindAccessPointForAccelerator(ctx context.Context, input *ListBindAccessPointForAcceleratorInput) (*ListBindAccessPointForAcceleratorOutput, error) { |
| 113 | + if input == nil { |
| 114 | + return nil, InputIsNilClientError |
| 115 | + } |
| 116 | + |
| 117 | + res, err := cli.newControlBuilder(input.AccountID). |
| 118 | + SetGeneric(input.GenericInput). |
| 119 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 120 | + RequestControl(ctx, http.MethodGet, nil, "/accelerator/"+input.AcceleratorID+"/accesspoint", cli.roundTripper(http.StatusOK)) |
| 121 | + if err != nil { |
| 122 | + return nil, err |
| 123 | + } |
| 124 | + defer res.Close() |
| 125 | + output := ListBindAccessPointForAcceleratorOutput{RequestInfo: res.RequestInfo()} |
| 126 | + if err := marshalOutput(res, &output); err != nil { |
| 127 | + return nil, err |
| 128 | + } |
| 129 | + return &output, nil |
| 130 | +} |
| 131 | + |
| 132 | +func (cli *ClientV2) BindAcceleratorWithAccessPoint(ctx context.Context, input *BindAcceleratorWithAccessPointInput) (*BindAcceleratorWithAccessPointOutput, error) { |
| 133 | + |
| 134 | + if input == nil { |
| 135 | + return nil, InputIsNilClientError |
| 136 | + } |
| 137 | + |
| 138 | + res, err := cli.newControlBuilder(input.AccountID). |
| 139 | + SetGeneric(input.GenericInput). |
| 140 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 141 | + RequestControl(ctx, http.MethodPut, nil, "/accesspoint/"+input.AccessPointName+"/accelerator/"+input.AcceleratorID, cli.roundTripper(http.StatusOK)) |
| 142 | + if err != nil { |
| 143 | + return nil, err |
| 144 | + } |
| 145 | + defer res.Close() |
| 146 | + output := BindAcceleratorWithAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 147 | + return &output, nil |
| 148 | +} |
| 149 | + |
| 150 | +func (cli *ClientV2) UnbindAcceleratorWithAccessPoint(ctx context.Context, input *UnbindAcceleratorWithAccessPointInput) (*UnbindAcceleratorWithAccessPointOutput, error) { |
| 151 | + if input == nil { |
| 152 | + return nil, InputIsNilClientError |
| 153 | + } |
| 154 | + res, err := cli.newControlBuilder(input.AccountID). |
| 155 | + SetGeneric(input.GenericInput). |
| 156 | + WithRetry(OnRetryFromStart, StatusCodeClassifier{}). |
| 157 | + RequestControl(ctx, http.MethodDelete, nil, "/accesspoint/"+input.AccessPointName+"/accelerator/"+input.AcceleratorID, cli.roundTripper(http.StatusNoContent)) |
| 158 | + if err != nil { |
| 159 | + return nil, err |
| 160 | + } |
| 161 | + defer res.Close() |
| 162 | + output := UnbindAcceleratorWithAccessPointOutput{RequestInfo: res.RequestInfo()} |
| 163 | + return &output, nil |
| 164 | +} |
0 commit comments